mirror of
https://github.com/p-stream/p-stream.git
synced 2026-04-21 03:02:28 +00:00
fix the source getting reset when we change sources
Changing sources causes a non fatal error, but we were clearing the last successful source when any error happened. Instead we can clear if it's fatal.
This commit is contained in:
parent
0c192d2582
commit
65246b8be9
2 changed files with 7 additions and 4 deletions
|
|
@ -10,6 +10,7 @@ import { Title } from "@/components/text/Title";
|
||||||
import { useOverlayRouter } from "@/hooks/useOverlayRouter";
|
import { useOverlayRouter } from "@/hooks/useOverlayRouter";
|
||||||
import { ErrorContainer, ErrorLayout } from "@/pages/layouts/ErrorLayout";
|
import { ErrorContainer, ErrorLayout } from "@/pages/layouts/ErrorLayout";
|
||||||
import { usePlayerStore } from "@/stores/player/store";
|
import { usePlayerStore } from "@/stores/player/store";
|
||||||
|
import { usePreferencesStore } from "@/stores/preferences";
|
||||||
|
|
||||||
import { ErrorCardInModal } from "../errors/ErrorCard";
|
import { ErrorCardInModal } from "../errors/ErrorCard";
|
||||||
|
|
||||||
|
|
@ -19,15 +20,20 @@ export function PlaybackErrorPart() {
|
||||||
const modal = useModal("error");
|
const modal = useModal("error");
|
||||||
const settingsRouter = useOverlayRouter("settings");
|
const settingsRouter = useOverlayRouter("settings");
|
||||||
const hasOpenedSettings = useRef(false);
|
const hasOpenedSettings = useRef(false);
|
||||||
|
const setLastSuccessfulSource = usePreferencesStore(
|
||||||
|
(s) => s.setLastSuccessfulSource,
|
||||||
|
);
|
||||||
|
|
||||||
// Automatically open the settings overlay when a playback error occurs
|
// Automatically open the settings overlay when a playback error occurs
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (playbackError && !hasOpenedSettings.current) {
|
if (playbackError && !hasOpenedSettings.current) {
|
||||||
hasOpenedSettings.current = true;
|
hasOpenedSettings.current = true;
|
||||||
|
// Reset the last successful source when a playback error occurs
|
||||||
|
setLastSuccessfulSource(null);
|
||||||
settingsRouter.open();
|
settingsRouter.open();
|
||||||
settingsRouter.navigate("/source");
|
settingsRouter.navigate("/source");
|
||||||
}
|
}
|
||||||
}, [playbackError, settingsRouter]);
|
}, [playbackError, settingsRouter, setLastSuccessfulSource]);
|
||||||
|
|
||||||
const handleOpenSourcePicker = () => {
|
const handleOpenSourcePicker = () => {
|
||||||
settingsRouter.open();
|
settingsRouter.open();
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import { DisplayInterface } from "@/components/player/display/displayInterface";
|
import { DisplayInterface } from "@/components/player/display/displayInterface";
|
||||||
import { playerStatus } from "@/stores/player/slices/source";
|
import { playerStatus } from "@/stores/player/slices/source";
|
||||||
import { MakeSlice } from "@/stores/player/slices/types";
|
import { MakeSlice } from "@/stores/player/slices/types";
|
||||||
import { usePreferencesStore } from "@/stores/preferences";
|
|
||||||
|
|
||||||
export interface DisplaySlice {
|
export interface DisplaySlice {
|
||||||
display: DisplayInterface | null;
|
display: DisplayInterface | null;
|
||||||
|
|
@ -106,8 +105,6 @@ export const createDisplaySlice: MakeSlice<DisplaySlice> = (set, get) => ({
|
||||||
s.status = playerStatus.PLAYBACK_ERROR;
|
s.status = playerStatus.PLAYBACK_ERROR;
|
||||||
s.interface.error = err;
|
s.interface.error = err;
|
||||||
});
|
});
|
||||||
// Reset last successful source on playback error
|
|
||||||
usePreferencesStore.getState().setLastSuccessfulSource(null);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
set((s) => {
|
set((s) => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue