mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-23 03:27:05 -04:00
Add note loading boundary (#2040)
* Remove redundant equal value Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * Add NoteLoadingBoundary to fetch note from API before rendering Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * Improve debug message for setHandler Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * Add test for boundary Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * Use common error page for note loading errors Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * Fix tests Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * Format code Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * Add missing snapshot Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * Reformat code Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
parent
0419113d36
commit
880e542351
19 changed files with 282 additions and 166 deletions
src/components/editor-page/hooks
|
@ -12,7 +12,7 @@ import { useApplicationState } from '../../../hooks/common/use-application-state
|
|||
import type { HistoryEntryWithOrigin } from '../../../api/history/types'
|
||||
import { HistoryEntryOrigin } from '../../../api/history/types'
|
||||
|
||||
export const useUpdateLocalHistoryEntry = (updateReady: boolean): void => {
|
||||
export const useUpdateLocalHistoryEntry = (): void => {
|
||||
const id = useApplicationState((state) => state.noteDetails.id)
|
||||
const userExists = useApplicationState((state) => !!state.user)
|
||||
const currentNoteTitle = useApplicationState((state) => state.noteDetails.title)
|
||||
|
@ -22,7 +22,7 @@ export const useUpdateLocalHistoryEntry = (updateReady: boolean): void => {
|
|||
const lastNoteTags = useRef<string[]>([])
|
||||
|
||||
useEffect(() => {
|
||||
if (!updateReady || userExists) {
|
||||
if (userExists) {
|
||||
return
|
||||
}
|
||||
if (currentNoteTitle === lastNoteTitle.current && equal(currentNoteTags, lastNoteTags.current)) {
|
||||
|
@ -46,5 +46,5 @@ export const useUpdateLocalHistoryEntry = (updateReady: boolean): void => {
|
|||
updateLocalHistoryEntry(id, entry)
|
||||
lastNoteTitle.current = currentNoteTitle
|
||||
lastNoteTags.current = currentNoteTags
|
||||
}, [updateReady, id, userExists, currentNoteTitle, currentNoteTags])
|
||||
}, [id, userExists, currentNoteTitle, currentNoteTags])
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue