mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
chore: migrate memo route
This commit is contained in:
@ -4,7 +4,7 @@ import { useEffect, useState } from "react";
|
||||
import toast from "react-hot-toast";
|
||||
import { activityServiceClient } from "@/grpcweb";
|
||||
import useNavigateTo from "@/hooks/useNavigateTo";
|
||||
import { useInboxStore, extractUsernameFromName } from "@/store/v1";
|
||||
import { useInboxStore, extractUsernameFromName, useMemoStore } from "@/store/v1";
|
||||
import { Activity } from "@/types/proto/api/v2/activity_service";
|
||||
import { Inbox, Inbox_Status } from "@/types/proto/api/v2/inbox_service";
|
||||
import { useTranslate } from "@/utils/i18n";
|
||||
@ -18,6 +18,7 @@ const MemoCommentMessage = ({ inbox }: Props) => {
|
||||
const t = useTranslate();
|
||||
const navigateTo = useNavigateTo();
|
||||
const inboxStore = useInboxStore();
|
||||
const memoStore = useMemoStore();
|
||||
const [activity, setActivity] = useState<Activity | undefined>(undefined);
|
||||
|
||||
useEffect(() => {
|
||||
@ -34,11 +35,19 @@ const MemoCommentMessage = ({ inbox }: Props) => {
|
||||
});
|
||||
}, [inbox.activityId]);
|
||||
|
||||
const handleNavigateToMemo = () => {
|
||||
if (!activity?.payload?.memoComment?.relatedMemoId) {
|
||||
const handleNavigateToMemo = async () => {
|
||||
const relatedMemoId = activity?.payload?.memoComment?.relatedMemoId;
|
||||
if (!relatedMemoId) {
|
||||
return;
|
||||
}
|
||||
navigateTo(`/m/${activity?.payload?.memoComment?.relatedMemoId}`);
|
||||
|
||||
const memo = await memoStore.getOrFetchMemoById(relatedMemoId);
|
||||
if (!memo) {
|
||||
toast.error("Memo not found");
|
||||
return;
|
||||
}
|
||||
|
||||
navigateTo(`/m/${memo.name}`);
|
||||
if (inbox.status === Inbox_Status.UNREAD) {
|
||||
handleArchiveMessage(true);
|
||||
}
|
||||
|
Reference in New Issue
Block a user