mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-06-03 00:19:57 -04:00
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:
parent
3399ed2023
commit
26f90505ff
227 changed files with 4726 additions and 2310 deletions
|
@ -1,19 +0,0 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import { isMockMode } from '../../utils/test-modes'
|
||||
import { useMemo } from 'react'
|
||||
|
||||
export const useBackendBaseUrl = (): string => {
|
||||
return useMemo(() => {
|
||||
const mockMode = isMockMode()
|
||||
if (!mockMode && process.env.NEXT_PUBLIC_BACKEND_BASE_URL === undefined) {
|
||||
throw new Error('NEXT_PUBLIC_BACKEND_BASE_URL is unset and mock mode is disabled')
|
||||
}
|
||||
|
||||
return mockMode ? '/mock-backend/' : (process.env.NEXT_PUBLIC_BACKEND_BASE_URL as string)
|
||||
}, [])
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import { useBackendBaseUrl } from './use-backend-base-url'
|
||||
|
||||
export const useCustomizeAssetsUrl = (): string => {
|
||||
const backendBaseUrl = useBackendBaseUrl()
|
||||
return process.env.NEXT_PUBLIC_CUSTOMIZE_ASSETS_URL || `${backendBaseUrl}public/`
|
||||
}
|
|
@ -14,7 +14,7 @@ import { useMemo } from 'react'
|
|||
export const useNoteTitle = (): string => {
|
||||
const { t } = useTranslation()
|
||||
const untitledNote = useMemo(() => t('editor.untitledNote'), [t])
|
||||
const noteTitle = useApplicationState((state) => state.noteDetails.noteTitle)
|
||||
const noteTitle = useApplicationState((state) => state.noteDetails.title)
|
||||
|
||||
return useMemo(() => (noteTitle === '' ? untitledNote : noteTitle), [noteTitle, untitledNote])
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue