Moved notice closing to renderer (no leftover nodes)

This commit is contained in:
Ajay Ramachandran
2020-04-14 00:10:20 -04:00
parent 9fafb9cf54
commit 638439a671
5 changed files with 36 additions and 19 deletions

View File

@@ -9,6 +9,8 @@ class SkipNotice {
// Contains functions and variables from the content script needed by the skip notice
contentContainer: () => any;
noticeElement: HTMLDivElement;
constructor(UUID: string, autoSkip: boolean = false, contentContainer) {
this.UUID = UUID;
this.autoSkip = autoSkip;
@@ -35,16 +37,23 @@ class SkipNotice {
//this is the suffix added at the end of every id
let idSuffix = this.UUID + amountOfPreviousNotices;
let noticeElement = document.createElement("div");
noticeElement.id = "sponsorSkipNoticeContainer" + idSuffix;
this.noticeElement = document.createElement("div");
this.noticeElement.id = "sponsorSkipNoticeContainer" + idSuffix;
referenceNode.prepend(noticeElement);
referenceNode.prepend(this.noticeElement);
ReactDOM.render(
<SkipNoticeComponent UUID={UUID} autoSkip={autoSkip} contentContainer={contentContainer} />,
noticeElement
<SkipNoticeComponent UUID={UUID}
autoSkip={autoSkip}
contentContainer={contentContainer}
closeListener={() => this.close()} />,
this.noticeElement
);
}
close() {
this.noticeElement.remove();
}
}
export default SkipNotice;