Browse Source

create useUntitledPage hooks with SWR

WNomunomu 2 years ago
parent
commit
3a7dcb6353
1 changed files with 16 additions and 0 deletions
  1. 16 0
      apps/app/src/stores/page.tsx

+ 16 - 0
apps/app/src/stores/page.tsx

@@ -239,6 +239,22 @@ export const useSWRxPageRevision = (pageId: string, revisionId: Ref<IRevision>):
   );
   );
 };
 };
 
 
+export const useUntitledPage = (pageId: string): SWRResponse<boolean> => {
+
+  const key = `untitled/${pageId}`;
+
+  return useSWR(key, null);
+
+};
+
+export const mutateUntitledPage = (pageId: string, isUntitledPage: boolean): void => {
+
+  const key = `untitled/${pageId}`;
+
+  mutate(key, isUntitledPage);
+
+};
+
 /*
 /*
  * SWR Infinite for page revision list
  * SWR Infinite for page revision list
  */
  */