Skip to content

Commit

Permalink
Strip hall and Chat /mar, /lib
Browse files Browse the repository at this point in the history
  • Loading branch information
matildepark committed Oct 29, 2019
1 parent 5a8fc08 commit 0a43957
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 476 deletions.
7 changes: 1 addition & 6 deletions full/src/js/api.js
Expand Up @@ -8,8 +8,7 @@ class UrbitApi {
this.bindPaths = [];
}

// keep default bind to hall, since its bind procedure more complex for now AA
bind(path, method, ship = this.authTokens.ship, appl = "hall", success, fail) {
bind(path, method, ship = this.authTokens.ship, appl = "%APPNAME%", success, fail) {
this.bindPaths = _.uniq([...this.bindPaths, path]);

window.subscriptionId = window.urb.subscribe(ship, appl, path,
Expand All @@ -30,10 +29,6 @@ class UrbitApi {
});
}

hall(data) {
this.action("hall", "hall-action", data);
}

%APPNAME%(data) {
this.action("%APPNAME%", "json", data);
}
Expand Down
4 changes: 0 additions & 4 deletions full/src/js/reducers/config.js
Expand Up @@ -6,10 +6,6 @@ export class ConfigReducer {
let data = _.get(json, '%APPNAME%', false);
if (data) {
state.inbox = data.inbox;
state.configs = data.configs;
state.circles = data.circles;
state.peers = data.peers;
state.messages = state.messages || {};
}
}
}
4 changes: 0 additions & 4 deletions full/src/js/reducers/initial.js
Expand Up @@ -5,11 +5,7 @@ export class InitialReducer {
reduce(json, state) {
let data = _.get(json, 'initial', false);
if (data) {
state.messages = data.messages;
state.inbox = data.inbox;
state.configs = data.configs;
state.circles = data.circles;
state.peers = data.peers;
}
}
}
65 changes: 0 additions & 65 deletions full/src/js/reducers/update.js
Expand Up @@ -6,12 +6,6 @@ export class UpdateReducer {
let data = _.get(json, 'update', false);
if (data) {
this.reduceInbox(_.get(data, 'inbox', false), state);
this.reduceMessage(_.get(data, 'message', false), state);
this.reduceMessages(_.get(data, 'messages', false), state);
this.reduceConfig(_.get(data, 'config', false), state);
this.reduceCircles(_.get(data, 'circles', false), state);
this.reducePeers(_.get(data, 'peers', false), state);
this.reduceDelete(_.get(data, 'delete', false), state);
}
}

Expand All @@ -20,63 +14,4 @@ export class UpdateReducer {
state.inbox = inbox;
}
}

reduceMessage(message, state) {
if (message && message.circle in state.messages) {
state.messages[message.circle].push(message.envelope);
} else {
state.messages[message.circle] = [message.envelope];
}
}

reduceMessages(msgs, state) {
if (msgs) {

let staMsgs = state.messages[msgs.circle];
if (msgs.circle in state.messages) {
console.log('new messages object: ', msgs);
console.log('lowest num in store: ', staMsgs[0].num);
console.log('highest num in store: ', staMsgs[staMsgs.length - 1].num);

if (staMsgs.length > 0 && staMsgs[0].num - 1 === msgs.end) {
state.messages[msgs.circle] = msgs.envelopes.concat(staMsgs);
} else if (staMsgs.length === 0) {
state.messages[msgs.circle] = msgs.envelopes;
} else {
console.error('%messages has inconsistent indices');
}

} else {
state.messages[msgs.circle] = msgs.envelopes;
}
}

}

reduceConfig(config, state) {
if (config) {
state.configs[config.circle] = config.config;
}
}

reduceCircles(circles, state) {
if (circles) {
state.circles = circles.circles;
}
}

reducePeers(peers, state) {
if (peers) {
state.peers[peers.circle] = peers.peers;
}
}

reduceDelete(del, state) {
if (del) {
delete state.configs[del.circle];
delete state.messages[del.circle];
delete state.peers[del.circle];
}
}

}
7 changes: 1 addition & 6 deletions full/src/js/store.js
Expand Up @@ -6,12 +6,7 @@ import { UpdateReducer } from '/reducers/update';
class Store {
constructor() {
this.state = {
inbox: {},
messages: {},
configs: {},
circles: [],
peers: {},
spinner: false
inbox: {}
};

this.initialReducer = new InitialReducer();
Expand Down
72 changes: 27 additions & 45 deletions full/urbit/app/smol.hoon
@@ -1,5 +1,4 @@
/- hall
/+ *server, %APPNAME%, hall-json
/+ *server
/= index
/^ octs
/; as-octs:mimes:html
Expand Down Expand Up @@ -35,28 +34,40 @@
/^ (map knot @)
/: /===/app/%APPNAME%/img /_ /png/
::
=, %APPNAME%
=, format
|%
:: +move: output effect
::
|_ [bol=bowl:gall sta=state]
+$ move (pair bone card)
::
+$ poke
$% [%launch-action [@tas path @t]]
==
:: +card: output move payload
::
+$ card
$% [%poke wire dock poke]
[%http-response =http-event:http]
[%connect wire binding:eyre term]
[%diff %json json]
==
--
::
|_ [bol=bowl:gall ~]
::
++ this .
::
:: +prep: set up the app, migrate the state once started
:: +prep: set up the app
::
++ prep
|= old=(unit state)
|= old=(unit ~)
^- (quip move _this)
=/ launcha/poke
=/ launcha
[%launch-action [%%APPNAME% /%APPNAME%tile '/~%APPNAME%/js/tile.js']]
?~ old
:_ this
:~
:: %connect here tells %eyre to mount at the /~%APPNAME% endpoint.
[ost.bol %connect / [~ /'~%APPNAME%'] %%APPNAME%]
[ost.bol %poke /%APPNAME% [our.bol %launch] launcha]
==
:- [ost.bol %poke /%APPNAME% [our.bol %launch] launcha]~
this(sta u.old)
:_ this
:~ [ost.bol %connect / [~ /'~%APPNAME%'] %%APPNAME%]
[ost.bol %poke /%APPNAME% [our.bol %launch] launcha]
==
::
::
++ peer-%APPNAME%tile
Expand All @@ -73,35 +84,6 @@
^- (quip move _this)
[~ this]
::
:: +poke-%APPNAME%: send us an action
::
++ poke-%APPNAME%-action
|= act=action:%APPNAME%
^- (quip move _this)
[~ this]
::
:: +send-%APPNAME%-update: utility func for sending updates to all our subscribers
::
++ send-%APPNAME%-update
|= [upd=update str=streams]
^- (list move)
=/ updates/(list move)
%+ turn (prey:pubsub:userlib /primary bol)
|= [=bone *]
[bone %diff %%APPNAME%-update upd]
::
=/ tile-updates/(list move)
%+ turn (prey:pubsub:userlib /%APPNAME%tile bol)
|= [=bone *]
[bone %diff %json *json]
::
%+ weld
updates
tile-updates

::
:: +lient arms
::
::
:: +bound: lient tells us we successfully bound our server to the ~%APPNAME% url
::
Expand Down
140 changes: 0 additions & 140 deletions full/urbit/lib/smol.hoon

This file was deleted.

0 comments on commit 0a43957

Please sign in to comment.