diff --git a/package-lock.json b/package-lock.json index 2c3dedb9..9e4f0117 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "1.0.0-dev.103", "license": "AGPL-3.0-only", "dependencies": { - "@powerhousedao/design-system": "^1.0.0-alpha.167", + "@powerhousedao/design-system": "^1.0.0-alpha.168", "@sentry/react": "^7.109.0", "@sentry/vite-plugin": "^2.22.2", "@tanstack/react-virtual": "^3.8.1", @@ -6566,9 +6566,9 @@ } }, "node_modules/@powerhousedao/design-system": { - "version": "1.0.0-alpha.167", - "resolved": "https://registry.npmjs.org/@powerhousedao/design-system/-/design-system-1.0.0-alpha.167.tgz", - "integrity": "sha512-yWXV4MXvUJN/BbuxhtPEqpx0QXgJ8a8ys4C2zN65uoeLVOqMG5HcdOtMqm84fXd5eOYcKrIfAsH1UB6JkZP2PA==", + "version": "1.0.0-alpha.168", + "resolved": "https://registry.npmjs.org/@powerhousedao/design-system/-/design-system-1.0.0-alpha.168.tgz", + "integrity": "sha512-z3mmuvyjJAjj2ztj/YWY/TbGDBxwHbDkVgIPvsaZxMTrpO6l3fwU8Urj85EP7ZPF4xyefEQ9S1oFlCNFskRXlw==", "dependencies": { "@internationalized/date": "^3.5.1", "@radix-ui/react-dialog": "^1.0.5", diff --git a/package.json b/package.json index 6792e9f7..5cdcbbac 100644 --- a/package.json +++ b/package.json @@ -90,7 +90,7 @@ "xvfb-maybe": "^0.2.1" }, "dependencies": { - "@powerhousedao/design-system": "^1.0.0-alpha.167", + "@powerhousedao/design-system": "^1.0.0-alpha.168", "@sentry/react": "^7.109.0", "@sentry/vite-plugin": "^2.22.2", "@tanstack/react-virtual": "^3.8.1", diff --git a/src/components/editor-loader.tsx b/src/components/editor-loader.tsx index 60940f74..227cb2e4 100644 --- a/src/components/editor-loader.tsx +++ b/src/components/editor-loader.tsx @@ -1,13 +1,25 @@ import { DefaultEditorLoader } from '@powerhousedao/design-system'; -import { ReactNode } from 'react'; +import { ComponentProps, ReactNode, useEffect, useState } from 'react'; -type Props = { +type Props = ComponentProps & { + loadingTimeout?: number; customEditorLoader?: ReactNode; }; export function EditorLoader(props: Props) { - const { customEditorLoader } = props; + const [showLoading, setShowLoading] = useState(false); + + // only shows the loader after some time has passed + useEffect(() => { + setTimeout(() => { + setShowLoading(true); + }, props.loadingTimeout ?? 200); + }, [props]); + + if (!showLoading) return null; + + const { customEditorLoader, ...defaultProps } = props; if (customEditorLoader) return <>{customEditorLoader}; - return ; + return ; } diff --git a/src/components/editors.tsx b/src/components/editors.tsx index d127fc69..15a8e95c 100644 --- a/src/components/editors.tsx +++ b/src/components/editors.tsx @@ -75,7 +75,7 @@ export function DocumentEditor(props: EditorProps) { initialDocument, ); const context: EditorContext = useMemo( - () => ({ theme, user: user }), + () => ({ theme, user }), [theme, user], ); const userPermissions = useUserPermissions(); @@ -151,7 +151,10 @@ export function DocumentEditor(props: EditorProps) { } if (isLoadingDocument || isLoadingEditor) { - return ; + const message = isLoadingDocument + ? 'Loading document' + : 'Loading editor'; + return ; } if (selectedNode?.kind !== FILE) { @@ -159,12 +162,7 @@ export function DocumentEditor(props: EditorProps) { } if (!documentModel) { - return ( -

- Document of type {fileNodeDocument?.documentType} is not - supported. -

- ); + return

Document of type {documentType} is not supported.

; } if (!editor) { diff --git a/src/hooks/useDocumentDriveServer.ts b/src/hooks/useDocumentDriveServer.ts index 8053cc01..f7aefcc5 100644 --- a/src/hooks/useDocumentDriveServer.ts +++ b/src/hooks/useDocumentDriveServer.ts @@ -512,8 +512,8 @@ export function useDocumentDriveServer( ); const deleteDrive = useCallback( - async (id: string, force = false) => { - if (!force && !isAllowedToCreateDocuments) { + async (id: string) => { + if (!isAllowedToCreateDocuments) { throw new Error('User is not allowed to delete drives'); } if (!server) {