Skip to content

Commit da1d1ff

Browse files
committed
Merge branch 'master' of https://github.com/ajayyy/SponsorBlock
2 parents fae3a35 + 1609995 commit da1d1ff

4 files changed

Lines changed: 33 additions & 6 deletions

File tree

public/options/options.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,17 @@
331331
</label>
332332
</div>
333333
</div>
334+
335+
<br />
336+
337+
<div data-type="selector" data-sync="segmentListDefaultTab">
338+
<label class="optionLabel" for="segmentListDefaultTab">__MSG_segmentListDefaultTab__:</label>
339+
340+
<select id="segmentListDefaultTab" class="selector-element optionsSelector">
341+
<option value="0">__MSG_SegmentsCap__</option>
342+
<option value="1">__MSG_Chapters__</option>
343+
</select>
344+
</div>
334345
</div>
335346

336347
<div data-type="toggle" data-sync="darkMode">

src/config.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as CompileConfig from "../config.json";
22
import * as invidiousList from "../ci/invidiouslist.json";
3-
import { Category, CategorySelection, CategorySkipOption, NoticeVisibilityMode, PreviewBarOption, SponsorTime, VideoID, SponsorHideType } from "./types";
3+
import { Category, CategorySelection, CategorySkipOption, NoticeVisibilityMode, PreviewBarOption, SponsorTime, VideoID, SponsorHideType, SegmentListDefaultTab } from "./types";
44
import { Keybind, ProtoConfig, keybindEquals } from "../maze-utils/src/config";
55
import { HashedValue } from "../maze-utils/src/hash";
66
import { Permission, AdvancedSkipRuleSet } from "./utils/skipRule";
@@ -10,6 +10,7 @@ interface SBConfig {
1010
isVip: boolean;
1111
permissions: Record<Category, Permission>;
1212
defaultCategory: Category;
13+
segmentListDefaultTab: SegmentListDefaultTab;
1314
renderSegmentsAsChapters: boolean;
1415
forceChannelCheck: boolean;
1516
minutesSaved: number;
@@ -338,6 +339,7 @@ const syncDefaults = {
338339
isVip: false,
339340
permissions: {},
340341
defaultCategory: "chooseACategory" as Category,
342+
segmentListDefaultTab: SegmentListDefaultTab.Segments,
341343
renderSegmentsAsChapters: false,
342344
forceChannelCheck: false,
343345
minutesSaved: 0,

src/popup/SegmentListComponent.tsx

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as React from "react";
2-
import { ActionType, SegmentUUID, SponsorHideType, SponsorTime, VideoID } from "../types";
2+
import { ActionType, SegmentListDefaultTab, SegmentUUID, SponsorHideType, SponsorTime, VideoID } from "../types";
33
import Config from "../config";
44
import { waitFor } from "../../maze-utils/src";
55
import { shortCategoryName } from "../utils/categoryUtils";
@@ -61,12 +61,21 @@ export const SegmentListComponent = (props: SegmentListComponentProps) => {
6161
}, [props.segments]);
6262

6363
React.useEffect(() => {
64-
if (hasSegments){
65-
setTab(SegmentListTab.Segments);
64+
const setTabBasedOnConfig = () => {
65+
const preferChapters = Config.config.segmentListDefaultTab === SegmentListDefaultTab.Chapters;
66+
if (preferChapters) {
67+
setTab(hasChapters ? SegmentListTab.Chapter : SegmentListTab.Segments);
68+
} else {
69+
setTab(hasSegments ? SegmentListTab.Segments : SegmentListTab.Chapter);
70+
}
71+
};
72+
73+
if (Config.isReady()) {
74+
setTabBasedOnConfig();
6675
} else {
67-
setTab(SegmentListTab.Chapter);
76+
waitFor(() => Config.isReady()).then(setTabBasedOnConfig);
6877
}
69-
}, [props.videoID, hasSegments]);
78+
}, [props.videoID, hasSegments, hasChapters]);
7079

7180
const segmentsWithNesting = React.useMemo(() => {
7281
const result: SegmentWithNesting[] = [];

src/types.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,4 +227,9 @@ export enum NoticeVisibilityMode {
227227
MiniForAll = 2,
228228
FadedForAutoSkip = 3,
229229
FadedForAll = 4
230+
}
231+
232+
export enum SegmentListDefaultTab {
233+
Segments,
234+
Chapters,
230235
}

0 commit comments

Comments
 (0)