Adrià Vilanova MartÃnez | 3c13a76 | 2024-11-09 23:03:32 +0100 | [diff] [blame] | 1 | import CssSelectorNodeWatcherHandler from '../../../../infrastructure/presentation/nodeWatcher/handlers/CssSelectorHandler.adapter'; |
| 2 | import { |
| 3 | NodeMutation, |
| 4 | NodeMutationType, |
| 5 | } from '../../../../presentation/nodeWatcher/NodeWatcherHandler'; |
| 6 | import FlattenThreads from '../../core/flattenThreads'; |
| 7 | |
| 8 | /** Readd reply button when the Community Console removes it */ |
| 9 | export 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 | } |