Skip to content

Commit

Permalink
fix(core): unexpected editable state after trash page refresh (#6433)
Browse files Browse the repository at this point in the history
close TOV-772
  • Loading branch information
JimmFly committed Apr 1, 2024
1 parent 2631b41 commit 62d9b0c
Showing 1 changed file with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,6 @@ const DetailPageImpl = memo(function DetailPageImpl() {
export const DetailPage = ({ pageId }: { pageId: string }): ReactElement => {
const currentWorkspace = useService(Workspace);
const pageRecordList = useService(PageRecordList);

const pageListReady = useLiveData(pageRecordList.isReady$);

const pageRecords = useLiveData(pageRecordList.records$);
Expand All @@ -286,7 +285,6 @@ export const DetailPage = ({ pageId }: { pageId: string }): ReactElement => {
() => pageRecords.find(page => page.id === pageId),
[pageRecords, pageId]
);

const pageManager = useService(PageManager);

const [page, setPage] = useState<Doc | null>(null);
Expand Down Expand Up @@ -318,6 +316,19 @@ export const DetailPage = ({ pageId }: { pageId: string }): ReactElement => {
}
}, [jumpOnce, pageRecord]);

useEffect(() => {
if (page && pageRecord?.meta?.trash) {
currentWorkspace.docCollection.awarenessStore.setReadonly(
page.blockSuiteDoc,
true
);
}
}, [
currentWorkspace.docCollection.awarenessStore,
page,
pageRecord?.meta?.trash,
]);

// if sync engine has been synced and the page is null, show 404 page.
if (pageListReady && !page) {
return <PageNotFound />;
Expand Down

0 comments on commit 62d9b0c

Please sign in to comment.