blob: c7be5cd82c1124237aecf4796e1eb08ae71be4f8 [file] [log] [blame]
Adrià Vilanova Martínez0d92a0c2023-11-06 01:37:20 +01001import OptionsWatcher from '../../../common/optionsWatcher.js';
2
Adrià Vilanova Martíneza3b97b92023-11-16 00:58:14 +01003import ProfileInfoHandler from './infoHandlers/profile.js';
4import ThreadInfoHandler from './infoHandlers/thread.js';
5import ThreadListInfoHandler from './infoHandlers/threadList.js';
Adrià Vilanova Martínez0d92a0c2023-11-06 01:37:20 +01006import ExpandedThreadListExtraInfoInjection from './injections/expandedThreadList.js';
7import ProfileAbuseExtraInfoInjection from './injections/profileAbuse.js';
8import ProfilePerForumStatsExtraInfoInjection from './injections/profilePerForumStats.js';
Adrià Vilanova Martínez80f1c732023-11-16 00:52:56 +01009import ThreadCommentExtraInfoInjection from './injections/threadComment.js';
Adrià Vilanova Martínez0d92a0c2023-11-06 01:37:20 +010010import ThreadListExtraInfoInjection from './injections/threadList.js';
Adrià Vilanova Martínez19f6a652023-11-15 19:38:50 +010011import ThreadQuestionExtraInfoInjection from './injections/threadQuestion.js';
Adrià Vilanova Martínez80f1c732023-11-16 00:52:56 +010012import ThreadReplyExtraInfoInjection from './injections/threadReply.js';
Adrià Vilanova Martínez0d92a0c2023-11-06 01:37:20 +010013
14export default class ExtraInfo {
15 constructor() {
Adrià Vilanova Martínez19f6a652023-11-15 19:38:50 +010016 const optionsWatcher = new OptionsWatcher(['extrainfo', 'perforumstats']);
Adrià Vilanova Martínez0d92a0c2023-11-06 01:37:20 +010017
18 const profileInfoHandler = new ProfileInfoHandler();
Adrià Vilanova Martínez19f6a652023-11-15 19:38:50 +010019 const threadInfoHandler = new ThreadInfoHandler();
Adrià Vilanova Martínez0d92a0c2023-11-06 01:37:20 +010020 const threadListInfoHandler = new ThreadListInfoHandler();
21
Adrià Vilanova Martínez19f6a652023-11-15 19:38:50 +010022 this.profileAbuse =
23 new ProfileAbuseExtraInfoInjection(profileInfoHandler, optionsWatcher);
Adrià Vilanova Martínez0d92a0c2023-11-06 01:37:20 +010024 this.profilePerForumStats = new ProfilePerForumStatsExtraInfoInjection(
Adrià Vilanova Martínez19f6a652023-11-15 19:38:50 +010025 profileInfoHandler, optionsWatcher);
26 this.threadQuestion =
27 new ThreadQuestionExtraInfoInjection(threadInfoHandler, optionsWatcher);
Adrià Vilanova Martínez80f1c732023-11-16 00:52:56 +010028 this.threadReply =
29 new ThreadReplyExtraInfoInjection(threadInfoHandler, optionsWatcher);
30 this.threadComment =
31 new ThreadCommentExtraInfoInjection(threadInfoHandler, optionsWatcher);
Adrià Vilanova Martínez0d92a0c2023-11-06 01:37:20 +010032 this.expandedThreadList = new ExpandedThreadListExtraInfoInjection(
Adrià Vilanova Martínez19f6a652023-11-15 19:38:50 +010033 threadListInfoHandler, optionsWatcher);
34 this.threadList =
35 new ThreadListExtraInfoInjection(threadListInfoHandler, optionsWatcher);
Adrià Vilanova Martínez0d92a0c2023-11-06 01:37:20 +010036 }
37
38 injectAbuseChipsAtProfileIfEnabled(card) {
39 this.profileAbuse.injectIfEnabled({card});
40 }
41
42 injectAtThreadListIfEnabled(li) {
43 const injectionDetails = this.threadList.getInjectionDetails(li);
44 this.threadList.injectIfEnabled(injectionDetails);
45 }
46
47 injectAtExpandedThreadListIfEnabled(toolbelt) {
48 const injectionDetails =
49 this.expandedThreadList.getInjectionDetails(toolbelt);
50 this.expandedThreadList.injectIfEnabled(injectionDetails);
51 }
52
53 injectPerForumStatsIfEnabled(chart) {
54 this.profilePerForumStats.injectIfEnabled({chart});
55 }
56
Adrià Vilanova Martínez0d92a0c2023-11-06 01:37:20 +010057 injectAtQuestionIfEnabled(stateChips) {
Adrià Vilanova Martínez19f6a652023-11-15 19:38:50 +010058 this.threadQuestion.injectIfEnabled({stateChips, isMessageNode: false});
Adrià Vilanova Martínez0d92a0c2023-11-06 01:37:20 +010059 }
60
Adrià Vilanova Martínez80f1c732023-11-16 00:52:56 +010061 injectAtReplyIfEnabled(messageNode) {
62 this.threadReply.injectIfEnabled({messageNode, isMessageNode: true});
63 }
64
65 injectAtCommentIfEnabled(messageNode) {
66 this.threadComment.injectIfEnabled({messageNode, isMessageNode: true});
Adrià Vilanova Martínez0d92a0c2023-11-06 01:37:20 +010067 }
68}