From 3a488a9110be1c3d33edc09aa5cbf3450742837f Mon Sep 17 00:00:00 2001 From: Ajay Date: Tue, 26 Nov 2024 02:25:42 -0500 Subject: Fix upcoming notice behavior --- src/render/UpcomingNotice.tsx | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) (limited to 'src/render/UpcomingNotice.tsx') 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; + upcomingNoticeRef: React.MutableRefObject; 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( - 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; } } -- cgit v1.2.3