From 4e522c92379306ed1171577522ed7f7c2b80fb34 Mon Sep 17 00:00:00 2001 From: hanyd Date: Fri, 13 Sep 2024 12:51:37 +0800 Subject: [PATCH] Make scroll on inputs on time edit step whole frames --- src/components/SponsorTimeEditComponent.tsx | 21 ++++++++++++--------- src/content.ts | 4 ++-- src/utils/video.ts | 12 ++++++++++-- 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/src/components/SponsorTimeEditComponent.tsx b/src/components/SponsorTimeEditComponent.tsx index a5f1f83c..21edadca 100644 --- a/src/components/SponsorTimeEditComponent.tsx +++ b/src/components/SponsorTimeEditComponent.tsx @@ -3,16 +3,16 @@ import { CheckboxChangeEvent } from "antd/es/checkbox"; import * as React from "react"; import * as CompileConfig from "../../config.json"; import Config from "../config"; +import { showMessage } from "../render/MessageNotice"; import { RectangleTooltip } from "../render/RectangleTooltip"; import { asyncRequestToServer } from "../requests/requests"; import { ActionType, Category, ChannelIDStatus, ContentContainer, SponsorTime } from "../types"; import { DEFAULT_CATEGORY } from "../utils/categoryUtils"; import { defaultPreviewTime } from "../utils/constants"; import { getFormattedTime, getFormattedTimeToSeconds } from "../utils/formating"; -import { getVideo } from "../utils/video"; +import { getFrameRate, getVideo } from "../utils/video"; import { SelectorOption } from "./SelectorComponent"; import SubmissionNoticeComponent from "./SubmissionNoticeComponent"; -import { showMessage } from "../render/MessageNotice"; export interface SponsorTimeEditProps { index: number; @@ -355,15 +355,18 @@ class SponsorTimeEditComponent extends React.Component {}, @@ -285,6 +286,8 @@ let waitingForEmbed = false; async function refreshVideoAttachments(): Promise { if (waitingForNewVideo) return; + void updateFrameRate(); + waitingForNewVideo = true; // Compatibility for Vinegar extension const newVideo = @@ -376,14 +379,15 @@ function addPageListeners(): void { }); } -export async function getFrameRate() { - return await getPropertyFromWindow({ +export async function updateFrameRate(): Promise { + frameRate = await getPropertyFromWindow({ sendType: "getFrameRate", responseType: "returnFrameRate", }).catch(() => { // fall back to 30 fps return 30; }); + return frameRate; } let lastRefresh = 0; @@ -402,6 +406,10 @@ export function getVideoID(): VideoID | null { return videoID; } +export function getFrameRate(): number { + return frameRate; +} + export function getWaitingForChannelID(): boolean { return waitingForChannelID; }