diff --git a/js/modules/loki_public_chat_api.js b/js/modules/loki_public_chat_api.js index 7894b6c8d..804ea74b4 100644 --- a/js/modules/loki_public_chat_api.js +++ b/js/modules/loki_public_chat_api.js @@ -395,6 +395,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, @@ -432,15 +443,21 @@ class LokiPublicChannelAPI { this.deleteLastId = res.response.meta.max_id; ({ more } = res.response); } - - // set up next poll - this.timers.delete = setTimeout(() => { - this.pollForDeletions(); - }, PUBLICCHAT_DELETION_POLL_EVERY); } // get channel messages async pollForMessages() { + try { + await this.pollOnceForMessages(); + } catch (e) { + log.warn(`Error while polling for public chat messages: ${e}`); + } + setTimeout(() => { + this.pollForMessages(); + }, GROUPCHAT_POLL_EVERY); + } + + async pollOnceForMessages() { const params = { include_annotations: 1, count: -20, @@ -466,7 +483,10 @@ class LokiPublicChannelAPI { if (adnMessage.is_deleted) { return; } - if (adnMessage.annotations && adnMessage.annotations.length) { + if ( + Array.isArray(adnMessage.annotations) && + adnMessage.annotations.length !== 0 + ) { const noteValue = adnMessage.annotations[0].value; ({ timestamp } = noteValue); @@ -533,10 +553,6 @@ class LokiPublicChannelAPI { }); this.conversation.setLastRetrievedMessage(this.lastGot); } - - this.timers.message = setTimeout(() => { - this.pollForMessages(); - }, PUBLICCHAT_MSG_POLL_EVERY); } // create a message in the channel diff --git a/ts/components/conversation/MessageDetail.tsx b/ts/components/conversation/MessageDetail.tsx index 1a18a780a..deca2a6b4 100644 --- a/ts/components/conversation/MessageDetail.tsx +++ b/ts/components/conversation/MessageDetail.tsx @@ -56,18 +56,16 @@ export class MessageDetail extends React.Component { public renderDeleteButton() { const { i18n, message } = this.props; - return ( - message.isDeletable ? ( -
- -
- ) : null - ); + return message.isDeletable ? ( +
+ +
+ ) : null; } public renderContact(contact: Contact) {