From 9e051a2dd6a9b4b7d3f161eb75d1e0cad4e77210 Mon Sep 17 00:00:00 2001 From: Isaac Visintainer Date: Tue, 11 Jun 2019 15:58:48 -0700 Subject: [PATCH] cleaned up api.js --- apps/publish/src/js/api.js | 149 +------------------------------------ 1 file changed, 4 insertions(+), 145 deletions(-) diff --git a/apps/publish/src/js/api.js b/apps/publish/src/js/api.js index d5264b4e1..c9043f564 100644 --- a/apps/publish/src/js/api.js +++ b/apps/publish/src/js/api.js @@ -9,9 +9,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) { - console.log('binding to ...', appl, ", path: ", path, ", as ship: ", ship, ", by method: ", method); + bind(path, method, ship = this.authTokens.ship, appl = "write", success, fail) { this.bindPaths = _.uniq([...this.bindPaths, path]); window.urb.subscribe(ship, appl, path, @@ -29,19 +27,8 @@ class UrbitApi { }, (err) => { fail(err); - }); - } - - hall(data) { - this.action("hall", "hall-action", data); - } - - coll(data) { - this.action("collections", "collections-action", data); - } - - setOnboardingBit(value) { - this.action("collections", "json", { onboard: value }); + } + ); } action(appl, mark, data) { @@ -49,140 +36,12 @@ class UrbitApi { window.urb.poke(ship, appl, mark, data, (json) => { resolve(json); - }, + }, (err) => { reject(err); }); }); } - - /* - Special actions - */ - - permit(cir, aud, message) { - this.hall({ - permit: { - nom: cir, - sis: aud, - inv: true - } - }); - - if (message) { - this.invite(cir, aud); - } - } - - permitCol(cir, aud, message, nom) { - this.hall({ - permit: { - nom: cir, - sis: aud, - inv: true - } - }); - - if (message) { - this.inviteCol(cir, aud, nom); - } - } - - invite(cir, aud) { - let audInboxes = aud.map((aud) => `~${aud}/i`); - let inviteMessage = { - aud: audInboxes, - ses: [{ - inv: { - inv: true, - cir: `~${window.ship}/${cir}` - } - }] - }; - - this.hall({ - phrase: inviteMessage - }); - } - - inviteCol(cir, aud, nom) { - let audInboxes = aud.map((aud) => `~${aud}/i`); - let inviteMessage = { - aud: audInboxes, - ses: [{ - app: { - app: nom, - sep: { - inv: { - inv: true, - cir: `~${window.ship}/${cir}` - } - } - } - }] - }; - - this.hall({ - phrase: inviteMessage - }); - } - - message(aud, words) { - let msg = { - aud, - ses: [{ - lin: { - msg: words, - pat: false - } - }] - }; - - this.hall({ - phrase: msg - }); - } - - source(nom, sub) { - this.hall({ - source: { - nom: "inbox", - sub: sub, - srs: [nom] - } - }) - } - - create(nom, priv) { - this.hall({ - create: { - nom: nom, - des: "chatroom", - sec: priv ? "village" : "channel" - } - }); - } - - ire(aud, uid, msg) { - let message = { - aud: aud, - ses: [{ - ire: { - top: uid, - sep: { - lin: { - msg: msg, - pat: false - } - } - } - }] - } - - this.hall({ - phrase: message - }) - } } export let api = new UrbitApi();