mirror of
https://github.com/oxen-io/session-desktop.git
synced 2023-12-14 02:12:57 +01:00
Merge pull request #479 from neuroscr/use-user-obj
Make sure public chat timers can't be restarted / Channel name bug fix
This commit is contained in:
commit
6e6428928c
|
@ -2152,6 +2152,15 @@
|
|||
});
|
||||
}
|
||||
},
|
||||
async setGroupName(name) {
|
||||
const profileName = this.get('name');
|
||||
if (profileName !== name) {
|
||||
this.set({ name });
|
||||
await window.Signal.Data.updateConversation(this.id, this.attributes, {
|
||||
Conversation: Whisper.Conversation,
|
||||
});
|
||||
}
|
||||
},
|
||||
async setGroupNameAndAvatar(name, avatarPath) {
|
||||
const currentName = this.get('name');
|
||||
const profileAvatar = this.get('profileAvatar');
|
||||
|
|
|
@ -212,6 +212,7 @@ class LokiPublicChannelAPI {
|
|||
this.modStatus = false;
|
||||
this.deleteLastId = 1;
|
||||
this.timers = {};
|
||||
this.stop = false;
|
||||
// end properties
|
||||
|
||||
log.info(`registered LokiPublicChannel ${channelId}`);
|
||||
|
@ -223,6 +224,7 @@ class LokiPublicChannelAPI {
|
|||
}
|
||||
|
||||
stop() {
|
||||
this.stop = true;
|
||||
if (this.timers.channel) {
|
||||
clearTimeout(this.timers.channel);
|
||||
}
|
||||
|
@ -387,9 +389,11 @@ class LokiPublicChannelAPI {
|
|||
} catch (e) {
|
||||
log.warn(`Error while polling for public chat deletions: ${e}`);
|
||||
}
|
||||
this.timers.channel = setTimeout(() => {
|
||||
this.pollForChannelOnce();
|
||||
}, PUBLICCHAT_CHAN_POLL_EVERY);
|
||||
if (!this.stop) {
|
||||
this.timers.channel = setTimeout(() => {
|
||||
this.pollForChannelOnce();
|
||||
}, PUBLICCHAT_CHAN_POLL_EVERY);
|
||||
}
|
||||
}
|
||||
|
||||
// update room details
|
||||
|
@ -408,10 +412,8 @@ class LokiPublicChannelAPI {
|
|||
res.response.data.annotations.forEach(note => {
|
||||
if (note.type === 'net.patter-app.settings') {
|
||||
// note.value.description only needed for directory
|
||||
// this.conversation.setGroupNameAndAvatar(note.value.name,
|
||||
// note.value.avatar);
|
||||
if (note.value && note.value.name) {
|
||||
this.conversation.setProfileName(note.value.name);
|
||||
this.conversation.setGroupName(note.value.name);
|
||||
}
|
||||
if (note.value && note.value.avatar) {
|
||||
this.conversation.setProfileAvatar(note.value.avatar);
|
||||
|
@ -429,9 +431,11 @@ class LokiPublicChannelAPI {
|
|||
} catch (e) {
|
||||
log.warn(`Error while polling for public chat deletions: ${e}`);
|
||||
}
|
||||
this.timers.delete = setTimeout(() => {
|
||||
this.pollForDeletions();
|
||||
}, PUBLICCHAT_DELETION_POLL_EVERY);
|
||||
if (!this.stop) {
|
||||
this.timers.delete = setTimeout(() => {
|
||||
this.pollForDeletions();
|
||||
}, PUBLICCHAT_DELETION_POLL_EVERY);
|
||||
}
|
||||
}
|
||||
|
||||
async pollOnceForDeletions() {
|
||||
|
@ -481,9 +485,11 @@ class LokiPublicChannelAPI {
|
|||
} catch (e) {
|
||||
log.warn(`Error while polling for public chat messages: ${e}`);
|
||||
}
|
||||
setTimeout(() => {
|
||||
this.timers.message = this.pollForMessages();
|
||||
}, PUBLICCHAT_MSG_POLL_EVERY);
|
||||
if (!this.stop) {
|
||||
setTimeout(() => {
|
||||
this.timers.message = this.pollForMessages();
|
||||
}, PUBLICCHAT_MSG_POLL_EVERY);
|
||||
}
|
||||
}
|
||||
|
||||
async pollOnceForMessages() {
|
||||
|
|
Loading…
Reference in a new issue