git ssb

1+

Daan Patchwork / manyverse



Commit 3a3e0ac54766595cc6a9614997bbf324f7b2d366

dx: [ios] remove everything Bluetooth related

Andre Staltz committed on 1/4/2020, 2:37:13 PM
Parent: 005463227a5ccddff19c47b81fe93d641b10fefc

Files changed

src/frontend/drivers/network.tschanged
src/frontend/drivers/ssb.tschanged
src/frontend/screens/central/connections-tab/model.tschanged
src/frontend/screens/central/connections-tab/view/index.tschanged
src/frontend/screens/welcome/view.tschanged
src/frontend/drivers/network.tsView
@@ -16,8 +16,14 @@
1616
1717 public bluetoothIsEnabled(): Stream<boolean> {
1818 return xs.create({
1919 async start(listener: Listener<boolean>) {
20+ if (Platform.OS === 'ios') {
21+ listener.next(false);
22+ listener.complete();
23+ return;
24+ }
25+
2026 try {
2127 listener.next(await BluetoothStatus.state());
2228 listener.complete();
2329 } catch (e) {
src/frontend/drivers/ssb.tsView
@@ -15,8 +15,9 @@
1515 AboutContent,
1616 BlobId,
1717 } from 'ssb-typescript';
1818 const nodejs = require('nodejs-mobile-react-native');
19+import {Platform} from 'react-native';
1920 import {isMsg, isRootPostMsg, isReplyPostMsg} from 'ssb-typescript/utils';
2021 import {Thread as ThreadData} from 'ssb-threads/types';
2122 import xsFromCallback from 'xstream-from-callback';
2223 import runAsync = require('promisify-tuple');
@@ -301,12 +302,15 @@
301302 return peersArr$;
302303 })
303304 .flatten();
304305
305- this.bluetoothScanState$ = this.ssb$
306- .map(ssb => ssb.bluetooth.bluetoothScanState())
307- .map(xsFromPullStream)
308- .flatten();
306+ this.bluetoothScanState$ =
307+ Platform.OS === 'ios'
308+ ? xs.empty()
309+ : this.ssb$
310+ .map(ssb => ssb.bluetooth.bluetoothScanState())
311+ .map(xsFromPullStream)
312+ .flatten();
309313 }
310314
311315 public thread$(rootMsgId: MsgId): Stream<ThreadAndExtras> {
312316 const ssbToThread = (ssb: any, cb: any) => {
@@ -726,11 +730,13 @@
726730 return;
727731 }
728732
729733 if (req.type === 'bluetooth.search') {
730- ssb.bluetooth.makeDeviceDiscoverable(req.interval, (err: any) => {
731- if (err) return console.error(err.message || err);
732- });
734+ if (Platform.OS !== 'ios') {
735+ ssb.bluetooth.makeDeviceDiscoverable(req.interval, (err: any) => {
736+ if (err) return console.error(err.message || err);
737+ });
738+ }
733739 return;
734740 }
735741
736742 if (req.type === 'dhtInvite.accept') {
src/frontend/screens/central/connections-tab/model.tsView
@@ -6,17 +6,18 @@
66
77 import xs, {Stream} from 'xstream';
88 import {FeedId} from 'ssb-typescript';
99 import {Reducer} from '@cycle/state';
10+import {AsyncStorageSource} from 'cycle-native-asyncstorage';
11+import {Platform} from 'react-native';
1012 import {SSBSource} from '../../../drivers/ssb';
1113 import {
1214 PeerKV,
1315 StagedPeerKV,
1416 StagedPeerMetadata as StagedPeer,
1517 } from '../../../ssb/types';
1618 import {NetworkSource} from '../../../drivers/network';
1719 import {noteStorageKeyFor} from './asyncstorage';
18-import {AsyncStorageSource} from 'cycle-native-asyncstorage';
1920
2021 export type State = {
2122 selfFeedId: FeedId;
2223 bluetoothEnabled: boolean;
@@ -88,17 +89,20 @@
8889 return {...prev, isSyncing};
8990 },
9091 );
9192
92- const updateBluetoothEnabled$ = actions.pingConnectivityModes$
93- .map(() => networkSource.bluetoothIsEnabled())
94- .flatten()
95- .map(
96- bluetoothEnabled =>
97- function updateBluetoothEnabled(prev: State): State {
98- return {...prev, bluetoothEnabled};
99- },
100- );
93+ const updateBluetoothEnabled$ =
94+ Platform.OS === 'ios'
95+ ? xs.empty()
96+ : actions.pingConnectivityModes$
97+ .map(() => networkSource.bluetoothIsEnabled())
98+ .flatten()
99+ .map(
100+ bluetoothEnabled =>
101+ function updateBluetoothEnabled(prev: State): State {
102+ return {...prev, bluetoothEnabled};
103+ },
104+ );
101105
102106 const updateLanEnabled$ = actions.pingConnectivityModes$
103107 .map(() => networkSource.wifiIsEnabled())
104108 .flatten()
src/frontend/screens/central/connections-tab/view/index.tsView
@@ -12,8 +12,9 @@
1212 TouchableHighlight,
1313 Animated,
1414 Easing,
1515 ActivityIndicator,
16+ Platform,
1617 } from 'react-native';
1718 import * as React from 'react';
1819 import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
1920 import {styles} from './styles';
@@ -105,15 +106,17 @@
105106 }
106107
107108 function ConnectivityModes(state: State) {
108109 return h(View, {style: styles.modesContainer}, [
109- h(ConnectivityMode, {
110- sel: 'bluetooth-mode',
111- active: state.bluetoothEnabled,
112- icon: 'bluetooth',
113- label: 'Bluetooth Mode',
114- lastScanned: state.bluetoothLastScanned,
115- }),
110+ Platform.OS === 'ios'
111+ ? null
112+ : h(ConnectivityMode, {
113+ sel: 'bluetooth-mode',
114+ active: state.bluetoothEnabled,
115+ icon: 'bluetooth',
116+ label: 'Bluetooth Mode',
117+ lastScanned: state.bluetoothLastScanned,
118+ }),
116119
117120 h(ConnectivityMode, {
118121 sel: 'lan-mode',
119122 active: state.lanEnabled,
src/frontend/screens/welcome/view.tsView
@@ -7,9 +7,9 @@
77 import {Stream} from 'xstream';
88 import {h} from '@cycle/react';
99 import {Palette} from '../../global-styles/palette';
1010 import {Dimensions} from '../../global-styles/dimens';
11-import {StyleSheet, Text, View, Image} from 'react-native';
11+import {StyleSheet, Text, View, Image, Platform} from 'react-native';
1212 import tutorialSlide from '../../components/tutorial-slide';
1313 import tutorialPresentation from '../../components/tutorial-presentation';
1414 import Button from '../../components/Button';
1515 import {State} from './model';
@@ -139,11 +139,16 @@
139139 renderDescription: () => [
140140 'To connect with friends and synchronize content, you can ' +
141141 'either: join the same ',
142142 h(Text, {style: styles.bold}, 'Wi-Fi'),
143- ', use ',
144- h(Text, {style: styles.bold}, 'Bluetooth sync'),
145- ', or exchange ',
143+ ...Platform.select({
144+ ios: [' or exchange '],
145+ default: [
146+ ', use ',
147+ h(Text, {style: styles.bold}, 'Bluetooth sync'),
148+ ', or exchange ',
149+ ],
150+ }),
146151 h(Text, {style: styles.bold}, 'P2P invites'),
147152 '. To find new people on the internet, look for an invite code ' +
148153 'to a ',
149154 h(Text, {style: styles.bold}, 'pub server'),

Built with git-ssb-web