fix(extra-info): handle successive message loads and promoted messages

When loading a thread, some messages might be collapsed and are loaded
in subsequent requests. This CL handles this case by holding an array of
messages which grows each time the user expands a gap of messages.

Furthermore, this CL also considers promoted messages for the message
list (before this, the extra info chips were added to promoted messages
only if they were loaded outside of the promoted messages structure as
well).

Bug: twpowertools:93
Change-Id: I8b6f4e8f4a97c7f5e4cdde52b6b773b9631fbe57
diff --git a/src/contentScripts/communityConsole/extraInfo/injections/baseThreadMessage.js b/src/contentScripts/communityConsole/extraInfo/injections/baseThreadMessage.js
index d086f9d..d0cd162 100644
--- a/src/contentScripts/communityConsole/extraInfo/injections/baseThreadMessage.js
+++ b/src/contentScripts/communityConsole/extraInfo/injections/baseThreadMessage.js
@@ -25,16 +25,15 @@
 
   inject(threadInfo, injectionDetails) {
     const messageNode = injectionDetails.messageNode;
-    const message = this.#getMessage(threadInfo, messageNode);
+    const message = this.#getMessage(threadInfo.messages, messageNode);
     const [chips, tooltips] = MessageExtraInfoService.getMessageChips(message);
     this.#injectChips(chips, messageNode);
     for (const tooltip of tooltips) new MDCTooltip(tooltip);
   }
 
-  #getMessage(threadInfo, messageNode) {
-    const thread = new ThreadModel(threadInfo.body?.[1]);
+  #getMessage(messagesList, messageNode) {
     const messageId = MessageExtraInfoService.getMessageIdFromNode(messageNode);
-    return MessageExtraInfoService.getMessageFromThreadModel(messageId, thread);
+    return MessageExtraInfoService.getMessageFromList(messageId, messagesList);
   }
 
   #injectChips(chips, messageNode) {
diff --git a/src/contentScripts/communityConsole/extraInfo/injections/threadQuestion.js b/src/contentScripts/communityConsole/extraInfo/injections/threadQuestion.js
index 1efe6db..d797ee1 100644
--- a/src/contentScripts/communityConsole/extraInfo/injections/threadQuestion.js
+++ b/src/contentScripts/communityConsole/extraInfo/injections/threadQuestion.js
@@ -9,7 +9,7 @@
     BaseExtraInfoInjection {
   inject(threadInfo, injectionDetails) {
     const [chips, tooltips] =
-        ThreadExtraInfoService.getThreadChips(threadInfo.body?.['1']);
+        ThreadExtraInfoService.getThreadChips(threadInfo.thread.data);
     this.#injectChips(chips, injectionDetails.stateChips);
     for (const tooltip of tooltips) new MDCTooltip(tooltip);
   }