diff --git a/src/components/EpisodeSelector.js b/src/components/EpisodeSelector.js
index 9d3cc4e5..b7c62094 100644
--- a/src/components/EpisodeSelector.js
+++ b/src/components/EpisodeSelector.js
@@ -2,7 +2,9 @@ import React from 'react';
import { TypeSelector } from './TypeSelector';
import { NumberSelector } from './NumberSelector';
import { VideoProgressStore } from '../lib/storage/VideoProgress'
+import { SelectBox } from '../components/SelectBox';
import './EpisodeSelector.css'
+import { useWindowSize } from '../hooks/useWindowSize';
export function EpisodeSelector({ setSelectedSeason, selectedSeason, setEpisode, seasons, episodes, currentSeason, currentEpisode, streamData }) {
const choices = episodes ? episodes.map(v => {
@@ -27,9 +29,21 @@ export function EpisodeSelector({ setSelectedSeason, selectedSeason, setEpisode,
}
}) : [];
+ const windowSize = useWindowSize()
+
return (
- ({ value: v.toString(), label: `Season ${v}`}))} />
+ {
+ (seasons.length > 0 && (windowSize.width <= 768 || seasons.length > 4)) ?
+ (
+ setSelectedSeason(seasons[index])} selectedItem={seasons.findIndex(s => s === selectedSeason)} options={seasons.map(season => { return {id: season, name: `Season ${season}` }})}/>
+ )
+ :
+ (
+ ({ value: v.toString(), label: `Season ${v}`}))} />
+ )
+ }
+
setEpisode({episode: e, season: selectedSeason})} choices={choices} selected={(selectedSeason.toString() === currentSeason) ? currentEpisode : null} />
)
diff --git a/src/hooks/useWindowSize.js b/src/hooks/useWindowSize.js
new file mode 100644
index 00000000..87427a62
--- /dev/null
+++ b/src/hooks/useWindowSize.js
@@ -0,0 +1,28 @@
+import { useEffect, useState } from "react";
+
+// https://usehooks.com/useWindowSize/
+export function useWindowSize() {
+ // Initialize state with undefined width/height so server and client renders match
+ // Learn more here: https://joshwcomeau.com/react/the-perils-of-rehydration/
+ const [windowSize, setWindowSize] = useState({
+ width: undefined,
+ height: undefined,
+ });
+ useEffect(() => {
+ // Handler to call on window resize
+ function handleResize() {
+ // Set window width/height to state
+ setWindowSize({
+ width: window.innerWidth,
+ height: window.innerHeight,
+ });
+ }
+ // Add event listener
+ window.addEventListener("resize", handleResize);
+ // Call handler right away so state gets updated with initial window size
+ handleResize();
+ // Remove event listener on cleanup
+ return () => window.removeEventListener("resize", handleResize);
+ }, []); // Empty array ensures that effect is only run on mount
+ return windowSize;
+ }
\ No newline at end of file