Skip to content

Commit

Permalink
Merge pull request #8633 from weseek/fix/140819-143352-editor-grant
Browse files Browse the repository at this point in the history
fix: Initialize grant correctly after when page transition
  • Loading branch information
yuki-takei committed Apr 15, 2024
2 parents 0c4c9f1 + efd7d47 commit 300b673
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions apps/app/src/client/services/page-operation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ import { SubscriptionStatusType } from '@growi/core';
import urljoin from 'url-join';

import { useEditingMarkdown, usePageTagsForEditors } from '~/stores/editor';
import { useCurrentPageId, useSWRMUTxCurrentPage, useSWRxTagsInfo } from '~/stores/page';
import {
useCurrentPageId, useSWRMUTxCurrentPage, useSWRxApplicableGrant, useSWRxTagsInfo,
useSWRxCurrentGrantData,
} from '~/stores/page';
import { useSetRemoteLatestPageData } from '~/stores/remote-latest-page';
import loggerFactory from '~/utils/logger';

Expand Down Expand Up @@ -99,6 +102,8 @@ export const useUpdateStateAfterSave = (pageId: string|undefined|null, opts?: Up
const { mutate: mutateTagsInfo } = useSWRxTagsInfo(pageId);
const { sync: syncTagsInfoForEditor } = usePageTagsForEditors(pageId);
const { mutate: mutateEditingMarkdown } = useEditingMarkdown();
const { mutate: mutateCurrentGrantData } = useSWRxCurrentGrantData(pageId);
const { mutate: mutateApplicableGrant } = useSWRxApplicableGrant(pageId);

// update swr 'currentPageId', 'currentPage', remote states
return useCallback(async() => {
Expand All @@ -121,6 +126,9 @@ export const useUpdateStateAfterSave = (pageId: string|undefined|null, opts?: Up
mutateEditingMarkdown(updatedPage.revision.body);
}

mutateCurrentGrantData();
mutateApplicableGrant();

const remoterevisionData = {
remoteRevisionId: updatedPage.revision._id,
remoteRevisionBody: updatedPage.revision.body,
Expand All @@ -131,7 +139,7 @@ export const useUpdateStateAfterSave = (pageId: string|undefined|null, opts?: Up
setRemoteLatestPageData(remoterevisionData);
},
// eslint-disable-next-line max-len
[pageId, mutateTagsInfo, syncTagsInfoForEditor, mutateCurrentPageId, mutateCurrentPage, opts?.supressEditingMarkdownMutation, setRemoteLatestPageData, mutateEditingMarkdown]);
[pageId, mutateTagsInfo, syncTagsInfoForEditor, mutateCurrentPageId, mutateCurrentPage, opts?.supressEditingMarkdownMutation, mutateCurrentGrantData, mutateApplicableGrant, setRemoteLatestPageData, mutateEditingMarkdown]);
};

export const unlink = async(path: string): Promise<void> => {
Expand Down

0 comments on commit 300b673

Please sign in to comment.