Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion public/_locales
Submodule _locales updated 1 files
+3 −0 en/messages.json
11 changes: 11 additions & 0 deletions public/options/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,17 @@
</label>
</div>
</div>

<br />

<div data-type="selector" data-sync="segmentListDefaultTab">
<label class="optionLabel" for="segmentListDefaultTab">__MSG_segmentListDefaultTab__:</label>

<select id="segmentListDefaultTab" class="selector-element optionsSelector">
<option value="0">__MSG_SegmentsCap__</option>
<option value="1">__MSG_Chapters__</option>
</select>
</div>
</div>

<div data-type="toggle" data-sync="darkMode">
Expand Down
4 changes: 3 additions & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as CompileConfig from "../config.json";
import * as invidiousList from "../ci/invidiouslist.json";
import { Category, CategorySelection, CategorySkipOption, NoticeVisibilityMode, PreviewBarOption, SponsorTime, VideoID, SponsorHideType } from "./types";
import { Category, CategorySelection, CategorySkipOption, NoticeVisibilityMode, PreviewBarOption, SponsorTime, VideoID, SponsorHideType, SegmentListDefaultTab } from "./types";
import { Keybind, ProtoConfig, keybindEquals } from "../maze-utils/src/config";
import { HashedValue } from "../maze-utils/src/hash";
import { Permission, AdvancedSkipRuleSet } from "./utils/skipRule";
Expand All @@ -10,6 +10,7 @@ interface SBConfig {
isVip: boolean;
permissions: Record<Category, Permission>;
defaultCategory: Category;
segmentListDefaultTab: SegmentListDefaultTab;
renderSegmentsAsChapters: boolean;
forceChannelCheck: boolean;
minutesSaved: number;
Expand Down Expand Up @@ -337,6 +338,7 @@ const syncDefaults = {
isVip: false,
permissions: {},
defaultCategory: "chooseACategory" as Category,
segmentListDefaultTab: SegmentListDefaultTab.Segments,
renderSegmentsAsChapters: false,
forceChannelCheck: false,
minutesSaved: 0,
Expand Down
19 changes: 14 additions & 5 deletions src/popup/SegmentListComponent.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from "react";
import { ActionType, SegmentUUID, SponsorHideType, SponsorTime, VideoID } from "../types";
import { ActionType, SegmentListDefaultTab, SegmentUUID, SponsorHideType, SponsorTime, VideoID } from "../types";
import Config from "../config";
import { waitFor } from "../../maze-utils/src";
import { shortCategoryName } from "../utils/categoryUtils";
Expand Down Expand Up @@ -61,12 +61,21 @@ export const SegmentListComponent = (props: SegmentListComponentProps) => {
}, [props.segments]);

React.useEffect(() => {
if (hasSegments){
setTab(SegmentListTab.Segments);
const setTabBasedOnConfig = () => {
const preferChapters = Config.config.segmentListDefaultTab === SegmentListDefaultTab.Chapters;
if (preferChapters) {
setTab(hasChapters ? SegmentListTab.Chapter : SegmentListTab.Segments);
} else {
setTab(hasSegments ? SegmentListTab.Segments : SegmentListTab.Chapter);
}
};

if (Config.isReady()) {
setTabBasedOnConfig();
} else {
setTab(SegmentListTab.Chapter);
waitFor(() => Config.isReady()).then(setTabBasedOnConfig);
}
}, [props.videoID, hasSegments]);
}, [props.videoID, hasSegments, hasChapters]);

const segmentsWithNesting = React.useMemo(() => {
const result: SegmentWithNesting[] = [];
Expand Down
5 changes: 5 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,4 +227,9 @@ export enum NoticeVisibilityMode {
MiniForAll = 2,
FadedForAutoSkip = 3,
FadedForAll = 4
}

export enum SegmentListDefaultTab {
Segments,
Chapters,
}