Merge branch 'MDL-67700-master' of git://github.com/ferranrecio/moodle
authorAndrew Nicols <andrew@nicols.co.uk>
Fri, 22 May 2020 02:51:31 +0000 (10:51 +0800)
committerAndrew Nicols <andrew@nicols.co.uk>
Fri, 22 May 2020 02:51:31 +0000 (10:51 +0800)
message/amd/build/message_drawer_view_conversation.min.js
message/amd/build/message_drawer_view_conversation.min.js.map
message/amd/src/message_drawer_view_conversation.js

index 29fbeeb..53c1f62 100644 (file)
Binary files a/message/amd/build/message_drawer_view_conversation.min.js and b/message/amd/build/message_drawer_view_conversation.min.js differ
index b1c6bcc..dac3fc9 100644 (file)
Binary files a/message/amd/build/message_drawer_view_conversation.min.js.map and b/message/amd/build/message_drawer_view_conversation.min.js.map differ
index 7b911ce..03854ff 100644 (file)
@@ -506,6 +506,18 @@ function(
                 newestFirst,
                 timeFrom
             )
+            .then(function(result) {
+                // Prevent older requests from contaminating the current view.
+                if (result.id != viewState.id) {
+                    result.messages = [];
+                    // Purge old conversation cache to prevent messages lose.
+                    if (result.id in stateCache) {
+                        delete stateCache[result.id];
+                    }
+                }
+
+                return result;
+            })
             .then(function(result) {
                 if (result.messages.length && ignoreList.length) {
                     result.messages = result.messages.filter(function(message) {
@@ -1865,6 +1877,9 @@ function(
     var resetState = function(body, conversationId, loggedInUserProfile) {
         // Reset all of the states back to the beginning if we're loading a new
         // conversation.
+        if (newMessagesPollTimer) {
+            newMessagesPollTimer.stop();
+        }
         loadedAllMessages = false;
         messagesOffset = 0;
         newMessagesPollTimer = null;
@@ -1893,10 +1908,6 @@ function(
             viewState = initialState;
         }
 
-        if (newMessagesPollTimer) {
-            newMessagesPollTimer.stop();
-        }
-
         render(initialState);
     };