Skip to content

Commit

Permalink
Merge of #9086
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Sep 11, 2024
2 parents a4dae48 + aa2a343 commit d7a8be6
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions apps/app/src/stores/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,14 @@ export const useTemplateBodyData = (initialData?: string): SWRResponse<string, E
export const useSWRxCurrentPage = (initialData?: IPagePopulatedToShowRevision|null): SWRResponse<IPagePopulatedToShowRevision|null> => {
const key = 'currentPage';

const { data: isLatestRevision } = useIsLatestRevision();

const { cache } = useSWRConfig();

// Problem 1: https://github.com/weseek/growi/pull/7772/files#diff-4c1708c4f959974166c15435c6b35950ba01bbf35e7e4b8e99efeb125a8000a7
// Problem 2: https://redmine.weseek.co.jp/issues/141027
// Problem 3: https://redmine.weseek.co.jp/issues/153618
// Problem 4: https://redmine.weseek.co.jp/issues/153759
const shouldMutate = (() => {
if (initialData === undefined) {
return false;
Expand All @@ -81,8 +85,11 @@ export const useSWRxCurrentPage = (initialData?: IPagePopulatedToShowRevision|nu
return true;
}

// mutate When a different revision is opened
if (cachedData.revision?._id != null && initialData.revision?._id != null && cachedData.revision._id !== initialData.revision._id) {
// mutate when opening a previous revision.
if (!isLatestRevision
&& cachedData.revision?._id != null && initialData.revision?._id != null
&& cachedData.revision._id !== initialData.revision._id
) {
return true;
}

Expand Down

0 comments on commit d7a8be6

Please sign in to comment.