Merge branch 'use-user-obj' of https://github.com/neuroscr/loki-messenger into use-user-obj

pull/475/head
Ryan Tharp 6 years ago
commit 2ca23db141

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

@ -56,18 +56,16 @@ export class MessageDetail extends React.Component<Props> {
public renderDeleteButton() {
const { i18n, message } = this.props;
return (
message.isDeletable ? (
<div className="module-message-detail__delete-button-container">
<button
onClick={message.onDelete}
className="module-message-detail__delete-button"
>
{i18n('deleteThisMessage')}
</button>
</div>
) : null
);
return message.isDeletable ? (
<div className="module-message-detail__delete-button-container">
<button
onClick={message.onDelete}
className="module-message-detail__delete-button"
>
{i18n('deleteThisMessage')}
</button>
</div>
) : null;
}
public renderContact(contact: Contact) {

Loading…
Cancel
Save