Remove unused packages and fix invariant violation on AsyncStore onNotReady (#9404)

* Remove traces of browser-request & mocha

* Remove unused matrix-react-test-utils

* Fix dispatcher invariant violation

* Add null-guard

* Improve types

* Fix null-guard

* Fix issue with authed users going directly to /#/login
This commit is contained in:
Michael Telatynski 2022-10-13 09:22:32 +01:00 committed by GitHub
parent 28bd58e551
commit 1800cb8c71
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 34 additions and 57 deletions

View file

@ -385,9 +385,11 @@ export function setMissingEntryGenerator(f: (value: string) => void) {
counterpart.setMissingEntryGenerator(f);
}
type Language = {
fileName: string;
label: string;
type Languages = {
[lang: string]: {
fileName: string;
label: string;
};
};
export function setLanguage(preferredLangs: string | string[]) {
@ -401,7 +403,7 @@ export function setLanguage(preferredLangs: string | string[]) {
}
let langToUse: string;
let availLangs: { [lang: string]: Language };
let availLangs: Languages;
return getLangsJson().then((result) => {
availLangs = result;
@ -438,9 +440,14 @@ export function setLanguage(preferredLangs: string | string[]) {
});
}
export function getAllLanguagesFromJson() {
type Language = {
value: string;
label: string;
};
export function getAllLanguagesFromJson(): Promise<Language[]> {
return getLangsJson().then((langsObject) => {
const langs = [];
const langs: Language[] = [];
for (const langKey in langsObject) {
if (langsObject.hasOwnProperty(langKey)) {
langs.push({
@ -536,7 +543,7 @@ export function pickBestLanguage(langs: string[]): string {
return langs[0];
}
async function getLangsJson(): Promise<{ [lang: string]: Language }> {
async function getLangsJson(): Promise<Languages> {
let url: string;
if (typeof(webpackLangJsonUrl) === 'string') { // in Jest this 'url' isn't a URL, so just fall through
url = webpackLangJsonUrl;