From f177b95a5aeebc4e932a5984165144ca7ccab294 Mon Sep 17 00:00:00 2001 From: Ajay Date: Sat, 22 Jun 2024 17:06:29 +0530 Subject: [PATCH] Fix submission menu after video ends and unskip button after video ends --- maze-utils | 2 +- src/components/SkipNoticeComponent.tsx | 3 ++- src/components/SponsorTimeEditComponent.tsx | 9 +++++---- src/components/SubmissionNoticeComponent.tsx | 7 ++++--- src/content.ts | 1 - src/render/GenericNotice.tsx | 3 ++- src/types.ts | 1 - 7 files changed, 14 insertions(+), 12 deletions(-) diff --git a/maze-utils b/maze-utils index 42888f80..4983281b 160000 --- a/maze-utils +++ b/maze-utils @@ -1 +1 @@ -Subproject commit 42888f800e38213f5e5d79dda953e790ada502eb +Subproject commit 4983281b05635362f587e030ae81ef4b60fe9de9 diff --git a/src/components/SkipNoticeComponent.tsx b/src/components/SkipNoticeComponent.tsx index 0a351c6c..2a1292a3 100644 --- a/src/components/SkipNoticeComponent.tsx +++ b/src/components/SkipNoticeComponent.tsx @@ -15,6 +15,7 @@ import { downvoteButtonColor, SkipNoticeAction } from "../utils/noticeUtils"; import { generateUserID } from "../../maze-utils/src/setup"; import { keybindToString } from "../../maze-utils/src/config"; import { getFormattedTime } from "../../maze-utils/src/formating"; +import { getVideo } from "../../maze-utils/src/video"; enum SkipButtonState { Undo, // Unskip @@ -685,7 +686,7 @@ class SkipNoticeComponent extends React.Component number { return () => { const sponsorTime = this.segments[index]; - const duration = Math.round((sponsorTime.segment[1] - this.contentContainer().v.currentTime) * (1 / this.contentContainer().v.playbackRate)); + const duration = Math.round((sponsorTime.segment[1] - getVideo().currentTime) * (1 / getVideo().playbackRate)); return Math.max(duration, Config.config.skipNoticeDuration); }; diff --git a/src/components/SponsorTimeEditComponent.tsx b/src/components/SponsorTimeEditComponent.tsx index 527dbbe2..f5ff47e7 100644 --- a/src/components/SponsorTimeEditComponent.tsx +++ b/src/components/SponsorTimeEditComponent.tsx @@ -9,6 +9,7 @@ import { DEFAULT_CATEGORY } from "../utils/categoryUtils"; import { getFormattedTime, getFormattedTimeToSeconds } from "../../maze-utils/src/formating"; import { asyncRequestToServer } from "../utils/requests"; import { defaultPreviewTime } from "../utils/constants"; +import { getVideo } from "../../maze-utils/src/video"; export interface SponsorTimeEditProps { index: number; @@ -401,7 +402,7 @@ class SponsorTimeEditComponent extends React.Component 0.6 && !this.fullVideoWarningShown && (sponsorTime.category === "sponsor" || sponsorTime.category === "selfpromo" || sponsorTime.category === "chooseACategory")) { @@ -553,7 +554,7 @@ class SponsorTimeEditComponent extends React.Component e.stopPropagation()}> {this.getSponsorTimeMessages()} @@ -283,7 +284,7 @@ class SubmissionNoticeComponent extends React.Component dialogWidth * 2) { + && getVideo().offsetWidth > dialogWidth * 2) { const options = { title: chrome.i18n.getMessage(`category_${category}`), textBoxes: getGuidelineInfo(category), diff --git a/src/content.ts b/src/content.ts index fa06b25f..7519d7d3 100644 --- a/src/content.ts +++ b/src/content.ts @@ -177,7 +177,6 @@ const skipNoticeContentContainer: ContentContainer = () => ({ sponsorTimes, sponsorTimesSubmitting, skipNotices, - v: getVideo(), sponsorVideoID: getVideoID(), reskipSponsorTime, updatePreviewBar, diff --git a/src/render/GenericNotice.tsx b/src/render/GenericNotice.tsx index d1a4443c..bbac6c94 100644 --- a/src/render/GenericNotice.tsx +++ b/src/render/GenericNotice.tsx @@ -8,6 +8,7 @@ const utils = new Utils(); import { ContentContainer } from "../types"; import NoticeTextSelectionComponent from "../components/NoticeTextSectionComponent"; import { ButtonListener } from "../../maze-utils/src/components/component-types"; +import { getVideo } from "../../maze-utils/src/video"; export interface TextBox { icon: string; @@ -75,7 +76,7 @@ export default class GenericNotice { {options.textBoxes?.length > 0 ? + style={{maxHeight: getVideo() ? (getVideo().offsetHeight - 200) + "px" : null}}> {this.getMessageBoxes(this.idSuffix, options.textBoxes)} diff --git a/src/types.ts b/src/types.ts index 460a308d..fdaee7b8 100644 --- a/src/types.ts +++ b/src/types.ts @@ -10,7 +10,6 @@ export interface ContentContainer { sponsorTimes: SponsorTime[]; sponsorTimesSubmitting: SponsorTime[]; skipNotices: SkipNotice[]; - v: HTMLVideoElement; sponsorVideoID; reskipSponsorTime: (segment: SponsorTime, forceSeek?: boolean) => void; updatePreviewBar: () => void;