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 | 0d92a0c | 2023-11-06 01:37:20 +0100 | [diff] [blame] | 3 | import ProfileInfoHandler from './handlers/profile.js'; |
Adrià Vilanova Martínez | 19f6a65 | 2023-11-15 19:38:50 +0100 | [diff] [blame] | 4 | import ThreadInfoHandler from './handlers/thread.js'; |
Adrià Vilanova Martínez | 0d92a0c | 2023-11-06 01:37:20 +0100 | [diff] [blame] | 5 | import ThreadListInfoHandler from './handlers/threadList.js'; |
| 6 | import ExpandedThreadListExtraInfoInjection from './injections/expandedThreadList.js'; |
| 7 | import ProfileAbuseExtraInfoInjection from './injections/profileAbuse.js'; |
| 8 | import ProfilePerForumStatsExtraInfoInjection from './injections/profilePerForumStats.js'; |
| 9 | import ThreadListExtraInfoInjection from './injections/threadList.js'; |
Adrià Vilanova Martínez | 19f6a65 | 2023-11-15 19:38:50 +0100 | [diff] [blame] | 10 | import ThreadMessageExtraInfoInjection from './injections/threadMessage.js'; |
| 11 | import ThreadQuestionExtraInfoInjection from './injections/threadQuestion.js'; |
Adrià Vilanova Martínez | 0d92a0c | 2023-11-06 01:37:20 +0100 | [diff] [blame] | 12 | |
| 13 | export default class ExtraInfo { |
| 14 | constructor() { |
Adrià Vilanova Martínez | 19f6a65 | 2023-11-15 19:38:50 +0100 | [diff] [blame] | 15 | const optionsWatcher = new OptionsWatcher(['extrainfo', 'perforumstats']); |
Adrià Vilanova Martínez | 0d92a0c | 2023-11-06 01:37:20 +0100 | [diff] [blame] | 16 | |
| 17 | const profileInfoHandler = new ProfileInfoHandler(); |
Adrià Vilanova Martínez | 19f6a65 | 2023-11-15 19:38:50 +0100 | [diff] [blame] | 18 | const threadInfoHandler = new ThreadInfoHandler(); |
Adrià Vilanova Martínez | 0d92a0c | 2023-11-06 01:37:20 +0100 | [diff] [blame] | 19 | const threadListInfoHandler = new ThreadListInfoHandler(); |
| 20 | |
Adrià Vilanova Martínez | 19f6a65 | 2023-11-15 19:38:50 +0100 | [diff] [blame] | 21 | this.profileAbuse = |
| 22 | new ProfileAbuseExtraInfoInjection(profileInfoHandler, optionsWatcher); |
Adrià Vilanova Martínez | 0d92a0c | 2023-11-06 01:37:20 +0100 | [diff] [blame] | 23 | this.profilePerForumStats = new ProfilePerForumStatsExtraInfoInjection( |
Adrià Vilanova Martínez | 19f6a65 | 2023-11-15 19:38:50 +0100 | [diff] [blame] | 24 | profileInfoHandler, optionsWatcher); |
| 25 | this.threadQuestion = |
| 26 | new ThreadQuestionExtraInfoInjection(threadInfoHandler, optionsWatcher); |
| 27 | this.threadMessage = |
| 28 | new ThreadMessageExtraInfoInjection(threadInfoHandler, optionsWatcher); |
Adrià Vilanova Martínez | 0d92a0c | 2023-11-06 01:37:20 +0100 | [diff] [blame] | 29 | this.expandedThreadList = new ExpandedThreadListExtraInfoInjection( |
Adrià Vilanova Martínez | 19f6a65 | 2023-11-15 19:38:50 +0100 | [diff] [blame] | 30 | threadListInfoHandler, optionsWatcher); |
| 31 | this.threadList = |
| 32 | new ThreadListExtraInfoInjection(threadListInfoHandler, optionsWatcher); |
Adrià Vilanova Martínez | 0d92a0c | 2023-11-06 01:37:20 +0100 | [diff] [blame] | 33 | } |
| 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ínez | 0d92a0c | 2023-11-06 01:37:20 +0100 | [diff] [blame] | 54 | injectAtQuestionIfEnabled(stateChips) { |
Adrià Vilanova Martínez | 19f6a65 | 2023-11-15 19:38:50 +0100 | [diff] [blame] | 55 | this.threadQuestion.injectIfEnabled({stateChips, isMessageNode: false}); |
Adrià Vilanova Martínez | 0d92a0c | 2023-11-06 01:37:20 +0100 | [diff] [blame] | 56 | } |
| 57 | |
Adrià Vilanova Martínez | 19f6a65 | 2023-11-15 19:38:50 +0100 | [diff] [blame] | 58 | injectAtMessageIfEnabled(messageNode) { |
| 59 | this.threadMessage.injectIfEnabled({messageNode, isMessageNode: true}); |
Adrià Vilanova Martínez | 0d92a0c | 2023-11-06 01:37:20 +0100 | [diff] [blame] | 60 | } |
| 61 | } |