Shun Miyazawa 1 год назад
Родитель
Сommit
b30c35aaf3

+ 0 - 8
apps/app/src/interfaces/page.ts

@@ -75,11 +75,3 @@ export type IOptionsForCreate = {
   origin?: Origin
   wip?: boolean,
 };
-
-export type CurrentPageYjsDraft = {
-  hasYjsDraft: boolean,
-}
-
-export const CurrentPageYjsDraftData = {
-  hasYjsDraft: { hasYjsDraft: true },
-};

+ 1 - 1
apps/app/src/interfaces/websocket.ts

@@ -50,7 +50,7 @@ export const SocketEventName = {
   PageDeleted: 'page:delete',
 
   // Yjs
-  YjsUpdated: 'yjsDraft:update',
+  YjsDraftUpdated: 'yjs:draft-update',
   YjsAwarenessStateUpdated: 'yjs:awareness-state-update',
 } as const;
 export type SocketEventName = typeof SocketEventName[keyof typeof SocketEventName];

+ 2 - 2
apps/app/src/server/service/socket-io.js

@@ -1,7 +1,7 @@
 import { GlobalSocketEventName } from '@growi/core/dist/interfaces';
 import { Server } from 'socket.io';
 
-import { CurrentPageYjsDraftData } from '~/interfaces/page';
+// import { CurrentPageYjsDraftData } from '~/interfaces/page';
 import { SocketEventName } from '~/interfaces/websocket';
 import loggerFactory from '~/utils/logger';
 
@@ -175,7 +175,7 @@ class SocketIoService {
         // Emit to the client in the room of the target pageId.
         this.io
           .in(getRoomNameWithId(RoomPrefix.PAGE, pageId))
-          .emit(SocketEventName.YjsUpdated, CurrentPageYjsDraftData.hasYjsDraft);
+          .emit(SocketEventName.YjsDraftUpdated, true);
 
         yjsConnectionManager.ysocketio.on('awareness-update', async(update) => {
           const awarenessStateSize = update.awareness.states.size;

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

@@ -18,7 +18,6 @@ import useSWRMutation, { type SWRMutationResponse } from 'swr/mutation';
 
 import { apiGet } from '~/client/util/apiv1-client';
 import { apiv3Get } from '~/client/util/apiv3-client';
-import type { CurrentPageYjsDraft } from '~/interfaces/page';
 import type { IRecordApplicableGrant, IResIsGrantNormalized } from '~/interfaces/page-grant';
 import type { AxiosResponse } from '~/utils/axios';
 
@@ -54,14 +53,6 @@ export const useTemplateBodyData = (initialData?: string): SWRResponse<string, E
   return useSWRStatic<string, Error>('templateBodyData', initialData);
 };
 
-export const useCurrentPageYjsDraft = (initialData?: CurrentPageYjsDraft): SWRResponse<CurrentPageYjsDraft, Error> => {
-  return useSWRStatic<CurrentPageYjsDraft, Error>('currentPageYjsDraft', initialData);
-};
-
-export const useCurrentPageYjsAwarenessStateSize = (initialData?: number): SWRResponse<number, Error> => {
-  return useSWRStatic<number, Error>('currentPageYjsAwarenessStateSize', initialData);
-};
-
 /** "useSWRxCurrentPage" is intended for initial data retrieval only. Use "useSWRMUTxCurrentPage" for revalidation */
 export const useSWRxCurrentPage = (initialData?: IPagePopulatedToShowRevision|null): SWRResponse<IPagePopulatedToShowRevision|null> => {
   const key = 'currentPage';