Fix: ignore unrelated ViewForum requests (threadListAvatars)

Commit 31a6616 is wrong, since the maxNum property is included in the
request body, not the response body. This followup commit fixes this and
accomplishes what the previous commit was supposed to do.

Bug: twpowertools:24
Change-Id: I808f3b01379d8c404f956ac14a3693dcf2520f7e
diff --git a/src/contentScripts/communityConsole/utils/AvatarsDB.js b/src/contentScripts/communityConsole/utils/AvatarsDB.js
index f1b09e9..311ffff 100644
--- a/src/contentScripts/communityConsole/utils/AvatarsDB.js
+++ b/src/contentScripts/communityConsole/utils/AvatarsDB.js
@@ -1,6 +1,7 @@
 import {openDB} from 'idb';
 
 const dbName = 'TWPTAvatarsDB';
+const threadListRequestEvent = 'TWPT_ViewForumRequest';
 const threadListLoadEvent = 'TWPT_ViewForumResponse';
 const createMessageLoadEvent = 'TWPT_CreateMessageRequest';
 // Time after the last use when a cache entry should be deleted (in s):
@@ -75,7 +76,9 @@
   }
 
   setUpInvalidationsHandlers() {
-    window.addEventListener(threadListLoadEvent, e => {
+    let ignoredRequests = [];
+
+    window.addEventListener(threadListRequestEvent, e => {
       // Ignore ViewForum requests made by the chat feature and the "Mark as
       // duplicate" dialog.
       //
@@ -84,7 +87,13 @@
       // thread list (which currently requests 100 threads) and the ones to load
       // more threads (which request 50 threads).
       var maxNum = e.detail.body?.['2']?.['1']?.['2'];
-      if (maxNum == 10 || maxNum == 20) return;
+      if (maxNum == 10 || maxNum == 20) ignoredRequests.push(e.$TWPTID);
+    });
+    window.addEventListener(threadListLoadEvent, e => {
+      if (ignoredRequests.includes(e.$TWPTID)) {
+        ignoredRequests = ignoredRequests.filter(item => item != e.$TWPTID);
+        return;
+      }
 
       this.handleInvalidationsByListLoad(e);
     });