diff --git a/pkg/interface/src/App.js b/pkg/interface/src/App.js index 2f24b5b269..f0c08ebb33 100644 --- a/pkg/interface/src/App.js +++ b/pkg/interface/src/App.js @@ -35,17 +35,6 @@ const Root = styled.div` min-height: 100vh; `; -const Home = () => ( -
- Home - Chat - Dojo - Groups - Links - Publish -
-); - const StatusBarWithRouter = withRouter(StatusBar); export default class App extends React.Component { @@ -110,7 +99,7 @@ export default class App extends React.Component { selectedGroups={selectedGroups} {...p} /> )} /> - ( + ( { - fail(err); - }, - (event) => { - success({ - data: event, - from: { - ship, - path - } - }); - }, - (qui) => { - quit(qui); - }); - } - - action(appl, mark, data) { - return new Promise((resolve, reject) => { - this.channel.poke(window.ship, appl, mark, data, - (json) => { - resolve(json); - }, - (err) => { - reject(err); - }); - }); - } - +class PrivateHelper extends BaseApi { contactViewAction(data) { return this.action('contact-view', 'json', data); } @@ -150,7 +120,6 @@ export default class Api { } metadataAction(data) { - console.log(data); return this.action('metadata-hook', 'metadata-action', data); } @@ -184,3 +153,4 @@ export default class Api { }); } } + diff --git a/pkg/interface/src/apps/chat/app.js b/pkg/interface/src/apps/chat/app.js index 8b1d96db02..a4d9c2713f 100644 --- a/pkg/interface/src/apps/chat/app.js +++ b/pkg/interface/src/apps/chat/app.js @@ -5,6 +5,7 @@ import ChatApi from '../../api/chat'; import ChatStore from '../../store/chat'; import ChatSubscription from '../../subscription/chat'; + import './css/custom.css'; import { Skeleton } from './components/skeleton'; @@ -20,8 +21,6 @@ export default class ChatApp extends React.Component { constructor(props) { super(props); this.store = new ChatStore(); - this.store.setStateHandler(this.setState.bind(this)); - this.state = this.store.state; this.totalUnreads = 0; this.resetControllers(); @@ -37,7 +36,7 @@ export default class ChatApp extends React.Component { // preload spinner asset new Image().src = '/~landscape/img/Spinner.png'; - this.store.clear(); + this.store.setStateHandler(this.setState.bind(this)); const channel = new this.props.channel(); this.api = new ChatApi(this.props.ship, channel, this.store); @@ -48,6 +47,7 @@ export default class ChatApp extends React.Component { componentWillUnmount() { this.subscription.delete(); this.store.clear(); + this.store.setStateHandler(() => {}); this.resetControllers(); } diff --git a/pkg/interface/src/apps/groups/app.js b/pkg/interface/src/apps/groups/app.js index 1a1e5f7070..781b10277f 100644 --- a/pkg/interface/src/apps/groups/app.js +++ b/pkg/interface/src/apps/groups/app.js @@ -1,8 +1,8 @@ import React, { Component } from 'react'; import { Route } from 'react-router-dom'; -import Api from './api'; -import Subscription from './subscription'; +import GroupsApi from '../../api/groups'; +import GroupsSubscription from '../../subscription/groups'; import GroupsStore from '../../store/groups'; import './css/custom.css'; @@ -18,24 +18,27 @@ export default class GroupsApp extends Component { constructor(props) { super(props); this.store = new GroupsStore(); - this.store.setStateHandler(this.setState.bind(this)); - this.state = this.store.state; this.resetControllers(); } componentDidMount() { - this.store.clear(); - const channel = new this.props.channel(); - this.api = new Api(this.props.ship, channel, this.store); + window.title = 'OS1 - Groups'; + // preload spinner asset + new Image().src = '/~landscape/img/Spinner.png'; - this.subscription = new Subscription(this.store, this.api, channel); + this.store.setStateHandler(this.setState.bind(this)); + const channel = new this.props.channel(); + this.api = new GroupsApi(this.props.ship, channel, this.store); + + this.subscription = new GroupsSubscription(this.store, this.api, channel); this.subscription.start(); } componentWillUnmount() { this.subscription.delete(); this.store.clear(); + this.store.setStateHandler(() => {}); this.resetControllers(); } diff --git a/pkg/interface/src/apps/groups/components/lib/contact-card.js b/pkg/interface/src/apps/groups/components/lib/contact-card.js index adc3e49cee..937090ee2c 100644 --- a/pkg/interface/src/apps/groups/components/lib/contact-card.js +++ b/pkg/interface/src/apps/groups/components/lib/contact-card.js @@ -141,7 +141,6 @@ export class ContactCard extends Component { type: 'Saving to group' }, () => { - console.log(state.avatarToSet); props.api .contactEdit(props.path, ship, { avatar: { diff --git a/pkg/interface/src/apps/groups/components/lib/group-sidebar.js b/pkg/interface/src/apps/groups/components/lib/group-sidebar.js index 08e011f11d..200fa11598 100644 --- a/pkg/interface/src/apps/groups/components/lib/group-sidebar.js +++ b/pkg/interface/src/apps/groups/components/lib/group-sidebar.js @@ -6,7 +6,6 @@ import { Sigil } from '../../../../lib/sigil'; import { SidebarInvite } from './sidebar-invite'; import { Welcome } from './welcome'; -import api from '../../api'; import { cite } from '../../../../lib/util'; export class GroupSidebar extends Component { @@ -48,7 +47,7 @@ export class GroupSidebar extends Component { return (
{ - this.store.handleEvent({ - data: { clear : true } - }); - this.start(); - }); - } - - subscribe(path, app) { - this.api.bind(path, 'PUT', this.api.ship, app, - this.handleEvent.bind(this), - (err) => { - console.log(err); - this.subscribe(path, app); - }, - () => { - this.subscribe(path, app); - }); - } - - firstRound() { - this.subscribe('/primary', 'contact-view'); - } - - secondRound() { - this.subscribe('/all', 'group-store'); - this.subscribe('/all', 'metadata-store'); - } - - thirdRound() { - this.subscribe('/synced', 'contact-hook'); - this.subscribe('/primary', 'invite-view'); - this.subscribe('/all', 's3-store'); - } - - handleEvent(diff) { - if (!this.firstRoundComplete) { - this.firstRoundComplete = true; - this.secondRound(); - } else if (!this.secondRoundComplete) { - this.secondRoundComplete = true; - this.thirdRound(); - } - this.store.handleEvent(diff); - } -} - diff --git a/pkg/interface/src/apps/launch/app.js b/pkg/interface/src/apps/launch/app.js index 91b31dc355..f330ab826a 100644 --- a/pkg/interface/src/apps/launch/app.js +++ b/pkg/interface/src/apps/launch/app.js @@ -14,8 +14,6 @@ export default class LaunchApp extends React.Component { constructor(props) { super(props); this.store = new LaunchStore(); - this.store.setStateHandler(this.setState.bind(this)); - this.state = this.store.state; this.resetControllers(); } @@ -28,9 +26,9 @@ export default class LaunchApp extends React.Component { componentDidMount() { window.title = 'OS1 - Home'; // preload spinner asset - new Image().src = '/~chat/img/Spinner.png'; + new Image().src = '/~landscape/img/Spinner.png'; - this.store.clear(); + this.store.setStateHandler(this.setState.bind(this)); const channel = new this.props.channel(); this.api = new LaunchApi(this.props.ship, channel, this.store); @@ -42,6 +40,7 @@ export default class LaunchApp extends React.Component { componentWillUnmount() { this.subscription.delete(); this.store.clear(); + this.store.setStateHandler(() => {}); this.resetControllers(); } diff --git a/pkg/interface/src/apps/launch/components/tiles.js b/pkg/interface/src/apps/launch/components/tiles.js index 22fdcc8aa1..69bd752494 100644 --- a/pkg/interface/src/apps/launch/components/tiles.js +++ b/pkg/interface/src/apps/launch/components/tiles.js @@ -10,8 +10,7 @@ import WeatherTile from './tiles/weather'; export default class Tiles extends React.PureComponent { render() { const { props } = this; - console.log('render'); - + let tiles = props.tileOrdering.filter((key) => { return props.tiles[key].isShown; }).map((key) => { diff --git a/pkg/interface/src/apps/launch/components/tiles/clock.js b/pkg/interface/src/apps/launch/components/tiles/clock.js index f7597bbb04..5c6927ea07 100644 --- a/pkg/interface/src/apps/launch/components/tiles/clock.js +++ b/pkg/interface/src/apps/launch/components/tiles/clock.js @@ -131,7 +131,6 @@ class Clock extends React.Component { initGeolocation() { if (typeof this.props.data === 'string') { - // console.log(typeof this.props.data) const latlon = this.props.data.split(',') const lat = latlon[0] const lon = latlon[1] diff --git a/pkg/interface/src/apps/links/app.js b/pkg/interface/src/apps/links/app.js index d2c2b76ad7..15d3a9f08c 100644 --- a/pkg/interface/src/apps/links/app.js +++ b/pkg/interface/src/apps/links/app.js @@ -23,14 +23,18 @@ export class LinksApp extends Component { constructor(props) { super(props); this.store = new LinksStore(); - this.store.setStateHandler(this.setState.bind(this)); - this.state = this.store.state; this.totalUnseen = 0; this.resetControllers(); } componentDidMount() { + window.title = 'OS1 - Groups'; + // preload spinner asset + new Image().src = '/~landscape/img/Spinner.png'; + + this.store.setStateHandler(this.setState.bind(this)); + const channel = new this.props.channel(); this.api = new LinksApi(this.props.ship, channel, this.store); @@ -41,6 +45,7 @@ export class LinksApp extends Component { componentWillUnmount() { this.subscription.delete(); this.store.clear(); + this.store.setStateHandler(() => {}); this.resetControllers(); } diff --git a/pkg/interface/src/apps/publish/app.js b/pkg/interface/src/apps/publish/app.js index c6d4fdf0bb..ae720f8bc2 100644 --- a/pkg/interface/src/apps/publish/app.js +++ b/pkg/interface/src/apps/publish/app.js @@ -20,8 +20,6 @@ export default class PublishApp extends React.Component { constructor(props) { super(props); this.store = new PublishStore(); - this.store.setStateHandler(this.setState.bind(this)); - this.state = this.store.state; this.unreadTotal = 0; this.resetControllers(); @@ -33,9 +31,12 @@ export default class PublishApp extends React.Component { } componentDidMount() { - window.title = 'OS1 - Publish'; + window.title = 'OS1 - Groups'; + // preload spinner asset + new Image().src = '/~landscape/img/Spinner.png'; + + this.store.setStateHandler(this.setState.bind(this)); - this.store.clear(); const channel = new this.props.channel(); this.api = new PublishApi(this.props.ship, channel, this.store); @@ -47,6 +48,7 @@ export default class PublishApp extends React.Component { componentWillUnmount() { this.subscription.delete(); this.store.clear(); + this.store.setStateHandler(() => {}); this.resetControllers(); } diff --git a/pkg/interface/src/components/GroupFilter.js b/pkg/interface/src/components/GroupFilter.js index 599a355d9c..24efc740a4 100644 --- a/pkg/interface/src/components/GroupFilter.js +++ b/pkg/interface/src/components/GroupFilter.js @@ -55,7 +55,6 @@ export default class GroupFilter extends Component { groupIndex() { const { props } = this; let index = []; - console.log(props); const associations = (props.associations && 'contacts' in props.associations) ? props.associations.contacts : {}; diff --git a/pkg/interface/src/lib/util.js b/pkg/interface/src/lib/util.js index dd582d99a5..ac98eb21e6 100644 --- a/pkg/interface/src/lib/util.js +++ b/pkg/interface/src/lib/util.js @@ -75,7 +75,7 @@ function hexToDec(hex) { return hex.reverse().reduce((acc, digit, idx) => { const dec = alphabet.findIndex(a => a === digit.toUpperCase()); if(dec < 0) { - console.log(hex); + console.error(hex); throw new Error('Incorrect hex formatting'); } return acc + dec * (16 ** idx); diff --git a/pkg/interface/src/reducers/launch-update.js b/pkg/interface/src/reducers/launch-update.js index b711cc98a1..0a7955134e 100644 --- a/pkg/interface/src/reducers/launch-update.js +++ b/pkg/interface/src/reducers/launch-update.js @@ -4,7 +4,6 @@ export default class LaunchReducer { reduce(json, state) { const data = _.get(json, 'launch-update', false); if (data) { - this.log(data, state); this.initial(data, state); this.changeFirstTime(data, state); this.changeOrder(data, state); @@ -13,10 +12,6 @@ export default class LaunchReducer { } } - log(json, state) { - console.log(json); - } - initial(json, state) { const data = _.get(json, 'initial', false); if (data) { diff --git a/pkg/interface/src/reducers/metadata-update.js b/pkg/interface/src/reducers/metadata-update.js index 9ae8ea6cda..a6bd20ce87 100644 --- a/pkg/interface/src/reducers/metadata-update.js +++ b/pkg/interface/src/reducers/metadata-update.js @@ -4,7 +4,6 @@ export default class MetadataReducer { reduce(json, state) { let data = _.get(json, 'metadata-update', false); if (data) { - this.log(data, state); this.associations(data, state); this.add(data, state); this.update(data, state); @@ -12,10 +11,6 @@ export default class MetadataReducer { } } - log(json, state) { - console.log(json); - } - associations(json, state) { let data = _.get(json, 'associations', false); if (data) { diff --git a/pkg/interface/src/subscription/base.js b/pkg/interface/src/subscription/base.js index 9f83ae53cd..d710425e25 100644 --- a/pkg/interface/src/subscription/base.js +++ b/pkg/interface/src/subscription/base.js @@ -12,7 +12,6 @@ export default class BaseSubscription { onChannelError(err) { console.error('event source error: ', err); - console.log('initiating new channel'); setTimeout(2000, () => { this.store.clear(); this.start(); diff --git a/pkg/interface/src/subscription/chat.js b/pkg/interface/src/subscription/chat.js index 6d7a93a40f..97e0241168 100644 --- a/pkg/interface/src/subscription/chat.js +++ b/pkg/interface/src/subscription/chat.js @@ -15,7 +15,6 @@ export default class ChatSubscription extends BaseSubscription { fetchMessages(start, end, path) { - console.log(start, end, path); fetch(`/chat-view/paginate/${start}/${end}${path}`) .then(response => response.json()) .then((json) => { diff --git a/pkg/interface/src/subscription/groups.js b/pkg/interface/src/subscription/groups.js new file mode 100644 index 0000000000..f104c4eb7c --- /dev/null +++ b/pkg/interface/src/subscription/groups.js @@ -0,0 +1,14 @@ +import BaseSubscription from './base'; + +export default class GroupsSubscription extends BaseSubscription { + start() { + this.subscribe('/primary', 'contact-view'); + this.subscribe('/all', 'group-store'); + this.subscribe('/all', 'metadata-store'); + this.subscribe('/synced', 'contact-hook'); + this.subscribe('/primary', 'invite-view'); + this.subscribe('/all', 's3-store'); + } +} + +