blob: d797ee1621e0e2fb10b57add1fc581c6ecddacf6 [file] [log] [blame]
Adrià Vilanova Martínez19f6a652023-11-15 19:38:50 +01001import {MDCTooltip} from '@material/tooltip';
2
3import ThreadModel from '../../../../models/Thread.js';
4import ThreadExtraInfoService from '../services/thread.js';
5
6import BaseExtraInfoInjection from './base.js';
7
8export default class ThreadQuestionExtraInfoInjection extends
9 BaseExtraInfoInjection {
10 inject(threadInfo, injectionDetails) {
11 const [chips, tooltips] =
Adrià Vilanova Martínez4b2582d2023-11-16 01:56:04 +010012 ThreadExtraInfoService.getThreadChips(threadInfo.thread.data);
Adrià Vilanova Martínez19f6a652023-11-15 19:38:50 +010013 this.#injectChips(chips, injectionDetails.stateChips);
14 for (const tooltip of tooltips) new MDCTooltip(tooltip);
15 }
16
17 #injectChips(chips, stateChipsElement) {
18 const stateChipsContainer = stateChipsElement.querySelector(
19 '.scTailwindThreadQuestionStatechipsroot');
20 const container = stateChipsContainer ?? stateChipsElement;
21 const shouldCreateContainer = stateChipsContainer === null;
22 this.addExtraInfoChips(chips, container, shouldCreateContainer);
23 }
24}