-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(#3): button isn't showing with multiple 'new message' tabs
- Loading branch information
Dolev Franco
committed
Jan 9, 2023
1 parent
2c89d0b
commit c809beb
Showing
2 changed files
with
51 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
export class NewMessageObserver { | ||
private observer: MutationObserver; | ||
private target: Node; | ||
|
||
constructor(callback: (element: Node) => void, target: Node) { | ||
this.target = target; | ||
this.observer = new MutationObserver((mutations) => { | ||
mutations.forEach((mutation) => { | ||
callback(target); | ||
}); | ||
}); | ||
const observerOptions = { | ||
attributes: true, | ||
childList: true, | ||
characterData: true, | ||
}; | ||
this.observer.observe(target, observerOptions); | ||
} | ||
|
||
getTarget(): Node { | ||
return this.target; | ||
} | ||
|
||
disconnect(): void { | ||
this.observer.disconnect(); | ||
} | ||
} |