Adapt react-client to use the real backend API (#1545)

Co-authored-by: Philip Molares <philip.molares@udo.edu>
Co-authored-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
Erik Michelson 2022-04-15 23:03:15 +02:00 committed by GitHub
parent 3399ed2023
commit 26f90505ff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
227 changed files with 4726 additions and 2310 deletions

View file

@ -1,11 +1,11 @@
/*
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { store } from '..'
import type { NoteDto } from '../../api/notes/types'
import type { Note, NotePermissions } from '../../api/notes/types'
import type {
AddTableAtCursorAction,
FormatSelectionAction,
@ -14,6 +14,7 @@ import type {
ReplaceInMarkdownContentAction,
SetNoteDetailsFromServerAction,
SetNoteDocumentContentAction,
SetNotePermissionsFromServerAction,
UpdateCursorPositionAction,
UpdateNoteTitleByFirstHeadingAction,
UpdateTaskListCheckboxAction
@ -36,13 +37,24 @@ export const setNoteContent = (content: string): void => {
* Sets the note metadata for the current note from an API response DTO to the redux.
* @param apiResponse The NoteDTO received from the API to store into redux.
*/
export const setNoteDataFromServer = (apiResponse: NoteDto): void => {
export const setNoteDataFromServer = (apiResponse: Note): void => {
store.dispatch({
type: NoteDetailsActionType.SET_NOTE_DATA_FROM_SERVER,
dto: apiResponse
noteFromServer: apiResponse
} as SetNoteDetailsFromServerAction)
}
/**
* Sets the note permissions for the current note from an API response DTO to the redux.
* @param apiResponse The NotePermissionsDTO received from the API to store into redux.
*/
export const setNotePermissionsFromServer = (apiResponse: NotePermissions): void => {
store.dispatch({
type: NoteDetailsActionType.SET_NOTE_PERMISSIONS_FROM_SERVER,
notePermissionsFromServer: apiResponse
} as SetNotePermissionsFromServerAction)
}
/**
* Updates the note title in the redux by the first heading found in the markdown content.
* @param firstHeading The content of the first heading found in the markdown content.