mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-14 23:24:46 -04:00
convert more promise chains to async await
Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>
This commit is contained in:
parent
23cfcacd09
commit
8636391a73
2 changed files with 18 additions and 29 deletions
|
@ -3,22 +3,18 @@ import {setFrontendConfig} from "../redux/frontend-config/methods";
|
||||||
import {setBackendConfig} from "../redux/backend-config/methods";
|
import {setBackendConfig} from "../redux/backend-config/methods";
|
||||||
import {getAndSetUser} from "../utils/apiUtils";
|
import {getAndSetUser} from "../utils/apiUtils";
|
||||||
|
|
||||||
export function loadAllConfig() {
|
export async function loadAllConfig() {
|
||||||
return getFrontendConfig()
|
const frontendConfig = await getFrontendConfig();
|
||||||
.then((frontendConfig) => {
|
|
||||||
if (!frontendConfig) {
|
if (!frontendConfig) {
|
||||||
return Promise.reject("Frontend config empty!");
|
return Promise.reject("Frontend config empty!");
|
||||||
}
|
}
|
||||||
setFrontendConfig(frontendConfig);
|
setFrontendConfig(frontendConfig);
|
||||||
return getBackendConfig()
|
|
||||||
})
|
const backendConfig = await getBackendConfig()
|
||||||
.then((backendConfig) => {
|
|
||||||
if (!backendConfig) {
|
if (!backendConfig) {
|
||||||
return Promise.reject("Backend config empty!");
|
return Promise.reject("Backend config empty!");
|
||||||
}
|
}
|
||||||
setBackendConfig(backendConfig)
|
setBackendConfig(backendConfig)
|
||||||
}).then(() => {
|
|
||||||
getAndSetUser();
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
|
await getAndSetUser();
|
||||||
|
}
|
|
@ -31,18 +31,11 @@ import "moment/locale/vi";
|
||||||
import "moment/locale/zh-cn";
|
import "moment/locale/zh-cn";
|
||||||
import "moment/locale/zh-tw";
|
import "moment/locale/zh-tw";
|
||||||
|
|
||||||
export function setUpI18n() {
|
export async function setUpI18n() {
|
||||||
return i18n
|
await i18n
|
||||||
// load translation using http -> see /public/locales
|
|
||||||
// learn more: https://github.com/i18next/i18next-http-backend
|
|
||||||
.use(Backend)
|
.use(Backend)
|
||||||
// detect user language
|
|
||||||
// learn more: https://github.com/i18next/i18next-browser-languageDetector
|
|
||||||
.use(LanguageDetector)
|
.use(LanguageDetector)
|
||||||
// pass the i18n instance to react-i18next.
|
|
||||||
.use(initReactI18next)
|
.use(initReactI18next)
|
||||||
// init i18next
|
|
||||||
// for all options read: https://www.i18next.com/overview/configuration-options
|
|
||||||
.init({
|
.init({
|
||||||
fallbackLng: 'en',
|
fallbackLng: 'en',
|
||||||
debug: true,
|
debug: true,
|
||||||
|
@ -53,9 +46,9 @@ export function setUpI18n() {
|
||||||
interpolation: {
|
interpolation: {
|
||||||
escapeValue: false, // not needed for react as it escapes by default
|
escapeValue: false, // not needed for react as it escapes by default
|
||||||
},
|
},
|
||||||
}).then(() => {
|
|
||||||
moment.locale(i18n.language);
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
moment.locale(i18n.language);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue