lint fixes

This commit is contained in:
Martti Malmi 2022-06-17 10:08:58 +03:00
parent 6640f52777
commit 938775ad05
4 changed files with 18 additions and 48 deletions

View File

@ -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)}`;
}
/**

View File

@ -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;

View File

@ -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;
}

View File

@ -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 {