git ssb

1+

Daan Patchwork / manyverse



Commit cfa701991cd5e09c587fca0fed40801f3bb5dcf2

dx: rename SyncTab to ConnectionsTab

Andre Staltz committed on 8/22/2018, 7:55:58 PM
Parent: 9c43dc489a4000eaa7eb961144517d9fe4fa9c3f

Files changed

e2e/central.jschanged
src/app/screens/central/index.tschanged
src/app/screens/central/model.tschanged
src/app/screens/central/view.tschanged
src/app/screens/central/connections-tab/README.mdadded
src/app/screens/central/connections-tab/index.tsadded
src/app/screens/central/connections-tab/intent.tsadded
src/app/screens/central/connections-tab/model.tsadded
src/app/screens/central/connections-tab/navigation.tsadded
src/app/screens/central/connections-tab/styles.tsadded
src/app/screens/central/connections-tab/view.tsadded
src/app/screens/central/sync-tab/README.mddeleted
src/app/screens/central/sync-tab/index.tsdeleted
src/app/screens/central/sync-tab/intent.tsdeleted
src/app/screens/central/sync-tab/model.tsdeleted
src/app/screens/central/sync-tab/navigation.tsdeleted
src/app/screens/central/sync-tab/styles.tsdeleted
src/app/screens/central/sync-tab/view.tsdeleted
e2e/central.jsView
@@ -36,20 +36,20 @@
3636 ),
3737 'I see Public tab button',
3838 );
3939
40- // Sync tab
41- const syncTabButton = await driver.elementByAndroidUIAutomator(
42- 'new UiSelector().descriptionContains("Sync Tab Button")',
40+ // Connections tab
41+ const connectionsTabButton = await driver.elementByAndroidUIAutomator(
42+ 'new UiSelector().descriptionContains("Connections Tab Button")',
4343 );
44- t.ok(syncTabButton, 'I see Sync Tab button');
45- await syncTabButton.tap();
44+ t.ok(connectionsTabButton, 'I see the Connections Tab button');
45+ await connectionsTabButton.tap();
4646 t.pass('I tap it');
4747 t.ok(
4848 await driver.elementByAndroidUIAutomator(
4949 'new UiSelector().textContains("Friends around you")',
5050 ),
51- 'I see Sync tab body',
51+ 'I see Connections tab body',
5252 );
5353
5454 const lanHelpButton = await driver.elementByAndroidUIAutomator(
5555 'new UiSelector().descriptionContains("Show LAN Help")',
src/app/screens/central/index.tsView
@@ -26,12 +26,20 @@
2626 import {Toast, Duration as ToastDuration} from '../../drivers/toast';
2727 import {Command, NavSource} from 'cycle-native-navigation';
2828 import {SSBSource, Req} from '../../drivers/ssb';
2929 import {publicTab, Sinks as PublicTabSinks} from './public-tab/index';
30-import {syncTab, Sinks as SyncTabSinks} from './sync-tab/index';
30+import {
31+ connectionsTab,
32+ Sinks as ConnectionsTabSinks,
33+} from './connections-tab/index';
3134 import {topBar, Sinks as TBSinks} from './top-bar';
3235 import intent from './intent';
33-import model, {State, publicTabLens, syncTabLens, topBarLens} from './model';
36+import model, {
37+ State,
38+ publicTabLens,
39+ connectionsTabLens,
40+ topBarLens,
41+} from './model';
3442 import view from './view';
3543 import navigation from './navigation';
3644 import sampleCombine from 'xstream/extra/sampleCombine';
3745
@@ -80,28 +88,28 @@
8088 onion: publicTabLens,
8189 '*': 'publicTab',
8290 })({...sources, scrollToTop: scrollToTop$});
8391
84- const syncTabSinks: SyncTabSinks = isolate(syncTab, {
85- onion: syncTabLens,
86- '*': 'syncTab',
92+ const connectionsTabSinks: ConnectionsTabSinks = isolate(connectionsTab, {
93+ onion: connectionsTabLens,
94+ '*': 'connectionsTab',
8795 })(sources);
8896
8997 const command$ = navigation(
9098 {openDrawer$: topBarSinks.menuPress},
91- xs.merge(publicTabSinks.navigation, syncTabSinks.navigation),
99+ xs.merge(publicTabSinks.navigation, connectionsTabSinks.navigation),
92100 );
93101 const centralReducer$ = model(actions, sources.ssb);
94102 const reducer$ = xs.merge(
95103 centralReducer$,
96104 publicTabSinks.onion,
97- syncTabSinks.onion,
105+ connectionsTabSinks.onion,
98106 ) as Stream<Reducer<State>>;
99107 const vdom$ = view(
100108 sources.onion.state$,
101109 topBarSinks.screen,
102110 publicTabSinks.screen,
103- syncTabSinks.screen,
111+ connectionsTabSinks.screen,
104112 );
105113
106114 const toast$: Stream<Toast> = sources.ssb.acceptInviteResponse$.map(res => {
107115 if (res === true)
@@ -121,9 +129,9 @@
121129 return {
122130 screen: vdom$,
123131 onion: reducer$,
124132 navigation: command$,
125- alert: syncTabSinks.alert,
133+ alert: connectionsTabSinks.alert,
126134 ssb: publicTabSinks.ssb,
127135 toast: toast$,
128136 };
129137 }
src/app/screens/central/model.tsView
@@ -21,16 +21,16 @@
2121 import {Reducer, Lens} from 'cycle-onionify';
2222 import {FeedId} from 'ssb-typescript';
2323 import {State as PublicTabState} from './public-tab/model';
2424 import {State as TopBarState} from './top-bar';
25-import {State as SyncTabState} from './sync-tab/model';
25+import {State as ConnectionsTabState} from './connections-tab/model';
2626 import {SSBSource} from '../../drivers/ssb';
2727
2828 export type State = {
2929 selfFeedId: FeedId;
3030 currentTab: number;
3131 publicTab?: PublicTabState;
32- syncTab?: SyncTabState;
32+ connectionsTab?: ConnectionsTabState;
3333 numOfPublicUpdates: number;
3434 };
3535
3636 export function initState(selfFeedId: FeedId): State {
@@ -76,12 +76,12 @@
7676 };
7777 },
7878 };
7979
80-export const syncTabLens: Lens<State, SyncTabState> = {
81- get: (parent: State): SyncTabState => {
82- if (parent.syncTab) {
83- return {...parent.syncTab, selfFeedId: parent.selfFeedId};
80+export const connectionsTabLens: Lens<State, ConnectionsTabState> = {
81+ get: (parent: State): ConnectionsTabState => {
82+ if (parent.connectionsTab) {
83+ return {...parent.connectionsTab, selfFeedId: parent.selfFeedId};
8484 } else {
8585 return {
8686 selfFeedId: parent.selfFeedId,
8787 lanEnabled: false,
@@ -92,12 +92,12 @@
9292 };
9393 }
9494 },
9595
96- set: (parent: State, child: SyncTabState): State => {
96+ set: (parent: State, child: ConnectionsTabState): State => {
9797 return {
9898 ...parent,
99- syncTab: child,
99+ connectionsTab: child,
100100 };
101101 },
102102 };
103103
src/app/screens/central/view.tsView
@@ -34,12 +34,12 @@
3434 accessible: true,
3535 accessibilityLabel: 'Public Tab Button',
3636 },
3737
38- sync: {
38+ connections: {
3939 name: 'wan',
4040 accessible: true,
41- accessibilityLabel: 'Sync Tab Button',
41+ accessibilityLabel: 'Connections Tab Button',
4242 },
4343 };
4444
4545 function renderPublicIcon(numOfPublicUpdates: number) {
@@ -78,10 +78,13 @@
7878 selectedItemStyle: styles.tabItemSelected,
7979 tabs: [
8080 renderPublicIcon(state.numOfPublicUpdates),
8181 {
82- normal: h(Icon, {...iconProps.tab, ...iconData.sync}),
83- selected: h(Icon, {...iconProps.tabSelected, ...iconData.sync}),
82+ normal: h(Icon, {...iconProps.tab, ...iconData.connections}),
83+ selected: h(Icon, {
84+ ...iconProps.tabSelected,
85+ ...iconData.connections,
86+ }),
8487 },
8588 ],
8689 }),
8790 },
src/app/screens/central/connections-tab/README.mdView
@@ -1,0 +1,1 @@
1+This Cycle.js component represents the screen where the user can see current connections with other users, syncing data through various means, such as Wi-Fi LAN, internet, Bluetooth, etc.
src/app/screens/central/connections-tab/index.tsView
@@ -1,0 +1,67 @@
1+/**
2+ * MMMMM is a mobile app for Secure Scuttlebutt networks
3+ *
4+ * Copyright (C) 2017 Andre 'Staltz' Medeiros
5+ *
6+ * This program is free software: you can redistribute it and/or modify
7+ * it under the terms of the GNU General Public License as published by
8+ * the Free Software Foundation, either version 3 of the License, or
9+ * (at your option) any later version.
10+ *
11+ * This program is distributed in the hope that it will be useful,
12+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+ * GNU General Public License for more details.
15+ *
16+ * You should have received a copy of the GNU General Public License
17+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
18+ */
19+
20+import {Stream} from 'xstream';
21+import {ReactElement} from 'react';
22+import {StateSource, Reducer} from 'cycle-onionify';
23+import {Command as AlertCommand} from 'cycle-native-alert';
24+import {ReactSource} from '@cycle/react';
25+import {Command} from 'cycle-native-navigation';
26+import {WifiSource} from '../../../drivers/wifi';
27+import {SSBSource} from '../../../drivers/ssb';
28+import view from './view';
29+import intent from './intent';
30+import model, {State} from './model';
31+import navigation from './navigation';
32+
33+export type Sources = {
34+ screen: ReactSource;
35+ onion: StateSource<State>;
36+ ssb: SSBSource;
37+ wifi: WifiSource;
38+};
39+
40+export type Sinks = {
41+ screen: Stream<ReactElement<any>>;
42+ navigation: Stream<Command>;
43+ alert: Stream<AlertCommand>;
44+ onion: Stream<Reducer<State>>;
45+};
46+
47+export function connectionsTab(sources: Sources): Sinks {
48+ const actions = intent(sources.screen);
49+ const vdom$ = view(sources.onion.state$);
50+ const command$ = navigation(actions, sources.onion.state$);
51+ const reducer$ = model(sources.ssb, sources.wifi);
52+ const alert$ = actions.showLANHelp$.mapTo({
53+ title: 'Friends around you',
54+ message:
55+ 'This list shows friends (accounts you follow) which are currently ' +
56+ 'connected to you in the same Local Area Network, for instance the ' +
57+ 'same Wi-Fi, so they are probably "around you".',
58+ buttons: [{text: 'OK', id: 'okay'}],
59+ });
60+
61+ return {
62+ alert: alert$,
63+ navigation: command$,
64+ screen: vdom$,
65+ onion: reducer$,
66+ };
67+}
src/app/screens/central/connections-tab/intent.tsView
@@ -1,0 +1,38 @@
1+/**
2+ * MMMMM is a mobile app for Secure Scuttlebutt networks
3+ *
4+ * Copyright (C) 2017 Andre 'Staltz' Medeiros
5+ *
6+ * This program is free software: you can redistribute it and/or modify
7+ * it under the terms of the GNU General Public License as published by
8+ * the Free Software Foundation, either version 3 of the License, or
9+ * (at your option) any later version.
10+ *
11+ * This program is distributed in the hope that it will be useful,
12+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+ * GNU General Public License for more details.
15+ *
16+ * You should have received a copy of the GNU General Public License
17+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
18+ */
19+
20+import xs, {Stream} from 'xstream';
21+import {ReactSource} from '@cycle/react';
22+import {FeedId} from 'ssb-typescript';
23+
24+export default function intent(reactSource: ReactSource) {
25+ return {
26+ showLANHelp$: reactSource.select('lan-help').events('press').mapTo(null),
27+
28+ goToPeerProfile$: xs.merge(
29+ reactSource.select('lan-peers').events('pressPeer'),
30+ reactSource.select('pub-peers').events('pressPeer'),
31+ ) as Stream<FeedId>,
32+
33+ goToPasteInvite$: reactSource
34+ .select('invites')
35+ .events('pressPaste')
36+ .mapTo(null),
37+ };
38+}
src/app/screens/central/connections-tab/model.tsView
@@ -1,0 +1,75 @@
1+/**
2+ * MMMMM is a mobile app for Secure Scuttlebutt networks
3+ *
4+ * Copyright (C) 2017 Andre 'Staltz' Medeiros
5+ *
6+ * This program is free software: you can redistribute it and/or modify
7+ * it under the terms of the GNU General Public License as published by
8+ * the Free Software Foundation, either version 3 of the License, or
9+ * (at your option) any later version.
10+ *
11+ * This program is distributed in the hope that it will be useful,
12+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+ * GNU General Public License for more details.
15+ *
16+ * You should have received a copy of the GNU General Public License
17+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
18+ */
19+
20+import xs, {Stream} from 'xstream';
21+import {PeerMetadata, FeedId} from 'ssb-typescript';
22+import {Reducer} from 'cycle-onionify';
23+import {SSBSource} from '../../../drivers/ssb';
24+import {WifiSource} from '../../../drivers/wifi';
25+
26+export type State = {
27+ selfFeedId: FeedId;
28+ lanEnabled: boolean;
29+ peers: {
30+ lan: Array<PeerMetadata>;
31+ pub: Array<PeerMetadata>;
32+ };
33+};
34+
35+export default function model(
36+ ssbSource: SSBSource,
37+ wifiSource: WifiSource,
38+): Stream<Reducer<State>> {
39+ const initReducer$ = xs.of(function initReducer(): State {
40+ return {
41+ selfFeedId: '',
42+ lanEnabled: false,
43+ peers: {
44+ lan: [],
45+ pub: [],
46+ },
47+ };
48+ });
49+
50+ const updateLanEnabled$ = wifiSource.isEnabled().map(
51+ lanEnabled =>
52+ function updateLanEnabled(prev: State): State {
53+ return {
54+ selfFeedId: prev.selfFeedId,
55+ lanEnabled,
56+ peers: prev.peers,
57+ };
58+ },
59+ );
60+
61+ const setPeersReducer$ = ssbSource.peers$.map(
62+ peers =>
63+ function setPeersReducer(prev: State): State {
64+ const lan = peers.filter(peer => peer.source === 'local');
65+ const pub = peers.filter(peer => peer.source !== 'local');
66+ return {
67+ selfFeedId: prev.selfFeedId,
68+ lanEnabled: prev.lanEnabled,
69+ peers: {lan, pub},
70+ };
71+ },
72+ );
73+
74+ return xs.merge(initReducer$, setPeersReducer$, updateLanEnabled$);
75+}
src/app/screens/central/connections-tab/navigation.tsView
@@ -1,0 +1,71 @@
1+/**
2+ * MMMMM is a mobile app for Secure Scuttlebutt networks
3+ *
4+ * Copyright (C) 2017 Andre 'Staltz' Medeiros
5+ *
6+ * This program is free software: you can redistribute it and/or modify
7+ * it under the terms of the GNU General Public License as published by
8+ * the Free Software Foundation, either version 3 of the License, or
9+ * (at your option) any later version.
10+ *
11+ * This program is distributed in the hope that it will be useful,
12+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+ * GNU General Public License for more details.
15+ *
16+ * You should have received a copy of the GNU General Public License
17+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
18+ */
19+
20+import xs, {Stream} from 'xstream';
21+import sampleCombine from 'xstream/extra/sampleCombine';
22+import {FeedId} from 'ssb-typescript';
23+import {Command} from 'cycle-native-navigation';
24+import {Screens} from '../../..';
25+import {navOptions as profileScreenNavOptions} from '../../profile';
26+import {navOptions as pasteInviteScreenNavOptions} from '../../invite-paste';
27+import {State} from './model';
28+
29+export type Actions = {
30+ goToPeerProfile$: Stream<FeedId>;
31+ goToPasteInvite$: Stream<any>;
32+};
33+
34+export default function navigation(
35+ actions: Actions,
36+ state$: Stream<State>,
37+): Stream<Command> {
38+ const toProfile$ = actions.goToPeerProfile$
39+ .compose(sampleCombine(state$))
40+ .map(
41+ ([feedId, state]) =>
42+ ({
43+ type: 'push',
44+ layout: {
45+ component: {
46+ name: Screens.Profile,
47+ passProps: {
48+ selfFeedId: state.selfFeedId,
49+ feedId,
50+ },
51+ options: profileScreenNavOptions,
52+ },
53+ },
54+ } as Command),
55+ );
56+
57+ const toPasteInvite$ = actions.goToPasteInvite$.map(
58+ () =>
59+ ({
60+ type: 'showOverlay',
61+ layout: {
62+ component: {
63+ name: Screens.InvitePaste,
64+ options: pasteInviteScreenNavOptions,
65+ },
66+ },
67+ } as Command),
68+ );
69+
70+ return xs.merge(toProfile$, toPasteInvite$);
71+}
src/app/screens/central/connections-tab/styles.tsView
@@ -1,0 +1,37 @@
1+/**
2+ * MMMMM is a mobile app for Secure Scuttlebutt networks
3+ *
4+ * Copyright (C) 2017 Andre 'Staltz' Medeiros
5+ *
6+ * This program is free software: you can redistribute it and/or modify
7+ * it under the terms of the GNU General Public License as published by
8+ * the Free Software Foundation, either version 3 of the License, or
9+ * (at your option) any later version.
10+ *
11+ * This program is distributed in the hope that it will be useful,
12+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+ * GNU General Public License for more details.
15+ *
16+ * You should have received a copy of the GNU General Public License
17+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
18+ */
19+
20+import {StyleSheet} from 'react-native';
21+import {Dimensions as Dimens} from '../../../global-styles/dimens';
22+import {Palette} from '../../../global-styles/palette';
23+
24+export const styles = StyleSheet.create({
25+ container: {
26+ backgroundColor: Palette.brand.voidBackground,
27+ alignSelf: 'stretch',
28+ flex: 1,
29+ },
30+});
31+
32+export const iconProps = {
33+ info: {
34+ size: Dimens.iconSizeSmall,
35+ color: Palette.brand.darkTextWeak,
36+ },
37+};
src/app/screens/central/connections-tab/view.tsView
@@ -1,0 +1,69 @@
1+/**
2+ * MMMMM is a mobile app for Secure Scuttlebutt networks
3+ *
4+ * Copyright (C) 2017 Andre 'Staltz' Medeiros
5+ *
6+ * This program is free software: you can redistribute it and/or modify
7+ * it under the terms of the GNU General Public License as published by
8+ * the Free Software Foundation, either version 3 of the License, or
9+ * (at your option) any later version.
10+ *
11+ * This program is distributed in the hope that it will be useful,
12+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+ * GNU General Public License for more details.
15+ *
16+ * You should have received a copy of the GNU General Public License
17+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
18+ */
19+
20+import {Stream} from 'xstream';
21+import {h} from '@cycle/react';
22+import {ScrollView} from 'react-native';
23+import {styles} from './styles';
24+import {State} from './model';
25+import InviteHeader from '../../../components/InviteHeader';
26+import SyncChannelAccordion from '../../../components/SyncChannelAccordion';
27+
28+export default function view(state$: Stream<State>) {
29+ return state$.map(state =>
30+ h(ScrollView, {style: styles.container}, [
31+ h(InviteHeader, {sel: 'invites'}),
32+
33+ // h(SyncChannelAccordion, {
34+ // icon: 'bluetooth',
35+ // name: 'Bluetooth',
36+ // active: false,
37+ // info: 'Connect with people very near',
38+ // onPressActivate: () => {},
39+ // peers: state.peers.bluetooth,
40+ // }),
41+
42+ h(SyncChannelAccordion, {
43+ sel: 'lan-peers',
44+ icon: 'wifi',
45+ name: 'Local network',
46+ active: state.lanEnabled,
47+ info: 'Connect with people in the same space',
48+ peers: state.peers.lan,
49+ }),
50+
51+ // h(SyncChannelAccordion, {
52+ // icon: 'account-network',
53+ // name: 'Internet P2P',
54+ // active: false,
55+ // info: 'Connect with friends online now on the internet',
56+ // peers: state.peers.dht,
57+ // }),
58+
59+ h(SyncChannelAccordion, {
60+ sel: 'pub-peers',
61+ icon: 'server-network',
62+ name: 'Internet servers',
63+ active: true,
64+ info: 'Connect with community servers on the internet',
65+ peers: state.peers.pub,
66+ }),
67+ ]),
68+ );
69+}
src/app/screens/central/sync-tab/README.mdView
@@ -1,1 +1,0 @@
1-This Cycle.js component represents the screen where the user can perform syncing of data through various means, such as Wi-Fi LAN, internet, Bluetooth, etc.
src/app/screens/central/sync-tab/index.tsView
@@ -1,67 +1,0 @@
1-/**
2- * MMMMM is a mobile app for Secure Scuttlebutt networks
3- *
4- * Copyright (C) 2017 Andre 'Staltz' Medeiros
5- *
6- * This program is free software: you can redistribute it and/or modify
7- * it under the terms of the GNU General Public License as published by
8- * the Free Software Foundation, either version 3 of the License, or
9- * (at your option) any later version.
10- *
11- * This program is distributed in the hope that it will be useful,
12- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14- * GNU General Public License for more details.
15- *
16- * You should have received a copy of the GNU General Public License
17- * along with this program. If not, see <http://www.gnu.org/licenses/>.
18- */
19-
20-import {Stream} from 'xstream';
21-import {ReactElement} from 'react';
22-import {StateSource, Reducer} from 'cycle-onionify';
23-import {Command as AlertCommand} from 'cycle-native-alert';
24-import {ReactSource} from '@cycle/react';
25-import {Command} from 'cycle-native-navigation';
26-import {WifiSource} from '../../../drivers/wifi';
27-import {SSBSource} from '../../../drivers/ssb';
28-import view from './view';
29-import intent from './intent';
30-import model, {State} from './model';
31-import navigation from './navigation';
32-
33-export type Sources = {
34- screen: ReactSource;
35- onion: StateSource<State>;
36- ssb: SSBSource;
37- wifi: WifiSource;
38-};
39-
40-export type Sinks = {
41- screen: Stream<ReactElement<any>>;
42- navigation: Stream<Command>;
43- alert: Stream<AlertCommand>;
44- onion: Stream<Reducer<State>>;
45-};
46-
47-export function syncTab(sources: Sources): Sinks {
48- const actions = intent(sources.screen);
49- const vdom$ = view(sources.onion.state$);
50- const command$ = navigation(actions, sources.onion.state$);
51- const reducer$ = model(sources.ssb, sources.wifi);
52- const alert$ = actions.showLANHelp$.mapTo({
53- title: 'Friends around you',
54- message:
55- 'This list shows friends (accounts you follow) which are currently ' +
56- 'connected to you in the same Local Area Network, for instance the ' +
57- 'same Wi-Fi, so they are probably "around you".',
58- buttons: [{text: 'OK', id: 'okay'}],
59- });
60-
61- return {
62- alert: alert$,
63- navigation: command$,
64- screen: vdom$,
65- onion: reducer$,
66- };
67-}
src/app/screens/central/sync-tab/intent.tsView
@@ -1,38 +1,0 @@
1-/**
2- * MMMMM is a mobile app for Secure Scuttlebutt networks
3- *
4- * Copyright (C) 2017 Andre 'Staltz' Medeiros
5- *
6- * This program is free software: you can redistribute it and/or modify
7- * it under the terms of the GNU General Public License as published by
8- * the Free Software Foundation, either version 3 of the License, or
9- * (at your option) any later version.
10- *
11- * This program is distributed in the hope that it will be useful,
12- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14- * GNU General Public License for more details.
15- *
16- * You should have received a copy of the GNU General Public License
17- * along with this program. If not, see <http://www.gnu.org/licenses/>.
18- */
19-
20-import xs, {Stream} from 'xstream';
21-import {ReactSource} from '@cycle/react';
22-import {FeedId} from 'ssb-typescript';
23-
24-export default function intent(reactSource: ReactSource) {
25- return {
26- showLANHelp$: reactSource.select('lan-help').events('press').mapTo(null),
27-
28- goToPeerProfile$: xs.merge(
29- reactSource.select('lan-peers').events('pressPeer'),
30- reactSource.select('pub-peers').events('pressPeer'),
31- ) as Stream<FeedId>,
32-
33- goToPasteInvite$: reactSource
34- .select('invites')
35- .events('pressPaste')
36- .mapTo(null),
37- };
38-}
src/app/screens/central/sync-tab/model.tsView
@@ -1,75 +1,0 @@
1-/**
2- * MMMMM is a mobile app for Secure Scuttlebutt networks
3- *
4- * Copyright (C) 2017 Andre 'Staltz' Medeiros
5- *
6- * This program is free software: you can redistribute it and/or modify
7- * it under the terms of the GNU General Public License as published by
8- * the Free Software Foundation, either version 3 of the License, or
9- * (at your option) any later version.
10- *
11- * This program is distributed in the hope that it will be useful,
12- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14- * GNU General Public License for more details.
15- *
16- * You should have received a copy of the GNU General Public License
17- * along with this program. If not, see <http://www.gnu.org/licenses/>.
18- */
19-
20-import xs, {Stream} from 'xstream';
21-import {PeerMetadata, FeedId} from 'ssb-typescript';
22-import {Reducer} from 'cycle-onionify';
23-import {SSBSource} from '../../../drivers/ssb';
24-import {WifiSource} from '../../../drivers/wifi';
25-
26-export type State = {
27- selfFeedId: FeedId;
28- lanEnabled: boolean;
29- peers: {
30- lan: Array<PeerMetadata>;
31- pub: Array<PeerMetadata>;
32- };
33-};
34-
35-export default function model(
36- ssbSource: SSBSource,
37- wifiSource: WifiSource,
38-): Stream<Reducer<State>> {
39- const initReducer$ = xs.of(function initReducer(): State {
40- return {
41- selfFeedId: '',
42- lanEnabled: false,
43- peers: {
44- lan: [],
45- pub: [],
46- },
47- };
48- });
49-
50- const updateLanEnabled$ = wifiSource.isEnabled().map(
51- lanEnabled =>
52- function updateLanEnabled(prev: State): State {
53- return {
54- selfFeedId: prev.selfFeedId,
55- lanEnabled,
56- peers: prev.peers,
57- };
58- },
59- );
60-
61- const setPeersReducer$ = ssbSource.peers$.map(
62- peers =>
63- function setPeersReducer(prev: State): State {
64- const lan = peers.filter(peer => peer.source === 'local');
65- const pub = peers.filter(peer => peer.source !== 'local');
66- return {
67- selfFeedId: prev.selfFeedId,
68- lanEnabled: prev.lanEnabled,
69- peers: {lan, pub},
70- };
71- },
72- );
73-
74- return xs.merge(initReducer$, setPeersReducer$, updateLanEnabled$);
75-}
src/app/screens/central/sync-tab/navigation.tsView
@@ -1,71 +1,0 @@
1-/**
2- * MMMMM is a mobile app for Secure Scuttlebutt networks
3- *
4- * Copyright (C) 2017 Andre 'Staltz' Medeiros
5- *
6- * This program is free software: you can redistribute it and/or modify
7- * it under the terms of the GNU General Public License as published by
8- * the Free Software Foundation, either version 3 of the License, or
9- * (at your option) any later version.
10- *
11- * This program is distributed in the hope that it will be useful,
12- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14- * GNU General Public License for more details.
15- *
16- * You should have received a copy of the GNU General Public License
17- * along with this program. If not, see <http://www.gnu.org/licenses/>.
18- */
19-
20-import xs, {Stream} from 'xstream';
21-import sampleCombine from 'xstream/extra/sampleCombine';
22-import {FeedId} from 'ssb-typescript';
23-import {Command} from 'cycle-native-navigation';
24-import {Screens} from '../../..';
25-import {navOptions as profileScreenNavOptions} from '../../profile';
26-import {navOptions as pasteInviteScreenNavOptions} from '../../invite-paste';
27-import {State} from './model';
28-
29-export type Actions = {
30- goToPeerProfile$: Stream<FeedId>;
31- goToPasteInvite$: Stream<any>;
32-};
33-
34-export default function navigation(
35- actions: Actions,
36- state$: Stream<State>,
37-): Stream<Command> {
38- const toProfile$ = actions.goToPeerProfile$
39- .compose(sampleCombine(state$))
40- .map(
41- ([feedId, state]) =>
42- ({
43- type: 'push',
44- layout: {
45- component: {
46- name: Screens.Profile,
47- passProps: {
48- selfFeedId: state.selfFeedId,
49- feedId,
50- },
51- options: profileScreenNavOptions,
52- },
53- },
54- } as Command),
55- );
56-
57- const toPasteInvite$ = actions.goToPasteInvite$.map(
58- () =>
59- ({
60- type: 'showOverlay',
61- layout: {
62- component: {
63- name: Screens.InvitePaste,
64- options: pasteInviteScreenNavOptions,
65- },
66- },
67- } as Command),
68- );
69-
70- return xs.merge(toProfile$, toPasteInvite$);
71-}
src/app/screens/central/sync-tab/styles.tsView
@@ -1,37 +1,0 @@
1-/**
2- * MMMMM is a mobile app for Secure Scuttlebutt networks
3- *
4- * Copyright (C) 2017 Andre 'Staltz' Medeiros
5- *
6- * This program is free software: you can redistribute it and/or modify
7- * it under the terms of the GNU General Public License as published by
8- * the Free Software Foundation, either version 3 of the License, or
9- * (at your option) any later version.
10- *
11- * This program is distributed in the hope that it will be useful,
12- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14- * GNU General Public License for more details.
15- *
16- * You should have received a copy of the GNU General Public License
17- * along with this program. If not, see <http://www.gnu.org/licenses/>.
18- */
19-
20-import {StyleSheet} from 'react-native';
21-import {Dimensions as Dimens} from '../../../global-styles/dimens';
22-import {Palette} from '../../../global-styles/palette';
23-
24-export const styles = StyleSheet.create({
25- container: {
26- backgroundColor: Palette.brand.voidBackground,
27- alignSelf: 'stretch',
28- flex: 1,
29- },
30-});
31-
32-export const iconProps = {
33- info: {
34- size: Dimens.iconSizeSmall,
35- color: Palette.brand.darkTextWeak,
36- },
37-};
src/app/screens/central/sync-tab/view.tsView
@@ -1,69 +1,0 @@
1-/**
2- * MMMMM is a mobile app for Secure Scuttlebutt networks
3- *
4- * Copyright (C) 2017 Andre 'Staltz' Medeiros
5- *
6- * This program is free software: you can redistribute it and/or modify
7- * it under the terms of the GNU General Public License as published by
8- * the Free Software Foundation, either version 3 of the License, or
9- * (at your option) any later version.
10- *
11- * This program is distributed in the hope that it will be useful,
12- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14- * GNU General Public License for more details.
15- *
16- * You should have received a copy of the GNU General Public License
17- * along with this program. If not, see <http://www.gnu.org/licenses/>.
18- */
19-
20-import {Stream} from 'xstream';
21-import {h} from '@cycle/react';
22-import {ScrollView} from 'react-native';
23-import {styles} from './styles';
24-import {State} from './model';
25-import InviteHeader from '../../../components/InviteHeader';
26-import SyncChannelAccordion from '../../../components/SyncChannelAccordion';
27-
28-export default function view(state$: Stream<State>) {
29- return state$.map(state =>
30- h(ScrollView, {style: styles.container}, [
31- h(InviteHeader, {sel: 'invites'}),
32-
33- // h(SyncChannelAccordion, {
34- // icon: 'bluetooth',
35- // name: 'Bluetooth',
36- // active: false,
37- // info: 'Connect with people very near',
38- // onPressActivate: () => {},
39- // peers: state.peers.bluetooth,
40- // }),
41-
42- h(SyncChannelAccordion, {
43- sel: 'lan-peers',
44- icon: 'wifi',
45- name: 'Local network',
46- active: state.lanEnabled,
47- info: 'Connect with people in the same space',
48- peers: state.peers.lan,
49- }),
50-
51- // h(SyncChannelAccordion, {
52- // icon: 'account-network',
53- // name: 'Internet P2P',
54- // active: false,
55- // info: 'Connect with friends online now on the internet',
56- // peers: state.peers.dht,
57- // }),
58-
59- h(SyncChannelAccordion, {
60- sel: 'pub-peers',
61- icon: 'server-network',
62- name: 'Internet servers',
63- active: true,
64- info: 'Connect with community servers on the internet',
65- peers: state.peers.pub,
66- }),
67- ]),
68- );
69-}

Built with git-ssb-web