Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): unexpected editable state after trash page refresh #6433

Merged
merged 1 commit into from
Apr 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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(() => {
EYHN marked this conversation as resolved.
Show resolved Hide resolved
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
Loading