mirror of
https://github.com/p-stream/p-stream.git
synced 2026-03-11 17:55:33 +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 { ErrorContainer, ErrorLayout } from "@/pages/layouts/ErrorLayout";
|
||||
import { usePlayerStore } from "@/stores/player/store";
|
||||
import { usePreferencesStore } from "@/stores/preferences";
|
||||
|
||||
import { ErrorCardInModal } from "../errors/ErrorCard";
|
||||
|
||||
|
|
@ -19,15 +20,20 @@ export function PlaybackErrorPart() {
|
|||
const modal = useModal("error");
|
||||
const settingsRouter = useOverlayRouter("settings");
|
||||
const hasOpenedSettings = useRef(false);
|
||||
const setLastSuccessfulSource = usePreferencesStore(
|
||||
(s) => s.setLastSuccessfulSource,
|
||||
);
|
||||
|
||||
// Automatically open the settings overlay when a playback error occurs
|
||||
useEffect(() => {
|
||||
if (playbackError && !hasOpenedSettings.current) {
|
||||
hasOpenedSettings.current = true;
|
||||
// Reset the last successful source when a playback error occurs
|
||||
setLastSuccessfulSource(null);
|
||||
settingsRouter.open();
|
||||
settingsRouter.navigate("/source");
|
||||
}
|
||||
}, [playbackError, settingsRouter]);
|
||||
}, [playbackError, settingsRouter, setLastSuccessfulSource]);
|
||||
|
||||
const handleOpenSourcePicker = () => {
|
||||
settingsRouter.open();
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import { DisplayInterface } from "@/components/player/display/displayInterface";
|
||||
import { playerStatus } from "@/stores/player/slices/source";
|
||||
import { MakeSlice } from "@/stores/player/slices/types";
|
||||
import { usePreferencesStore } from "@/stores/preferences";
|
||||
|
||||
export interface DisplaySlice {
|
||||
display: DisplayInterface | null;
|
||||
|
|
@ -106,8 +105,6 @@ export const createDisplaySlice: MakeSlice<DisplaySlice> = (set, get) => ({
|
|||
s.status = playerStatus.PLAYBACK_ERROR;
|
||||
s.interface.error = err;
|
||||
});
|
||||
// Reset last successful source on playback error
|
||||
usePreferencesStore.getState().setLastSuccessfulSource(null);
|
||||
});
|
||||
|
||||
set((s) => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue