mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-28 05:54:43 -04:00
Fix Communication between frontend and backend (#1201)
Co-authored-by: Tilman Vatteroth <git@tilmanvatteroth.de> Signed-off-by: Philip Molares <philip.molares@udo.edu> Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
parent
4a18e51c83
commit
9cf7980334
38 changed files with 268 additions and 164 deletions
|
@ -6,7 +6,6 @@
|
|||
|
||||
import { DateTime } from 'luxon'
|
||||
import { Reducer } from 'redux'
|
||||
import { Note } from '../../api/notes'
|
||||
import {
|
||||
NoteFrontmatter,
|
||||
NoteTextDirection,
|
||||
|
@ -22,6 +21,7 @@ import {
|
|||
SetNoteFrontmatterFromRenderingAction,
|
||||
UpdateNoteTitleByFirstHeadingAction
|
||||
} from './types'
|
||||
import { noteDtoToNoteDetails } from '../../api/notes/dto-methods'
|
||||
|
||||
export const initialState: NoteDetails = {
|
||||
markdownContent: '',
|
||||
|
@ -29,10 +29,9 @@ export const initialState: NoteDetails = {
|
|||
createTime: DateTime.fromSeconds(0),
|
||||
lastChange: {
|
||||
timestamp: DateTime.fromSeconds(0),
|
||||
userId: ''
|
||||
userName: ''
|
||||
},
|
||||
alias: '',
|
||||
preVersionTwoNote: false,
|
||||
viewCount: 0,
|
||||
authorship: [],
|
||||
noteTitle: '',
|
||||
|
@ -67,7 +66,7 @@ export const NoteDetailsReducer: Reducer<NoteDetails, NoteDetailsAction> = (stat
|
|||
noteTitle: generateNoteTitle(state.frontmatter, (action as UpdateNoteTitleByFirstHeadingAction).firstHeading)
|
||||
}
|
||||
case NoteDetailsActionType.SET_NOTE_DATA_FROM_SERVER:
|
||||
return convertNoteToNoteDetails((action as SetNoteDetailsFromServerAction).note)
|
||||
return noteDtoToNoteDetails((action as SetNoteDetailsFromServerAction).note)
|
||||
case NoteDetailsActionType.SET_NOTE_FRONTMATTER:
|
||||
return {
|
||||
...state,
|
||||
|
@ -111,21 +110,4 @@ const generateNoteTitle = (frontmatter: NoteFrontmatter, firstHeading?: string)
|
|||
}
|
||||
}
|
||||
|
||||
const convertNoteToNoteDetails = (note: Note): NoteDetails => {
|
||||
return {
|
||||
markdownContent: note.content,
|
||||
frontmatter: initialState.frontmatter,
|
||||
id: note.id,
|
||||
noteTitle: initialState.noteTitle,
|
||||
createTime: DateTime.fromSeconds(note.createTime),
|
||||
lastChange: {
|
||||
userId: note.lastChange.userId,
|
||||
timestamp: DateTime.fromSeconds(note.lastChange.timestamp)
|
||||
},
|
||||
firstHeading: initialState.firstHeading,
|
||||
preVersionTwoNote: note.preVersionTwoNote,
|
||||
viewCount: note.viewCount,
|
||||
alias: note.alias,
|
||||
authorship: note.authorship
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue