mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-29 06:15:29 -04:00
fix(note-deletion): Add required keepMedia property and redirect
The backend requires a property "keepMedia" that states whether uploaded media should be kept around or not. This property was missing in our API call. Additionally, after deleting a note, the user is now redirected to the history page. Signed-off-by: Erik Michelson <github@erik.michelson.eu>
This commit is contained in:
parent
d57b2f27fd
commit
6cc11d07e3
3 changed files with 25 additions and 5 deletions
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
import type { Note } from './types'
|
||||
import type { Note, NoteDeletionOptions } from './types'
|
||||
import type { MediaUpload } from '../media/types'
|
||||
import { GetApiRequestBuilder } from '../common/api-request-builder/get-api-request-builder'
|
||||
import { PostApiRequestBuilder } from '../common/api-request-builder/post-api-request-builder'
|
||||
|
@ -73,5 +73,11 @@ export const createNoteWithPrimaryAlias = async (markdown: string, primaryAlias:
|
|||
* @throws {Error} when the api request wasn't successful.
|
||||
*/
|
||||
export const deleteNote = async (noteIdOrAlias: string): Promise<void> => {
|
||||
await new DeleteApiRequestBuilder('notes/' + noteIdOrAlias).sendRequest()
|
||||
await new DeleteApiRequestBuilder<void, NoteDeletionOptions>('notes/' + noteIdOrAlias)
|
||||
.withJsonBody({
|
||||
keepMedia: false
|
||||
// TODO Ask whether the user wants to keep the media uploaded to the note.
|
||||
// https://github.com/hedgedoc/react-client/issues/2288
|
||||
})
|
||||
.sendRequest()
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* 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
|
||||
*/
|
||||
|
@ -50,3 +50,7 @@ export interface NoteGroupPermissionEntry {
|
|||
groupName: string
|
||||
canEdit: boolean
|
||||
}
|
||||
|
||||
export interface NoteDeletionOptions {
|
||||
keepMedia: boolean
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue