ryoji-s 2 лет назад
Родитель
Сommit
5678fa9d85

+ 3 - 3
apps/app/src/components/PageEditor/PageEditor.tsx

@@ -5,7 +5,7 @@ import React, {
 import type EventEmitter from 'events';
 import nodePath from 'path';
 
-import type { IPageHasId, IUser } from '@growi/core';
+import type { IPageHasId, IUser, IUserHasId } from '@growi/core';
 import { useGlobalSocket } from '@growi/core/dist/swr';
 import { pathUtils } from '@growi/core/dist/utils';
 import {
@@ -165,7 +165,7 @@ export const PageEditor = React.memo((props: Props): JSX.Element => {
     initialValueRef.current = initialValue;
   }, [initialValue]);
 
-  const [userList, setUserList] = useState<IUser[]>([]);
+  const [userList, setUserList] = useState<IUserHasId[]>([]);
   const [markdownToPreview, setMarkdownToPreview] = useState<string>(initialValue);
   const setMarkdownPreviewWithDebounce = useMemo(() => debounce(100, throttle(150, (value: string) => {
     setMarkdownToPreview(value);
@@ -463,7 +463,7 @@ export const PageEditor = React.memo((props: Props): JSX.Element => {
             acceptedFileType={acceptedFileType}
             onScroll={scrollEditorHandlerThrottle}
             indentSize={currentIndentSize ?? defaultIndentSize}
-            user={user}
+            user={user ?? undefined}
             pageId={pageId ?? undefined}
             initialValue={initialValue}
             onOpenEditor={markdown => setMarkdownToPreview(markdown)}

+ 2 - 2
apps/app/src/components/PageHeader/PageHeader.tsx

@@ -1,6 +1,6 @@
 import type { FC } from 'react';
 
-import type { IUser } from '@growi/core';
+import type { IUserHasId } from '@growi/core';
 import { DevidedPagePath } from '@growi/core/dist/models';
 
 import { useSWRxCurrentPage } from '~/stores/page';
@@ -14,7 +14,7 @@ import styles from './PageHeader.module.scss';
 const moduleClass = styles['page-header'] ?? '';
 
 type Props = {
-  userList: IUser[]
+  userList: IUserHasId[]
 }
 
 export const PageHeader: FC<Props> = (props) => {

+ 2 - 2
apps/app/src/components/PageHeader/UserList.tsx

@@ -1,11 +1,11 @@
 import type { FC } from 'react';
 
-import type { IUser } from '@growi/core';
+import type { IUserHasId } from '@growi/core';
 import { UserPicture } from '@growi/ui/dist/components';
 
 type Props = {
   className: string,
-  userList: IUser[]
+  userList: IUserHasId[]
 }
 
 export const UserList: FC<Props> = (props) => {

+ 3 - 3
packages/editor/src/components/CodeMirrorEditorMain.tsx

@@ -2,7 +2,7 @@ import { useEffect } from 'react';
 
 import { type Extension } from '@codemirror/state';
 import { keymap, scrollPastEnd } from '@codemirror/view';
-import { IUser } from '@growi/core/dist/interfaces';
+import type { IUserHasId } from '@growi/core/dist/interfaces';
 
 import { GlobalCodeMirrorEditorKey, AcceptedUploadFileType } from '../consts';
 import { setDataLine } from '../services/extensions/setDataLine';
@@ -24,11 +24,11 @@ type Props = {
   onScroll?: () => void,
   acceptedFileType?: AcceptedUploadFileType,
   indentSize?: number,
-  user?: IUser
+  user?: IUserHasId
   pageId?: string,
   initialValue?: string,
   onOpenEditor?: (markdown: string) => void,
-  onUserList?: (userList: any[]) => void,
+  onUserList?: (userList: IUserHasId[]) => void,
   editorTheme?: string,
   editorKeymap?: string,
 }

+ 5 - 5
packages/editor/src/stores/use-collaborative-editor-mode.ts

@@ -1,6 +1,6 @@
 import { useEffect, useState } from 'react';
 
-import { GlobalSocketEventName, IUser } from '@growi/core/dist/interfaces';
+import { GlobalSocketEventName, type IUserHasId } from '@growi/core/dist/interfaces';
 import { useGlobalSocket, GLOBAL_SOCKET_NS } from '@growi/core/dist/swr';
 // see: https://github.com/yjs/y-codemirror.next#example
 // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -14,17 +14,17 @@ import { UseCodeMirrorEditor } from '../services';
 
 type UserLocalState = {
   name: string;
-  user?: IUser;
+  user?: IUserHasId;
   color: string;
   colorLight: string;
 }
 
 export const useCollaborativeEditorMode = (
-    user?: IUser,
+    user?: IUserHasId,
     pageId?: string,
     initialValue?: string,
     onOpenEditor?: (markdown: string) => void,
-    onUserList?: (userList: IUser[]) => void,
+    onUserList?: (userList: IUserHasId[]) => void,
     codeMirrorEditor?: UseCodeMirrorEditor,
 ): void => {
   const [ydoc, setYdoc] = useState<Y.Doc | null>(null);
@@ -99,7 +99,7 @@ export const useCollaborativeEditorMode = (
       if (onUserList) {
         const { added, removed } = update;
         if (added.length > 0 || removed.length > 0) {
-          const userList: IUser[] = Array.from(socketIOProvider.awareness.states.values(), value => value.user.user && value.user.user);
+          const userList: IUserHasId[] = Array.from(socketIOProvider.awareness.states.values(), value => value.user.user && value.user.user);
           onUserList(userList);
         }
       }