Add keybind for previewing a segment

This commit is contained in:
Ajay
2024-01-14 18:34:23 -05:00
parent f3818c2066
commit 1bf67cc533
9 changed files with 40 additions and 7 deletions

View File

@@ -48,6 +48,7 @@ import { addCleanupListener } from "../maze-utils/src/cleanup";
import { hideDeArrowPromotion, tryShowingDeArrowPromotion } from "./dearrowPromotion";
import { asyncRequestToServer } from "./utils/requests";
import { isMobileControlsOpen } from "./utils/mobileUtils";
import { defaultPreviewTime } from "./utils/constants";
cleanPage();
@@ -2230,7 +2231,16 @@ function openSubmissionMenu() {
if (sponsorTimesSubmitting !== undefined && sponsorTimesSubmitting.length > 0) {
submissionNotice = new SubmissionNotice(skipNoticeContentContainer, sendSubmitMessage);
}
}
function previewRecentSegment() {
if (sponsorTimesSubmitting !== undefined && sponsorTimesSubmitting.length > 0) {
previewTime(sponsorTimesSubmitting[sponsorTimesSubmitting.length - 1].segment[0] - defaultPreviewTime);
if (submissionNotice) {
submissionNotice.scrollToBottom();
}
}
}
function submitSegments() {
@@ -2444,6 +2454,7 @@ function hotkeyListener(e: KeyboardEvent): void {
const closeSkipNoticeKey = Config.config.closeSkipNoticeKeybind;
const startSponsorKey = Config.config.startSponsorKeybind;
const submitKey = Config.config.actuallySubmitKeybind;
const previewKey = Config.config.previewKeybind;
const openSubmissionMenuKey = Config.config.submitKeybind;
const nextChapterKey = Config.config.nextChapterKeybind;
const previousChapterKey = Config.config.previousChapterKeybind;
@@ -2475,6 +2486,9 @@ function hotkeyListener(e: KeyboardEvent): void {
} else if (keybindEquals(key, openSubmissionMenuKey)) {
openSubmissionMenu();
return;
} else if (keybindEquals(key, previewKey)) {
previewRecentSegment();
return;
} else if (keybindEquals(key, nextChapterKey)) {
if (sponsorTimes.length > 0) e.stopPropagation();
nextChapter();