From 9dda9a583d5226f532ad620518c702e3598342f1 Mon Sep 17 00:00:00 2001 From: FlorianZahn Date: Thu, 21 Oct 2021 03:14:45 +0200 Subject: [PATCH 1/2] unsubmitted segments are initialized rounded to 3 digits --- src/components/SponsorTimeEditComponent.tsx | 11 ++++++++++- src/content.ts | 5 +++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/components/SponsorTimeEditComponent.tsx b/src/components/SponsorTimeEditComponent.tsx index 371228dd..ea09ec6a 100644 --- a/src/components/SponsorTimeEditComponent.tsx +++ b/src/components/SponsorTimeEditComponent.tsx @@ -38,6 +38,9 @@ class SponsorTimeEditComponent extends React.Component void; + previousSkipType: CategoryActionType; + timeBeforeChangingToPOI: number; // Initialized when first selecting POI + constructor(props: SponsorTimeEditProps) { super(props); @@ -46,6 +49,7 @@ class SponsorTimeEditComponent extends React.Component segment.category === event.target.value && i !== this.props.index)) { alert(chrome.i18n.getMessage("poiOnlyOneSegment")); } + } else if (getCategoryActionType(event.target.value as Category) === CategoryActionType.Skippable && this.previousSkipType === CategoryActionType.POI) { + this.setTimeTo(1, this.timeBeforeChangingToPOI); } - + + this.previousSkipType = getCategoryActionType(event.target.value as Category); this.saveEditTimes(); } diff --git a/src/content.ts b/src/content.ts index 7eeed429..679f5847 100644 --- a/src/content.ts +++ b/src/content.ts @@ -1459,9 +1459,10 @@ function getRealCurrentTime(): number { } function startOrEndTimingNewSegment() { + const roundedTime = Math.round((getRealCurrentTime() + Number.EPSILON) * 1000) / 1000; if (!isSegmentCreationInProgress()) { sponsorTimesSubmitting.push({ - segment: [getRealCurrentTime()], + segment: [roundedTime], UUID: null, category: Config.config.defaultCategory, actionType: ActionType.Skip, @@ -1471,7 +1472,7 @@ function startOrEndTimingNewSegment() { // Finish creating the new segment const existingSegment = getIncompleteSegment(); const existingTime = existingSegment.segment[0]; - const currentTime = getRealCurrentTime(); + const currentTime = roundedTime; // Swap timestamps if the user put the segment end before the start existingSegment.segment = [Math.min(existingTime, currentTime), Math.max(existingTime, currentTime)]; From 95f45312e139858151365b0f452415f5eade6fec Mon Sep 17 00:00:00 2001 From: FlorianZahn Date: Thu, 21 Oct 2021 04:19:26 +0200 Subject: [PATCH 2/2] support for multiple poi categories --- src/components/SponsorTimeEditComponent.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/SponsorTimeEditComponent.tsx b/src/components/SponsorTimeEditComponent.tsx index ea09ec6a..98c00616 100644 --- a/src/components/SponsorTimeEditComponent.tsx +++ b/src/components/SponsorTimeEditComponent.tsx @@ -344,7 +344,7 @@ class SponsorTimeEditComponent extends React.Component