blob: 2eb3d333cdc9a801fe2f210f82ee2b90bc92c7d1 [file] [log] [blame]
Adrià Vilanova Martínez3c13a762024-11-09 23:03:32 +01001import CssSelectorNodeWatcherHandler from '../../../../infrastructure/presentation/nodeWatcher/handlers/CssSelectorHandler.adapter';
2import {
3 NodeMutation,
4 NodeMutationType,
5} from '../../../../presentation/nodeWatcher/NodeWatcherHandler';
6import FlattenThreads from '../../core/flattenThreads';
7
8/** Readd reply button when the Community Console removes it */
9export default class FlattenThreadsReaddReplyBtnHandler extends CssSelectorNodeWatcherHandler {
10 cssSelector = 'twpt-flatten-thread-reply-button';
11 mutationTypesProcessed = [NodeMutationType.RemovedNode];
12
13 constructor(private flattenThreads: FlattenThreads) {
14 super();
15 }
16
17 onMutatedNode({ node, mutationRecord }: NodeMutation<HTMLElement>) {
18 this.flattenThreads.injectReplyBtn(
19 mutationRecord.target,
20 JSON.parse(node.getAttribute('extraInfo')),
21 );
22 }
23}