mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-14 07:04:45 -04:00

* Change copyright year from 2020 to 2021 Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> * Change copyright year in jetbrains copyright template Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>
34 lines
1,018 B
TypeScript
34 lines
1,018 B
TypeScript
/*
|
|
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
|
*
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
*/
|
|
|
|
import { getConfig } from '../../../api/config'
|
|
import { setApiUrl } from '../../../redux/api-url/methods'
|
|
import { setBanner } from '../../../redux/banner/methods'
|
|
import { setConfig } from '../../../redux/config/methods'
|
|
import { getAndSetUser } from '../../login-page/auth/utils'
|
|
|
|
export const loadAllConfig: (baseUrl: string) => Promise<void> = async (baseUrl) => {
|
|
setApiUrl({
|
|
apiUrl: (process.env.REACT_APP_BACKEND || baseUrl) + '/api/v2'
|
|
})
|
|
|
|
const config = await getConfig()
|
|
if (!config) {
|
|
return Promise.reject(new Error('Config empty!'))
|
|
}
|
|
setConfig(config)
|
|
|
|
const banner = config.banner
|
|
if (banner.text !== '') {
|
|
const lastAcknowledgedTimestamp = window.localStorage.getItem('bannerTimeStamp') || ''
|
|
setBanner({
|
|
...banner,
|
|
show: banner.text !== '' && banner.timestamp !== lastAcknowledgedTimestamp
|
|
})
|
|
}
|
|
|
|
await getAndSetUser()
|
|
}
|