fix: handle casting-player navigation when no back stack exists

Use useEffect to check connection state and redirect properly. If no back
stack exists, navigate to home tab instead of calling router.back().
This commit is contained in:
Uruk
2026-01-20 19:04:29 +01:00
parent 338f42b980
commit ef2cc19e21

View File

@@ -198,10 +198,18 @@ export default function CastingPlayerScreen() {
}, [currentItem?.Type, nextEpisode, duration, progress]);
// Redirect if not connected
if (!isConnected || !currentItem || !protocol) {
if (router.canGoBack()) {
router.back();
useEffect(() => {
if (!isConnected || !currentItem || !protocol) {
if (router.canGoBack()) {
router.back();
} else {
router.replace("/(auth)/(tabs)/(home)/");
}
}
}, [isConnected, currentItem, protocol]);
// Don't render if not connected
if (!isConnected || !currentItem || !protocol) {
return null;
}