Verified Commit 86fd69e9 authored by staltz's avatar staltz

WIP UI work (connect to bluetooth staged peer)

parent 0884238c
......@@ -280,8 +280,6 @@ export class SSBSource {
})),
);
bluetooth$.subscribe({next: x => console.warn(JSON.stringify(x))});
return xs.combine(bluetooth$, hosting$, claiming$);
})
.flatten()
......@@ -425,6 +423,11 @@ export type SearchBluetoothReq = {
interval: number;
};
export type ConnectBluetoothReq = {
type: 'connectBluetooth';
address: string;
};
export type Req =
| PublishReq
| PublishAboutReq
......@@ -432,7 +435,8 @@ export type Req =
| StartDhtReq
| AcceptDhtInviteReq
| RemoveDhtInviteReq
| SearchBluetoothReq;
| SearchBluetoothReq
| ConnectBluetoothReq;
function dropCompletion(stream: Stream<any>): Stream<any> {
return xs.merge(stream, xs.never());
......@@ -501,6 +505,11 @@ export function ssbDriver(sink: Stream<Req>): SSBSource {
if (err) console.error(err.message || err);
});
}
if (req.type === 'connectBluetooth') {
api.sbot.async.gossipConnect[0]('bt:' + req.address, (err: any) => {
if (err) console.error(err.message || err);
});
}
if (req.type === 'dhtInvite.accept') {
api.sbot.async.acceptDhtInvite[0](req.invite, (err: any, v: any) => {
if (err) {
......
......@@ -5,11 +5,12 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
import xs, {Stream} from 'xstream';
import {Req} from '../../../drivers/ssb';
import {Req, StagedPeerMetadata} from '../../../drivers/ssb';
export type Actions = {
removeDhtInvite$: Stream<string>;
bluetoothSearch$: Stream<any>;
openStagedPeer$: Stream<StagedPeerMetadata>;
};
export default function ssb(actions: Actions) {
......@@ -20,5 +21,8 @@ export default function ssb(actions: Actions) {
actions.bluetoothSearch$.mapTo(
{type: 'searchBluetooth', interval: 60e3} as Req,
),
actions.openStagedPeer$
.filter(peer => peer.source === 'bluetooth')
.map(peer => ({type: 'connectBluetooth', address: peer.key} as Req)),
);
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment