Stop polling when you leave the public chat, clear up a bit

pull/480/head
Beaudan Brown 6 years ago
parent 4836b74f60
commit d2dcd6c23d

@ -1378,7 +1378,7 @@
options.messageType = message.get('type'); options.messageType = message.get('type');
options.isPublic = this.isPublic(); options.isPublic = this.isPublic();
if (options.isPublic) { if (options.isPublic) {
options.publicSendData = await this.getPublicSendData(); options.publicSendData = this.getPublicSendData();
} }
const groupNumbers = this.getRecipients(); const groupNumbers = this.getRecipients();
@ -2070,7 +2070,7 @@
conversationId: this.get('id'), conversationId: this.get('id'),
}; };
}, },
async getPublicSendData() { getPublicSendData() {
const serverAPI = lokiPublicChatAPI.findOrCreateServer( const serverAPI = lokiPublicChatAPI.findOrCreateServer(
this.get('server') this.get('server')
); );
@ -2312,27 +2312,24 @@
}, },
deleteContact() { deleteContact() {
if (this.isPublic()) { const message = this.isPublic()
Whisper.events.trigger('showConfirmationDialog', { ? i18n('deletePublicChannelConfirmation')
message: i18n('deletePublicChannelConfirmation'), : i18n('deleteContactConfirmation');
onOk: () => ConversationController.deleteContact(this.id),
});
} else {
Whisper.events.trigger('showConfirmationDialog', { Whisper.events.trigger('showConfirmationDialog', {
message: i18n('deleteContactConfirmation'), message,
onOk: () => ConversationController.deleteContact(this.id), onOk: () => {
}); ConversationController.deleteContact(this.id);
if (this.isPublic()) {
const channelAPI = this.getPublicSendData();
channelAPI.stop();
} }
}, },
});
},
async deletePublicMessage(message) { async deletePublicMessage(message) {
const serverAPI = lokiPublicChatAPI.findOrCreateServer( const channelAPI = this.getPublicSendData();
this.get('server')
);
const channelAPI = serverAPI.findOrCreateChannel(
this.get('channelId'),
this.id
);
const success = await channelAPI.deleteMessage(message.getServerId()); const success = await channelAPI.deleteMessage(message.getServerId());
if (success) { if (success) {
this.removeMessage(message.id); this.removeMessage(message.id);

Loading…
Cancel
Save