Skip to content

Commit 7ccdf67

Browse files
Set default tab to chapters if there are no segments
1 parent 7cbb0ec commit 7ccdf67

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/popup/SegmentListComponent.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,13 @@ export const SegmentListComponent = (props: SegmentListComponentProps) => {
4747
}, []);
4848

4949
React.useEffect(() => {
50-
setTab(SegmentListTab.Segments);
51-
}, [props.videoID]);
50+
const hasNonChapter = props.segments.find(seg => seg.actionType !== ActionType.Chapter)
51+
if (!hasNonChapter && props.segments.length > 0) {
52+
setTab(SegmentListTab.Chapter);
53+
} else {
54+
setTab(SegmentListTab.Segments);
55+
}
56+
}, [props.videoID, props.segments]);
5257

5358
const tabFilter = (segment: SponsorTime) => {
5459
if (tab === SegmentListTab.Chapter) {

0 commit comments

Comments
 (0)