Adrià Vilanova Martínez | 0d92a0c | 2023-11-06 01:37:20 +0100 | [diff] [blame] | 1 | import OptionsWatcher from '../../../common/optionsWatcher.js'; |
| 2 | |
Adrià Vilanova Martínez | a3b97b9 | 2023-11-16 00:58:14 +0100 | [diff] [blame] | 3 | import ProfileInfoHandler from './infoHandlers/profile.js'; |
| 4 | import ThreadInfoHandler from './infoHandlers/thread.js'; |
| 5 | import ThreadListInfoHandler from './infoHandlers/threadList.js'; |
Adrià Vilanova Martínez | 0d92a0c | 2023-11-06 01:37:20 +0100 | [diff] [blame] | 6 | import ExpandedThreadListExtraInfoInjection from './injections/expandedThreadList.js'; |
| 7 | import ProfileAbuseExtraInfoInjection from './injections/profileAbuse.js'; |
| 8 | import ProfilePerForumStatsExtraInfoInjection from './injections/profilePerForumStats.js'; |
Adrià Vilanova Martínez | 80f1c73 | 2023-11-16 00:52:56 +0100 | [diff] [blame] | 9 | import ThreadCommentExtraInfoInjection from './injections/threadComment.js'; |
Adrià Vilanova Martínez | 0d92a0c | 2023-11-06 01:37:20 +0100 | [diff] [blame] | 10 | import ThreadListExtraInfoInjection from './injections/threadList.js'; |
Adrià Vilanova Martínez | 19f6a65 | 2023-11-15 19:38:50 +0100 | [diff] [blame] | 11 | import ThreadQuestionExtraInfoInjection from './injections/threadQuestion.js'; |
Adrià Vilanova Martínez | 80f1c73 | 2023-11-16 00:52:56 +0100 | [diff] [blame] | 12 | import ThreadReplyExtraInfoInjection from './injections/threadReply.js'; |
Adrià Vilanova Martínez | 0d92a0c | 2023-11-06 01:37:20 +0100 | [diff] [blame] | 13 | |
| 14 | export default class ExtraInfo { |
| 15 | constructor() { |
Adrià Vilanova Martínez | 19f6a65 | 2023-11-15 19:38:50 +0100 | [diff] [blame] | 16 | const optionsWatcher = new OptionsWatcher(['extrainfo', 'perforumstats']); |
Adrià Vilanova Martínez | 0d92a0c | 2023-11-06 01:37:20 +0100 | [diff] [blame] | 17 | |
| 18 | const profileInfoHandler = new ProfileInfoHandler(); |
Adrià Vilanova Martínez | 19f6a65 | 2023-11-15 19:38:50 +0100 | [diff] [blame] | 19 | const threadInfoHandler = new ThreadInfoHandler(); |
Adrià Vilanova Martínez | 0d92a0c | 2023-11-06 01:37:20 +0100 | [diff] [blame] | 20 | const threadListInfoHandler = new ThreadListInfoHandler(); |
| 21 | |
Adrià Vilanova Martínez | 19f6a65 | 2023-11-15 19:38:50 +0100 | [diff] [blame] | 22 | this.profileAbuse = |
| 23 | new ProfileAbuseExtraInfoInjection(profileInfoHandler, optionsWatcher); |
Adrià Vilanova Martínez | 0d92a0c | 2023-11-06 01:37:20 +0100 | [diff] [blame] | 24 | this.profilePerForumStats = new ProfilePerForumStatsExtraInfoInjection( |
Adrià Vilanova Martínez | 19f6a65 | 2023-11-15 19:38:50 +0100 | [diff] [blame] | 25 | profileInfoHandler, optionsWatcher); |
| 26 | this.threadQuestion = |
| 27 | new ThreadQuestionExtraInfoInjection(threadInfoHandler, optionsWatcher); |
Adrià Vilanova Martínez | 80f1c73 | 2023-11-16 00:52:56 +0100 | [diff] [blame] | 28 | this.threadReply = |
| 29 | new ThreadReplyExtraInfoInjection(threadInfoHandler, optionsWatcher); |
| 30 | this.threadComment = |
| 31 | new ThreadCommentExtraInfoInjection(threadInfoHandler, optionsWatcher); |
Adrià Vilanova Martínez | 0d92a0c | 2023-11-06 01:37:20 +0100 | [diff] [blame] | 32 | this.expandedThreadList = new ExpandedThreadListExtraInfoInjection( |
Adrià Vilanova Martínez | 19f6a65 | 2023-11-15 19:38:50 +0100 | [diff] [blame] | 33 | threadListInfoHandler, optionsWatcher); |
| 34 | this.threadList = |
| 35 | new ThreadListExtraInfoInjection(threadListInfoHandler, optionsWatcher); |
Adrià Vilanova Martínez | 0d92a0c | 2023-11-06 01:37:20 +0100 | [diff] [blame] | 36 | } |
| 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ínez | 0d92a0c | 2023-11-06 01:37:20 +0100 | [diff] [blame] | 57 | injectAtQuestionIfEnabled(stateChips) { |
Adrià Vilanova Martínez | 19f6a65 | 2023-11-15 19:38:50 +0100 | [diff] [blame] | 58 | this.threadQuestion.injectIfEnabled({stateChips, isMessageNode: false}); |
Adrià Vilanova Martínez | 0d92a0c | 2023-11-06 01:37:20 +0100 | [diff] [blame] | 59 | } |
| 60 | |
Adrià Vilanova Martínez | 80f1c73 | 2023-11-16 00:52:56 +0100 | [diff] [blame] | 61 | injectAtReplyIfEnabled(messageNode) { |
| 62 | this.threadReply.injectIfEnabled({messageNode, isMessageNode: true}); |
| 63 | } |
| 64 | |
| 65 | injectAtCommentIfEnabled(messageNode) { |
| 66 | this.threadComment.injectIfEnabled({messageNode, isMessageNode: true}); |
Adrià Vilanova Martínez | 0d92a0c | 2023-11-06 01:37:20 +0100 | [diff] [blame] | 67 | } |
| 68 | } |