diff --git a/src/js/iris-lib/Channel.js b/src/js/iris-lib/Channel.js index 4bad9639..b0bad6fc 100644 --- a/src/js/iris-lib/Channel.js +++ b/src/js/iris-lib/Channel.js @@ -371,17 +371,15 @@ class Channel { participants: chatId.pub || chatId, save: false })); - } else { - if (chatId.uuid && chatId.participants && chatId.myGroupSecret) { - callback(new Channel({ - key: keypair, - gun, - participants: chatId.participants, - uuid: chatId.uuid, - myGroupSecret: chatId.myGroupSecret, - save: false - })); - } + } else if (chatId.uuid && chatId.participants && chatId.myGroupSecret) { + callback(new Channel({ + key: keypair, + gun, + participants: chatId.participants, + uuid: chatId.uuid, + myGroupSecret: chatId.myGroupSecret, + save: false + })); } } }); @@ -734,7 +732,7 @@ class Channel { if (typeof callback !== 'function') { throw new Error(`onTheir callback must be a function, got ${typeof callback}`); } - if (!this.directSubscriptions.hasOwnProperty(key)) { + if (!Object.prototype.hasOwnProperty.call(this.directSubscriptions, key)) { this.directSubscriptions[key] = []; } this.directSubscriptions[key].push({key, callback, from}); @@ -766,7 +764,7 @@ class Channel { if (typeof callback !== 'function') { throw new Error(`onTheir callback must be a function, got ${typeof callback}`); } - if (!this.groupSubscriptions.hasOwnProperty(key)) { + if (!Object.prototype.hasOwnProperty.call(this.groupSubscriptions, key)) { this.groupSubscriptions[key] = []; } const subscription = {key, callback, from}; @@ -846,9 +844,8 @@ class Channel { getSimpleLink(urlRoot = 'https://iris.to/') { if (this.uuid) { return `${urlRoot}?channelId=${this.uuid}&inviter=${this.key.pub}`; - } else { - return `${urlRoot}?chatWith=${this.getCurrentParticipants()[0]}`; } + return `${urlRoot}?chatWith=${this.getCurrentParticipants()[0]}`; } /** @@ -1122,9 +1119,8 @@ class Channel { const enc = encodeURIComponent; if (channelId && inviter) { return `${urlRoot}?channelId=${enc(channelId)}&inviter=${enc(inviter)}&s=${enc(sharedSecret)}&k=${enc(linkId)}`; - } else { - return `${urlRoot}?chatWith=${enc(chatWith)}&s=${enc(sharedSecret)}&k=${enc(linkId)}`; } + return `${urlRoot}?chatWith=${enc(chatWith)}&s=${enc(sharedSecret)}&k=${enc(linkId)}`; } /** diff --git a/src/js/iris-lib/Social.js b/src/js/iris-lib/Social.js deleted file mode 100644 index 02d44c78..00000000 --- a/src/js/iris-lib/Social.js +++ /dev/null @@ -1,23 +0,0 @@ -class Social { - groupGet(path, callback, groupNode = State.local.get('groups').get('follows')) { - const follows = {}; - groupNode.map((isFollowing, user) => { - if (follows[user] && follows[user] === isFollowing) { return; } - follows[user] = isFollowing; - if (isFollowing) { // TODO: callback on unfollow, for unsubscribe - const node = _.reduce(path.split('/'), (sum, s) => sum.get(decodeURIComponent(s)), State.public.user(user)); - callback(node, user); - } - }); - } - - groupMap(path, callback, groupNode = State.local.get('groups').get('follows')) { - groupGet(path, (node, from) => node.map((...args) => callback(...args, from)), groupNode); - } - - groupOn(path, callback, groupNode = State.local.get('groups').get('follows')) { - groupGet(path, (node, from) => node.on((...args) => callback(...args, from)), groupNode); - } -} - -export default Social; diff --git a/src/js/iris-lib/util.js b/src/js/iris-lib/util.js index 616ef41e..5b213418 100644 --- a/src/js/iris-lib/util.js +++ b/src/js/iris-lib/util.js @@ -79,13 +79,10 @@ async function loadGunDepth(chain, maxDepth = 2, opts = {}) { } export default { - loadGunDepth: loadGunDepth, - - gunOnceDefined: gunOnceDefined, - - gunAsAnotherUser: gunAsAnotherUser, - - getHash: async function(str, format = `base64`) { + loadGunDepth, + gunOnceDefined, + gunAsAnotherUser, + getHash: async (str, format = `base64`) => { if (!str) { return undefined; } diff --git a/src/js/views/Group.js b/src/js/views/Group.js index 5769962e..0b56e1e4 100644 --- a/src/js/views/Group.js +++ b/src/js/views/Group.js @@ -21,7 +21,7 @@ function deleteChat(pub) { delete Session.channels[pub]; State.local.get('channels').get(pub).put(null); route('/chat'); - }; + } } class Group extends View {