diff --git a/js/app/components/aqlink.tsx b/js/app/components/aqlink.tsx index deb1b3416..ef2f75119 100644 --- a/js/app/components/aqlink.tsx +++ b/js/app/components/aqlink.tsx @@ -1,8 +1,4 @@ -import { - useNavigation, - useNavigationState, - useRoute, -} from "@react-navigation/native"; +import { useNavigation } from "@react-navigation/native"; import usePlatform from "hooks/usePlatform"; import { useEffect } from "react"; import { Pressable, StyleProp, ViewStyle } from "react-native"; @@ -45,18 +41,18 @@ export default function AQLink({ }) { const { isWeb } = usePlatform(); const navigation = useNavigation(); - const route = useRoute(); const openLoginModal = useStore((state) => state.openLoginModal); const { href } = useAQLinkHref(to); - // get the deepest active route for nested navigators - const currentRoute = useNavigationState((state) => { + const getCurrentRoute = () => { + const state = navigation.getState(); + if (!state) return { name: undefined, params: undefined }; let route: any = state.routes[state.index]; while (route.state?.index !== undefined) { route = route.state.routes[route.state.index]; } return { name: route.name, params: route.params }; - }); + }; const baseStyle: StyleProp = { display: "flex", @@ -71,12 +67,12 @@ export default function AQLink({ if (to.screen === "Login") { console.log( "AQLink intercepting login navigation, current route:", - currentRoute, + getCurrentRoute(), ); - openLoginModal(currentRoute as any); + openLoginModal(getCurrentRoute() as any); console.log( "AQLink login navigation intercepted, current route:", - currentRoute, + getCurrentRoute(), ); return; } @@ -87,7 +83,7 @@ export default function AQLink({ rootNav.navigate(to.screen, to.params); console.log( "AQLink root navigation intercepted, current route:", - currentRoute, + getCurrentRoute(), ); return; } @@ -95,7 +91,10 @@ export default function AQLink({ const converted = convertNavigationParams(to); // @ts-expect-error - dynamic navigation with LinkParams navigation.navigate(converted.screen, converted.params); - console.log("AQLink navigation intercepted, current route:", currentRoute); + console.log( + "AQLink navigation intercepted, current route:", + getCurrentRoute(), + ); }; // use Pressable with href on web to render as tag for copy/paste support diff --git a/js/app/components/mobile/chat.tsx b/js/app/components/mobile/chat.tsx index b6fa9ef8e..30b644e28 100644 --- a/js/app/components/mobile/chat.tsx +++ b/js/app/components/mobile/chat.tsx @@ -5,8 +5,6 @@ import { Resizable, StreamNotificationProvider, Text, - useHandle, - useLivestreamInfo, View, zero, } from "@streamplace/components"; @@ -143,9 +141,6 @@ export function MobileChatPanel({ isPlayerRatioGreater }) { } function ChatPanel() { - const { profile } = useLivestreamInfo(); - const handle = useHandle(); - let agent = usePDSAgent(); const navigation = useNavigation(); diff --git a/js/app/components/settings/settings.tsx b/js/app/components/settings/settings.tsx index f8c2df66a..c941a26a3 100644 --- a/js/app/components/settings/settings.tsx +++ b/js/app/components/settings/settings.tsx @@ -29,7 +29,6 @@ import { import { ScrollView } from "react-native"; import { LiquidGlassView } from "@callstack/liquid-glass"; -import { useNavigationState } from "@react-navigation/native"; import Mu from "components/mobile/desktop-ui/mu"; import { useStore } from "store"; import { useUserProfile } from "store/hooks"; @@ -41,15 +40,6 @@ export function Settings() { const danmuUnlocked = useDanmuUnlocked(); const openLoginModal = useStore((state) => state.openLoginModal); - // get the deepest active route for nested navigators - const currentRoute = useNavigationState((state) => { - let route: any = state.routes[state.index]; - while (route.state?.index !== undefined) { - route = route.state.routes[route.state.index]; - } - return { name: route.name, params: route.params }; - }); - const adminDids = useStreamplaceStore((state) => state.adminDIDs); const did = useDID(); diff --git a/js/components/src/components/ui/resizeable.tsx b/js/components/src/components/ui/resizeable.tsx index 1ca124ac3..9d9fdb306 100644 --- a/js/components/src/components/ui/resizeable.tsx +++ b/js/components/src/components/ui/resizeable.tsx @@ -13,6 +13,7 @@ import Animated, { useAnimatedStyle, useSharedValue, withSpring, + withTiming, } from "react-native-reanimated"; import { useSafeAreaInsets } from "react-native-safe-area-context"; import { useKeyboardSlide } from "../../hooks"; @@ -23,6 +24,11 @@ const AnimatedView = Animated.createAnimatedComponent(View); const { height: SCREEN_HEIGHT } = Dimensions.get("window"); +const TIMING_CONFIG = { + duration: 300, + easing: Easing.inOut(Easing.quad), +}; + type ResizableChatSheetProps = { startingPercentage?: number; isPlayerRatioGreater: boolean; @@ -31,8 +37,6 @@ type ResizableChatSheetProps = { renderAbove?: (isCollapsed: boolean) => React.ReactNode; }; -const SPRING_CONFIG = { damping: 20, stiffness: 100 }; - export function Resizable({ startingPercentage, isPlayerRatioGreater, @@ -56,7 +60,7 @@ export function Resizable({ const targetHeight = startingPercentage ? startingPercentage * SCREEN_HEIGHT : MIN_HEIGHT; - sheetHeight.value = withSpring(targetHeight, SPRING_CONFIG); + sheetHeight.value = withTiming(targetHeight, TIMING_CONFIG); setIsCollapsed(targetHeight < COLLAPSE_HEIGHT); }, 1000); }, []); @@ -73,7 +77,7 @@ export function Resizable({ const nowCollapsed = newHeight < COLLAPSE_HEIGHT; if (nowCollapsed && !wasCollapsed.value) { - sheetHeight.value = withSpring(MIN_HEIGHT, SPRING_CONFIG); + sheetHeight.value = withTiming(MIN_HEIGHT, SPRING_CONFIG); wasCollapsed.value = true; runOnJS(setIsCollapsed)(true); } else if (!nowCollapsed && wasCollapsed.value) { @@ -139,8 +143,8 @@ export function Resizable({ onPress={() => { const isCurrentlyCollapsed = sheetHeight.value === MIN_HEIGHT; sheetHeight.value = isCurrentlyCollapsed - ? withSpring(MAX_HEIGHT, SPRING_CONFIG) - : withSpring(MIN_HEIGHT, SPRING_CONFIG); + ? withTiming(MAX_HEIGHT, SPRING_CONFIG) + : withTiming(MIN_HEIGHT, SPRING_CONFIG); setIsCollapsed(!isCurrentlyCollapsed); }} > diff --git a/js/components/src/context/profile-cache.tsx b/js/components/src/context/profile-cache.tsx index 61d8688fe..a48dbff15 100644 --- a/js/components/src/context/profile-cache.tsx +++ b/js/components/src/context/profile-cache.tsx @@ -3,6 +3,7 @@ import { createContext, useCallback, useContext, + useMemo, useRef, useState, } from "react"; @@ -85,8 +86,13 @@ export function ProfileCacheProvider({ [flush], ); + const value = useMemo( + () => ({ profiles, requestProfiles }), + [profiles, requestProfiles], + ); + return ( - + {children} );