aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/render/UpcomingNotice.tsx
diff options
context:
space:
mode:
authorAjay <[email protected]>2024-11-26 02:25:42 -0500
committerAjay <[email protected]>2024-11-26 02:25:42 -0500
commit3a488a9110be1c3d33edc09aa5cbf3450742837f (patch)
treed116a765dc72b80c52fdc91eeba600b2ab958a4b /src/render/UpcomingNotice.tsx
parentdfdc052f4bcd0f4d2f50a37ef4763e3a1af5024d (diff)
downloadSponsorBlock-3a488a9110be1c3d33edc09aa5cbf3450742837f.tar.gz
SponsorBlock-3a488a9110be1c3d33edc09aa5cbf3450742837f.zip
Fix upcoming notice behavior
Diffstat (limited to 'src/render/UpcomingNotice.tsx')
-rw-r--r--src/render/UpcomingNotice.tsx32
1 files changed, 22 insertions, 10 deletions
diff --git a/src/render/UpcomingNotice.tsx b/src/render/UpcomingNotice.tsx
index 8c0aeffe..3b8e4f90 100644
--- a/src/render/UpcomingNotice.tsx
+++ b/src/render/UpcomingNotice.tsx
@@ -1,9 +1,9 @@
import * as React from "react";
import { createRoot, Root } from "react-dom/client";
import { ContentContainer, SponsorTime } from "../types";
-import UpcomingNoticeComponent from "../components/UpcomingNoticeComponent";
import Utils from "../utils";
+import SkipNoticeComponent from "../components/SkipNoticeComponent";
const utils = new Utils();
class UpcomingNotice {
@@ -13,9 +13,11 @@ class UpcomingNotice {
noticeElement: HTMLDivElement;
- upcomingNoticeRef: React.MutableRefObject<UpcomingNoticeComponent>;
+ upcomingNoticeRef: React.MutableRefObject<SkipNoticeComponent>;
root: Root;
+ closed = false;
+
constructor(segments: SponsorTime[], contentContainer: ContentContainer, timeLeft: number, autoSkip: boolean) {
this.upcomingNoticeRef = React.createRef();
@@ -31,23 +33,33 @@ class UpcomingNotice {
this.root = createRoot(this.noticeElement);
this.root.render(
- <UpcomingNoticeComponent
- segments={segments}
- autoSkip={autoSkip}
+ <SkipNoticeComponent segments={segments}
+ autoSkip={autoSkip}
+ upcomingNotice={true}
contentContainer={contentContainer}
- timeUntilSegment={timeLeft}
ref={this.upcomingNoticeRef}
- closeListener={() => this.close()} />
+ closeListener={() => this.close()}
+ smaller={true}
+ fadeIn={true}
+ unskipTime={timeLeft} />
);
}
close(): void {
this.root.unmount();
-
this.noticeElement.remove();
- const upcomingNotices = this.contentContainer().upcomingNotices;
- upcomingNotices.splice(upcomingNotices.indexOf(this), 1);
+ this.closed = true;
+ }
+
+ sameNotice(segments: SponsorTime[]): boolean {
+ if (segments.length !== this.segments.length) return false;
+
+ for (let i = 0; i < segments.length; i++) {
+ if (segments[i].UUID !== this.segments[i].UUID) return false;
+ }
+
+ return true;
}
}