blob: 1d2b0245c45d48c584e85b614c657f5c0a0d68f1 [file] [log] [blame]
Adrià Vilanova Martínez0d92a0c2023-11-06 01:37:20 +01001import OptionsWatcher from '../../../common/optionsWatcher.js';
2
Adrià Vilanova Martínez0d92a0c2023-11-06 01:37:20 +01003import ProfileInfoHandler from './handlers/profile.js';
Adrià Vilanova Martínez19f6a652023-11-15 19:38:50 +01004import ThreadInfoHandler from './handlers/thread.js';
Adrià Vilanova Martínez0d92a0c2023-11-06 01:37:20 +01005import ThreadListInfoHandler from './handlers/threadList.js';
6import ExpandedThreadListExtraInfoInjection from './injections/expandedThreadList.js';
7import ProfileAbuseExtraInfoInjection from './injections/profileAbuse.js';
8import ProfilePerForumStatsExtraInfoInjection from './injections/profilePerForumStats.js';
9import ThreadListExtraInfoInjection from './injections/threadList.js';
Adrià Vilanova Martínez19f6a652023-11-15 19:38:50 +010010import ThreadMessageExtraInfoInjection from './injections/threadMessage.js';
11import ThreadQuestionExtraInfoInjection from './injections/threadQuestion.js';
Adrià Vilanova Martínez0d92a0c2023-11-06 01:37:20 +010012
13export default class ExtraInfo {
14 constructor() {
Adrià Vilanova Martínez19f6a652023-11-15 19:38:50 +010015 const optionsWatcher = new OptionsWatcher(['extrainfo', 'perforumstats']);
Adrià Vilanova Martínez0d92a0c2023-11-06 01:37:20 +010016
17 const profileInfoHandler = new ProfileInfoHandler();
Adrià Vilanova Martínez19f6a652023-11-15 19:38:50 +010018 const threadInfoHandler = new ThreadInfoHandler();
Adrià Vilanova Martínez0d92a0c2023-11-06 01:37:20 +010019 const threadListInfoHandler = new ThreadListInfoHandler();
20
Adrià Vilanova Martínez19f6a652023-11-15 19:38:50 +010021 this.profileAbuse =
22 new ProfileAbuseExtraInfoInjection(profileInfoHandler, optionsWatcher);
Adrià Vilanova Martínez0d92a0c2023-11-06 01:37:20 +010023 this.profilePerForumStats = new ProfilePerForumStatsExtraInfoInjection(
Adrià Vilanova Martínez19f6a652023-11-15 19:38:50 +010024 profileInfoHandler, optionsWatcher);
25 this.threadQuestion =
26 new ThreadQuestionExtraInfoInjection(threadInfoHandler, optionsWatcher);
27 this.threadMessage =
28 new ThreadMessageExtraInfoInjection(threadInfoHandler, optionsWatcher);
Adrià Vilanova Martínez0d92a0c2023-11-06 01:37:20 +010029 this.expandedThreadList = new ExpandedThreadListExtraInfoInjection(
Adrià Vilanova Martínez19f6a652023-11-15 19:38:50 +010030 threadListInfoHandler, optionsWatcher);
31 this.threadList =
32 new ThreadListExtraInfoInjection(threadListInfoHandler, optionsWatcher);
Adrià Vilanova Martínez0d92a0c2023-11-06 01:37:20 +010033 }
34
35 injectAbuseChipsAtProfileIfEnabled(card) {
36 this.profileAbuse.injectIfEnabled({card});
37 }
38
39 injectAtThreadListIfEnabled(li) {
40 const injectionDetails = this.threadList.getInjectionDetails(li);
41 this.threadList.injectIfEnabled(injectionDetails);
42 }
43
44 injectAtExpandedThreadListIfEnabled(toolbelt) {
45 const injectionDetails =
46 this.expandedThreadList.getInjectionDetails(toolbelt);
47 this.expandedThreadList.injectIfEnabled(injectionDetails);
48 }
49
50 injectPerForumStatsIfEnabled(chart) {
51 this.profilePerForumStats.injectIfEnabled({chart});
52 }
53
Adrià Vilanova Martínez0d92a0c2023-11-06 01:37:20 +010054 injectAtQuestionIfEnabled(stateChips) {
Adrià Vilanova Martínez19f6a652023-11-15 19:38:50 +010055 this.threadQuestion.injectIfEnabled({stateChips, isMessageNode: false});
Adrià Vilanova Martínez0d92a0c2023-11-06 01:37:20 +010056 }
57
Adrià Vilanova Martínez19f6a652023-11-15 19:38:50 +010058 injectAtMessageIfEnabled(messageNode) {
59 this.threadMessage.injectIfEnabled({messageNode, isMessageNode: true});
Adrià Vilanova Martínez0d92a0c2023-11-06 01:37:20 +010060 }
61}