mirror of
https://github.com/docmost/docmost.git
synced 2026-05-18 15:34:05 +08:00
5506eb194b
* Show actual history changes * V2 - WIP * feat: page history diff * fix: exclude content from history listing --------- Co-authored-by: Jason Norwood-Young <jason@10layer.com>
46 lines
1.2 KiB
TypeScript
46 lines
1.2 KiB
TypeScript
import { usePageHistoryQuery } from "@/features/page-history/queries/page-history-query";
|
|
import { HistoryEditor } from "@/features/page-history/components/history-editor";
|
|
import { useTranslation } from "react-i18next";
|
|
import { useAtomValue } from "jotai";
|
|
import {
|
|
activeHistoryIdAtom,
|
|
activeHistoryPrevIdAtom,
|
|
} from "@/features/page-history/atoms/history-atoms";
|
|
|
|
function HistoryView() {
|
|
const { t } = useTranslation();
|
|
const historyId = useAtomValue(activeHistoryIdAtom);
|
|
const prevHistoryId = useAtomValue(activeHistoryPrevIdAtom);
|
|
|
|
const {
|
|
data,
|
|
isLoading: isLoadingCurrent,
|
|
isError: isErrorCurrent,
|
|
} = usePageHistoryQuery(historyId);
|
|
const {
|
|
data: prevData,
|
|
isLoading: isLoadingPrev,
|
|
isError: isErrorPrev,
|
|
} = usePageHistoryQuery(prevHistoryId);
|
|
|
|
if (isLoadingCurrent || isLoadingPrev) {
|
|
return <></>;
|
|
}
|
|
|
|
if (isErrorCurrent || !data) {
|
|
return <div>{t("Error fetching page data.")}</div>;
|
|
}
|
|
|
|
return (
|
|
<div>
|
|
<HistoryEditor
|
|
content={data.content}
|
|
title={data.title}
|
|
previousContent={!isErrorPrev ? prevData?.content : undefined}
|
|
/>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
export default HistoryView;
|