From 144163ced72709b2c5d64c4f9639bd0385875964 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Thu, 10 Jan 2019 10:25:47 +0100 Subject: [PATCH] MOBILE-2795 messages: Fix videos refreshed when VideoJS is on --- src/addon/messages/pages/discussion/discussion.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/addon/messages/pages/discussion/discussion.ts b/src/addon/messages/pages/discussion/discussion.ts index 7ac5d20b7..b3151026e 100644 --- a/src/addon/messages/pages/discussion/discussion.ts +++ b/src/addon/messages/pages/discussion/discussion.ts @@ -132,8 +132,11 @@ export class AddonMessagesDiscussionPage implements OnDestroy { * @param {boolean} [keep=true] If set the keep flag or not. */ protected addMessage(message: any, keep: boolean = true): void { - // Use text instead of message ID because ID changes when a message is read. - message.hash = Md5.hashAsciiStr(message.text || '') + '#' + message.timecreated + '#' + message.useridfrom; + /* Create a hash to identify the message. The text of online messages isn't reliable because it can have random data + like VideoJS ID. Try to use id and fallback to text for offline messages. */ + message.hash = Md5.hashAsciiStr(String(message.id || message.text || '')) + '#' + message.timecreated + '#' + + message.useridfrom; + if (typeof this.keepMessageMap[message.hash] === 'undefined') { // Message not added to the list. Add it now. this.messages.push(message);