chore: update inbox props

This commit is contained in:
Steven 2024-02-14 09:44:35 +08:00
parent 4aa4417d91
commit f1ec5775a7
4 changed files with 31 additions and 28 deletions

View file

@ -57,20 +57,20 @@ const DisablePasswordLoginDialog: React.FC<Props> = ({ destroy }: Props) => {
return (
<>
<div className="dialog-header-container !w-64">
<div className="dialog-header-container">
<p className="title-text">{t("setting.system-section.disable-password-login")}</p>
<IconButton size="sm" onClick={handleCloseBtnClick}>
<Icon.X className="w-5 h-auto" />
</IconButton>
</div>
<div className="dialog-content-container !w-64">
<div className="dialog-content-container !w-72">
{confirmedOnce ? (
<>
<p className="content-text">{t("setting.system-section.disable-password-login-final-warning")}</p>
<Input value={typingConfirmation} onChange={handleTypingConfirmationChanged} />
<p className="">{t("setting.system-section.disable-password-login-final-warning")}</p>
<Input className="w-full mt-2" value={typingConfirmation} onChange={handleTypingConfirmationChanged} />
</>
) : (
<p className="content-text">{t("setting.system-section.disable-password-login-warning")}</p>
<p className="">{t("setting.system-section.disable-password-login-warning")}</p>
)}
<div className="mt-4 w-full flex flex-row justify-end items-center space-x-2">
<Button variant="plain" color="neutral" onClick={handleCloseBtnClick}>

View file

@ -5,8 +5,8 @@ import toast from "react-hot-toast";
import { activityServiceClient } from "@/grpcweb";
import useNavigateTo from "@/hooks/useNavigateTo";
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 { Memo } from "@/types/proto/api/v2/memo_service";
import { useTranslate } from "@/utils/i18n";
import Icon from "../Icon";
@ -19,35 +19,35 @@ const MemoCommentMessage = ({ inbox }: Props) => {
const navigateTo = useNavigateTo();
const inboxStore = useInboxStore();
const memoStore = useMemoStore();
const [activity, setActivity] = useState<Activity | undefined>(undefined);
const [relatedMemo, setRelatedMemo] = useState<Memo | undefined>(undefined);
useEffect(() => {
if (!inbox.activityId) {
return;
}
activityServiceClient
.getActivity({
(async () => {
const { activity } = await activityServiceClient.getActivity({
id: inbox.activityId,
})
.then(({ activity }) => {
setActivity(activity);
});
if (!activity) {
return;
}
if (activity.payload?.memoComment?.relatedMemoId) {
const memo = await memoStore.getOrFetchMemoById(activity.payload?.memoComment?.relatedMemoId, {
skipStore: true,
});
setRelatedMemo(memo);
}
})();
}, [inbox.activityId]);
const handleNavigateToMemo = async () => {
const relatedMemoId = activity?.payload?.memoComment?.relatedMemoId;
if (!relatedMemoId) {
if (!relatedMemo) {
return;
}
const memo = await memoStore.getOrFetchMemoById(relatedMemoId);
if (!memo) {
toast.error("Memo not found");
return;
}
navigateTo(`/m/${memo.name}`);
navigateTo(`/m/${relatedMemo.name}`);
if (inbox.status === Inbox_Status.UNREAD) {
handleArchiveMessage(true);
}
@ -105,7 +105,7 @@ const MemoCommentMessage = ({ inbox }: Props) => {
>
{t("inbox.memo-comment", {
user: extractUsernameFromName(inbox.sender),
memo: `memo#${activity?.payload?.memoComment?.relatedMemoId}`,
memo: `memos#${relatedMemo?.name}`,
})}
</p>
</div>

View file

@ -23,13 +23,16 @@ const VersionUpdateMessage = ({ inbox }: Props) => {
return;
}
activityServiceClient
.getActivity({
(async () => {
const { activity } = await activityServiceClient.getActivity({
id: inbox.activityId,
})
.then(({ activity }) => {
setActivity(activity);
});
if (!activity) {
return;
}
setActivity(activity);
})();
}, [inbox.activityId]);
const handleNavigate = () => {

View file

@ -70,7 +70,7 @@ const Home = () => {
<div className={classNames("w-full flex flex-row justify-start items-start px-4 sm:px-6 gap-4")}>
<div className={classNames(md ? "w-[calc(100%-15rem)]" : "w-full")}>
<MemoEditor className="mb-2" cacheKey="home-memo-editor" />
<div className="flex flex-col justify-start items-start w-full max-w-full pb-28">
<div className="flex flex-col justify-start items-start w-full max-w-full">
<MemoFilter className="px-2 pb-2" />
{sortedMemos.map((memo) => (
<MemoView key={`${memo.id}-${memo.updateTime}`} memo={memo} showVisibility showPinned />