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 0ce5e342c6
commit da6e42c19b

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;
}