refactor(router): centralize app route transitions
This commit is contained in:
@@ -9,10 +9,9 @@
|
||||
* - 错误占位符(broken image icon)
|
||||
*/
|
||||
import Image from "next/image";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
|
||||
import { ROUTE_BUILDERS } from "@/router/routes";
|
||||
import { useAppNavigator } from "@/router/use-app-navigator";
|
||||
import {
|
||||
isBrowserLocalChatImageSource,
|
||||
normalizeChatImageSource,
|
||||
@@ -33,7 +32,7 @@ export function ImageBubble({
|
||||
imageUrl,
|
||||
imagePaywalled = false,
|
||||
}: ImageBubbleProps) {
|
||||
const router = useRouter();
|
||||
const navigator = useAppNavigator();
|
||||
const [errorSrc, setErrorSrc] = useState<string | null>(null);
|
||||
const { mediaUrl, isUsingCachedMedia, reportMediaError } =
|
||||
useCachedChatMediaUrl({
|
||||
@@ -58,7 +57,7 @@ export function ImageBubble({
|
||||
const openImage = () => {
|
||||
if (!messageId) return;
|
||||
requestChatScrollSnapshotSave(messageId);
|
||||
router.push(ROUTE_BUILDERS.chatImage(messageId), { scroll: false });
|
||||
navigator.openChatImage(messageId);
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user