fix(extra-info): show extra info in the RCE thread page

The extra info feature worked with the old thread pages. This CL brings
support to the new RCE thread pages.

Bug: twpowertools:93
Change-Id: I47e4235afa4f7ec441f5a92edfcc28b1cb5f0419
diff --git a/src/contentScripts/communityConsole/extraInfo/injections/threadMessage.js b/src/contentScripts/communityConsole/extraInfo/injections/threadMessage.js
new file mode 100644
index 0000000..e203e9e
--- /dev/null
+++ b/src/contentScripts/communityConsole/extraInfo/injections/threadMessage.js
@@ -0,0 +1,40 @@
+import {MDCTooltip} from '@material/tooltip';
+
+import ThreadModel from '../../../../models/Thread.js';
+import MessageExtraInfoService from '../services/message.js';
+
+import BaseExtraInfoInjection from './base.js';
+
+export default class ThreadMessageExtraInfoInjection extends
+    BaseExtraInfoInjection {
+  inject(threadInfo, injectionDetails) {
+    const messageNode = injectionDetails.messageNode;
+    const message = this.#getMessage(threadInfo, 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]);
+    const messageId = MessageExtraInfoService.getMessageIdFromNode(messageNode);
+    return MessageExtraInfoService.getMessageFromThreadModel(messageId, thread);
+  }
+
+  #injectChips(chips, messageNode) {
+    const interactionsElement = messageNode.querySelector(
+        '.scTailwindThreadMessageMessageinteractionsroot');
+    if (interactionsElement === null)
+      throw new Error(`Couldn't find interactions element.`);
+
+    this.#indicateInteractionsElementIsNonEmpty(interactionsElement);
+
+    this.addExtraInfoChips(
+        chips, interactionsElement, /* withContainer = */ true);
+  }
+
+  #indicateInteractionsElementIsNonEmpty(interactionsElement) {
+    interactionsElement.classList.add(
+        'scTailwindThreadMessageMessageinteractionsinteractions');
+  }
+}
diff --git a/src/contentScripts/communityConsole/extraInfo/injections/threadQuestion.js b/src/contentScripts/communityConsole/extraInfo/injections/threadQuestion.js
new file mode 100644
index 0000000..1efe6db
--- /dev/null
+++ b/src/contentScripts/communityConsole/extraInfo/injections/threadQuestion.js
@@ -0,0 +1,24 @@
+import {MDCTooltip} from '@material/tooltip';
+
+import ThreadModel from '../../../../models/Thread.js';
+import ThreadExtraInfoService from '../services/thread.js';
+
+import BaseExtraInfoInjection from './base.js';
+
+export default class ThreadQuestionExtraInfoInjection extends
+    BaseExtraInfoInjection {
+  inject(threadInfo, injectionDetails) {
+    const [chips, tooltips] =
+        ThreadExtraInfoService.getThreadChips(threadInfo.body?.['1']);
+    this.#injectChips(chips, injectionDetails.stateChips);
+    for (const tooltip of tooltips) new MDCTooltip(tooltip);
+  }
+
+  #injectChips(chips, stateChipsElement) {
+    const stateChipsContainer = stateChipsElement.querySelector(
+        '.scTailwindThreadQuestionStatechipsroot');
+    const container = stateChipsContainer ?? stateChipsElement;
+    const shouldCreateContainer = stateChipsContainer === null;
+    this.addExtraInfoChips(chips, container, shouldCreateContainer);
+  }
+}