refactor(chat): show images in page overlay

This commit is contained in:
2026-07-09 10:11:25 +08:00
parent cb7791dd8d
commit fc92c3a5d5
23 changed files with 253 additions and 627 deletions
+4 -1
View File
@@ -16,10 +16,13 @@ describe("route meta", () => {
});
it("classifies known dynamic chat routes", () => {
expect(getRouteAccess("/chat/image/msg_1")).toBe("session");
expect(getRouteAccess("/chat/deviceid/device_1")).toBe("public");
});
it("does not keep the removed chat image route as a guarded route", () => {
expect(getRouteAccess("/chat/image/msg_1")).toBe("public");
});
it("includes private room in static routes", () => {
expect(ALL_STATIC_ROUTES).toContain(ROUTES.privateRoom);
});
-1
View File
@@ -20,7 +20,6 @@ const STATIC_ROUTE_ACCESS: Partial<Record<string, RouteAccess>> = {
};
export function getRouteAccess(pathname: string): RouteAccess {
if (pathname.startsWith("/chat/image/")) return "session";
if (pathname.startsWith("/chat/deviceid/")) return "public";
return STATIC_ROUTE_ACCESS[pathname] ?? "public";
}
+1 -4
View File
@@ -35,8 +35,6 @@ export type StaticRoute = (typeof ROUTES)[keyof typeof ROUTES];
export const ROUTE_BUILDERS = {
chatDeviceId: (deviceId: string): `/chat/deviceid/${string}` =>
`/chat/deviceid/${encodeURIComponent(deviceId)}` as const,
chatImage: (messageId: string): `/chat/image/${string}` =>
`/chat/image/${encodeURIComponent(messageId)}` as const,
subscription: (
type: "vip" | "topup",
options: { payChannel?: PayChannel; returnTo?: "chat" } = {},
@@ -64,5 +62,4 @@ export const ALL_STATIC_ROUTES: readonly StaticRoute[] = [
/** 联合路由类型,包含静态路由与已知动态路由 */
export type Route =
| StaticRoute
| `/chat/deviceid/${string}`
| `/chat/image/${string}`;
| `/chat/deviceid/${string}`;
-7
View File
@@ -34,7 +34,6 @@ export interface AppNavigator {
back: () => void;
openAuth: (redirectTo?: string) => void;
openChat: (options?: { replace?: boolean; scroll?: boolean }) => void;
openChatImage: (messageId: string) => void;
openSubscription: (input: OpenSubscriptionInput) => void;
exitSubscription: (returnTo: SubscriptionReturnTo) => void;
exitSubscriptionAfterSuccess: (returnTo: SubscriptionReturnTo) => void;
@@ -77,10 +76,6 @@ export function useAppNavigator(): AppNavigator {
router.push(ROUTES.chat, navOptions);
}, [router]);
const openChatImage = useCallback((messageId: string): void => {
router.push(ROUTE_BUILDERS.chatImage(messageId), { scroll: false });
}, [router]);
const getDefaultPayChannel = useCallback(() => {
return getDefaultPayChannelForCountryCode(userState.currentUser?.countryCode);
}, [userState.currentUser?.countryCode]);
@@ -185,7 +180,6 @@ export function useAppNavigator(): AppNavigator {
back,
openAuth,
openChat,
openChatImage,
openSubscription,
exitSubscription,
exitSubscriptionAfterSuccess,
@@ -201,7 +195,6 @@ export function useAppNavigator(): AppNavigator {
isAuthenticatedUser,
openAuth,
openChat,
openChatImage,
openSubscription,
openSubscriptionForPendingUnlock,
push,