From 64da228a27e69f5c55bab1d238f75dca695d41c5 Mon Sep 17 00:00:00 2001 From: hanyd Date: Sat, 14 Sep 2024 16:02:44 +0800 Subject: [PATCH] Remove description on segments --- src/components/SponsorTimeEditComponent.tsx | 19 ------------------- src/content.ts | 4 ---- src/js-components/previewBar.ts | 5 ++--- src/types.ts | 7 +------ src/utils/exporter.ts | 4 +--- 5 files changed, 4 insertions(+), 35 deletions(-) diff --git a/src/components/SponsorTimeEditComponent.tsx b/src/components/SponsorTimeEditComponent.tsx index 21edadca..7fa7cb71 100644 --- a/src/components/SponsorTimeEditComponent.tsx +++ b/src/components/SponsorTimeEditComponent.tsx @@ -31,7 +31,6 @@ export interface SponsorTimeEditState { sponsorTimeEdits: [string, string]; selectedCategory: Category; selectedActionType: ActionType; - description: string; suggestedNames: SelectorOption[]; chapterNameSelectorOpen: boolean; chapterNameSelectorHovering: boolean; @@ -71,7 +70,6 @@ class SponsorTimeEditComponent extends React.Component { - this.saveEditTimes(); - } - ); - - if (!this.fetchingSuggestions) { - this.fetchSuggestions(description); - } - } - async fetchSuggestions(description: string): Promise { if (this.props.contentContainer().channelIDInfo.status !== ChannelIDStatus.Found) return; diff --git a/src/content.ts b/src/content.ts index 6bbc4329..480f5347 100644 --- a/src/content.ts +++ b/src/content.ts @@ -1384,7 +1384,6 @@ function updatePreviewBar(): void { actionType: segment.actionType, unsubmitted: false, showLarger: segment.actionType === ActionType.Poi, - description: segment.description, source: segment.source, requiredSegment: requiredSegment && (segment.UUID === requiredSegment || segment.UUID?.startsWith(requiredSegment)), @@ -1400,7 +1399,6 @@ function updatePreviewBar(): void { actionType: segment.actionType, unsubmitted: true, showLarger: segment.actionType === ActionType.Poi, - description: segment.description, source: segment.source, }); }); @@ -2018,7 +2016,6 @@ function updateSponsorTimesSubmitting(getFromConfig = true) { UUID: segmentTime.UUID, category: segmentTime.category, actionType: segmentTime.actionType, - description: segmentTime.description, source: segmentTime.source, }); } @@ -2589,7 +2586,6 @@ function checkForPreloadedSegment() { UUID: generateUserID() as SegmentUUID, category: segment.category ? segment.category : Config.config.defaultCategory, actionType: segment.actionType ? segment.actionType : ActionType.Skip, - description: segment.description ?? "", source: SponsorSourceType.Local, }); diff --git a/src/js-components/previewBar.ts b/src/js-components/previewBar.ts index 84add3da..92dca650 100644 --- a/src/js-components/previewBar.ts +++ b/src/js-components/previewBar.ts @@ -11,7 +11,6 @@ export interface PreviewBarSegment { actionType: ActionType; unsubmitted: boolean; showLarger: boolean; - description: string; source: SponsorSourceType; requiredSegment?: boolean; selectedSegment?: boolean; @@ -108,7 +107,7 @@ class PreviewBar { private setTooltipTitle(segment: PreviewBarSegment, tooltip: HTMLElement): void { if (segment) { - const name = segment.description || shortCategoryName(segment.category); + const name = shortCategoryName(segment.category); if (segment.unsubmitted) { tooltip.textContent = chrome.i18n.getMessage("unsubmitted") + " " + name; } else { @@ -264,7 +263,7 @@ class PreviewBar { elem.classList.add("sponsorChapterText"); return elem; })()) as HTMLDivElement; - chapterCustomText.innerText = chosenSegment.description || shortCategoryName(chosenSegment.category); + chapterCustomText.innerText = shortCategoryName(chosenSegment.category); // if (chosenSegment.actionType !== ActionType.Chapter) { // chapterTitle.classList.add("sponsorBlock-segment-title"); diff --git a/src/types.ts b/src/types.ts index f1cb8148..749c3a88 100644 --- a/src/types.ts +++ b/src/types.ts @@ -79,18 +79,13 @@ export enum SponsorSourceType { Local = 1, YouTube = 2, } - -export interface SegmentContainer { +export interface SponsorTime { segment: [number] | [number, number]; -} - -export interface SponsorTime extends SegmentContainer { UUID: SegmentUUID; locked?: number; category: Category; actionType: ActionType; - description?: string; hidden?: SponsorHideType; source: SponsorSourceType; diff --git a/src/utils/exporter.ts b/src/utils/exporter.ts index bca3816f..8d4fc404 100644 --- a/src/utils/exporter.ts +++ b/src/utils/exporter.ts @@ -26,7 +26,7 @@ export function exportTimes(segments: SponsorTime[]): string { } function exportTime(segment: SponsorTime): string { - const name = segment.description || shortCategoryName(segment.category); + const name = shortCategoryName(segment.category); return `${getFormattedTime(segment.segment[0], true)}${ segment.segment[1] && segment.segment[0] !== segment.segment[1] @@ -66,7 +66,6 @@ export function importTimes(data: string, videoDuration: number): SponsorTime[] segment: [startTime, getFormattedTimeToSeconds(match[1])], category: determinedCategory, actionType: ActionType.Skip, - description: title, source: SponsorSourceType.Local, UUID: generateUserID() as SegmentUUID, }; @@ -104,7 +103,6 @@ export function exportTimesAsHashParam(segments: SponsorTime[]): string { actionType: segment.actionType, category: segment.category, segment: segment.segment, - ...(segment.description ? { description: segment.description } : {}), // don't include the description param if empty })); return `#segments=${JSON.stringify(hashparamSegments)}`;