From a05b387ee11ba2d75f5dcddcc0a00ad6fd4ef95e Mon Sep 17 00:00:00 2001 From: Tilman Vatteroth Date: Sun, 26 Mar 2023 10:27:57 +0200 Subject: [PATCH] nullable note details Signed-off-by: Tilman Vatteroth --- .../document-infobar.tsx | 4 ++-- .../components/editor-page/app-bar/app-bar.tsx | 7 ++++--- .../app-bar/read-only-mode-button.tsx | 4 ++-- .../editor-page/app-bar/slide-mode-button.tsx | 4 ++-- .../document-bar/aliases/aliases-add-form.tsx | 4 ++-- .../document-bar/aliases/aliases-list.tsx | 5 ++--- .../note-info/note-info-line-contributors.tsx | 4 ++-- .../note-info/note-info-line-created.tsx | 4 ++-- .../note-info/note-info-line-updated.tsx | 6 +++--- .../permission-entry-special-group.tsx | 8 +++----- .../permissions/permission-entry-user.tsx | 4 ++-- .../permissions/permission-owner-info.tsx | 4 ++-- .../permissions/permission-section-owner.tsx | 4 ++-- .../permission-section-special-groups.tsx | 4 ++-- .../permissions/permission-section-users.tsx | 6 +++--- .../document-bar/revisions/revision-list.tsx | 4 ++-- .../revisions/revision-modal-footer.tsx | 4 ++-- .../document-bar/revisions/revision-viewer.tsx | 4 ++-- .../document-bar/share/note-url-field.tsx | 4 ++-- .../document-bar/share/share-modal.tsx | 4 ++-- .../editor-document-renderer.tsx | 4 ++-- .../hooks/use-on-scroll-with-line-offset.ts | 5 ++--- .../use-scroll-state-without-line-offset.ts | 4 ++-- .../use-on-image-upload-from-renderer.ts | 5 ++++- .../editor-pane/hooks/use-handle-upload.tsx | 7 +++++-- .../hooks/use-line-based-position.ts | 10 +++++----- .../hooks/yjs/use-on-note-deleted.ts | 4 ++-- .../hooks/yjs/use-realtime-connection.ts | 2 +- .../editor-pane/hooks/yjs/use-websocket-url.ts | 4 ++-- .../number-of-lines-in-document-info.tsx | 4 ++-- .../status-bar/remaining-characters-info.tsx | 4 ++-- .../status-bar/selected-characters.tsx | 4 ++-- .../head-meta-properties/license-link-head.tsx | 4 ++-- .../head-meta-properties/opengraph-head.tsx | 4 ++-- .../hooks/use-update-local-history-entry.ts | 7 ++++--- ...end-additional-configuration-to-renderer.ts | 3 ++- .../delete-note-modal.tsx | 4 ++-- .../delete-note-sidebar-entry.tsx | 4 ++-- .../export-markdown-sidebar-entry.tsx | 6 +++++- .../pin-note-sidebar-entry.tsx | 3 ++- .../slide-show-page-content.tsx | 3 ++- .../task-list/set-checkbox-in-editor.tsx | 8 ++++++-- frontend/src/hooks/common/use-is-owner.ts | 3 ++- frontend/src/hooks/common/use-may-edit.ts | 3 ++- frontend/src/hooks/common/use-note-details.ts | 17 +++++++++++++++++ .../hooks/common/use-note-markdown-content.ts | 4 ++-- frontend/src/hooks/common/use-note-title.ts | 4 ++-- ...ote-markdown-content-without-frontmatter.ts | 18 ++++++++---------- frontend/src/redux/application-state.d.ts | 4 ++-- ...uild-state-from-updated-markdown-content.ts | 9 ++++++++- frontend/src/redux/note-details/methods.ts | 6 +++++- frontend/src/redux/note-details/reducer.ts | 8 +++----- .../build-state-from-first-heading-update.ts | 10 ++++++++-- .../build-state-from-metadata-update.ts | 10 ++++++++-- .../build-state-from-server-permissions.ts | 9 ++++++--- ...ild-state-from-set-note-data-from-server.ts | 6 +++++- .../build-state-from-update-cursor-position.ts | 10 ++++++++-- frontend/src/redux/note-details/types.ts | 3 +++ 58 files changed, 194 insertions(+), 125 deletions(-) create mode 100644 frontend/src/hooks/common/use-note-details.ts diff --git a/frontend/src/components/document-read-only-page/document-infobar.tsx b/frontend/src/components/document-read-only-page/document-infobar.tsx index d3822e5ad..aa49c4fe0 100644 --- a/frontend/src/components/document-read-only-page/document-infobar.tsx +++ b/frontend/src/components/document-read-only-page/document-infobar.tsx @@ -3,7 +3,7 @@ * * SPDX-License-Identifier: AGPL-3.0-only */ -import { useApplicationState } from '../../hooks/common/use-application-state' +import { useNoteDetails } from '../../hooks/common/use-note-details' import { InternalLink } from '../common/links/internal-link' import { ShowIf } from '../common/show-if/show-if' import { NoteInfoLineCreated } from '../editor-page/document-bar/note-info/note-info-line-created' @@ -18,7 +18,7 @@ import { Trans, useTranslation } from 'react-i18next' */ export const DocumentInfobar: React.FC = () => { const { t } = useTranslation() - const noteDetails = useApplicationState((state) => state.noteDetails) + const noteDetails = useNoteDetails() // TODO Check permissions ("writability") of note and show edit link depending on that. return ( diff --git a/frontend/src/components/editor-page/app-bar/app-bar.tsx b/frontend/src/components/editor-page/app-bar/app-bar.tsx index 40d45073c..eb6d8339c 100644 --- a/frontend/src/components/editor-page/app-bar/app-bar.tsx +++ b/frontend/src/components/editor-page/app-bar/app-bar.tsx @@ -4,6 +4,7 @@ * SPDX-License-Identifier: AGPL-3.0-only */ import { useApplicationState } from '../../../hooks/common/use-application-state' +import { useNoteDetails } from '../../../hooks/common/use-note-details' import { NewNoteButton } from '../../common/new-note-button/new-note-button' import { ShowIf } from '../../common/show-if/show-if' import { SignInButton } from '../../landing-layout/navigation/sign-in-button' @@ -34,17 +35,17 @@ export interface AppBarProps { */ export const AppBar: React.FC = ({ mode }) => { const userExists = useApplicationState((state) => !!state.user) - const noteFrontmatter = useApplicationState((state) => state.noteDetails.frontmatter) + const noteFrontmatter = useNoteDetails() return (