diff --git a/js/modules/loki_public_chat_api.js b/js/modules/loki_public_chat_api.js index 7ea7bdce3..d5b3269ce 100644 --- a/js/modules/loki_public_chat_api.js +++ b/js/modules/loki_public_chat_api.js @@ -365,6 +365,17 @@ class LokiPublicChannelAPI { // get moderation actions async pollForDeletions() { + try { + await this.pollOnceForDeletions(); + } catch (e) { + log.warn(`Error while polling for public chat deletions: ${e}`); + } + setTimeout(() => { + this.pollForDeletions(); + }, DELETION_POLL_EVERY); + } + + async pollOnceForDeletions() { // grab the last 200 deletions const params = { count: 200, @@ -402,22 +413,18 @@ class LokiPublicChannelAPI { this.deleteLastId = res.response.meta.max_id; ({ more } = res.response); } - - // set up next poll - setTimeout(() => { - this.pollForDeletions(); - }, DELETION_POLL_EVERY); } // get channel messages async pollForMessages() { try { await this.pollOnceForMessages(); - } finally { - setTimeout(() => { - this.pollForMessages(); - }, GROUPCHAT_POLL_EVERY); + } catch (e) { + log.warn(`Error while polling for public chat messages: ${e}`); } + setTimeout(() => { + this.pollForMessages(); + }, GROUPCHAT_POLL_EVERY); } async pollOnceForMessages() {