hedgedoc/src/components/application-loader/initializers/configLoader.ts
Tilman Vatteroth 28600d6508
Change copyright year from 2020 to 2021 (#917)
* 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>
2021-01-06 21:37:59 +01:00

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()
}