diff --git a/package.json b/package.json index 402e6e13da..f5c817ffd8 100644 --- a/package.json +++ b/package.json @@ -199,7 +199,6 @@ "jest-raw-loader": "^1.0.1", "jest-sonar-reporter": "^2.0.0", "matrix-mock-request": "^2.5.0", - "matrix-react-test-utils": "^0.2.3", "matrix-web-i18n": "^1.3.0", "postcss-scss": "^4.0.4", "raw-loader": "^4.0.2", diff --git a/src/components/structures/MatrixChat.tsx b/src/components/structures/MatrixChat.tsx index 923f461092..515355b63d 100644 --- a/src/components/structures/MatrixChat.tsx +++ b/src/components/structures/MatrixChat.tsx @@ -337,14 +337,19 @@ export default class MatrixChat extends React.PureComponent { // the old creds, but rather go straight to the relevant page const firstScreen = this.screenAfterLogin ? this.screenAfterLogin.screen : null; - if (firstScreen === 'login' || - firstScreen === 'register' || - firstScreen === 'forgot_password') { - this.showScreenAfterLogin(); - return; + const restoreSuccess = await this.loadSession(); + if (restoreSuccess) { + return true; } - return this.loadSession(); + if (firstScreen === 'login' || + firstScreen === 'register' || + firstScreen === 'forgot_password' + ) { + this.showScreenAfterLogin(); + } + + return false; }); } @@ -470,7 +475,7 @@ export default class MatrixChat extends React.PureComponent { return { serverConfig: props }; } - private loadSession() { + private loadSession(): Promise { // the extra Promise.resolve() ensures that synchronous exceptions hit the same codepath as // asynchronous ones. return Promise.resolve().then(() => { @@ -490,6 +495,7 @@ export default class MatrixChat extends React.PureComponent { dis.dispatch({ action: "view_welcome_page" }); } } + return loadedSession; }); // Note we don't catch errors from this: we catch everything within // loadSession as there's logic there to ask the user if they want diff --git a/src/components/views/elements/LanguageDropdown.tsx b/src/components/views/elements/LanguageDropdown.tsx index cf1dfedcce..06ffb232aa 100644 --- a/src/components/views/elements/LanguageDropdown.tsx +++ b/src/components/views/elements/LanguageDropdown.tsx @@ -38,7 +38,7 @@ interface IProps { interface IState { searchQuery: string; - langs: string[]; + langs: Awaited>; } export default class LanguageDropdown extends React.Component { @@ -60,7 +60,7 @@ export default class LanguageDropdown extends React.Component { }); this.setState({ langs }); }).catch(() => { - this.setState({ langs: ['en'] }); + this.setState({ langs: [{ value: 'en', label: "English" }] }); }); if (!this.props.value) { @@ -83,7 +83,7 @@ export default class LanguageDropdown extends React.Component { return ; } - let displayedLanguages; + let displayedLanguages: Awaited>; if (this.state.searchQuery) { displayedLanguages = this.state.langs.filter((lang) => { return languageMatchesSearchQuery(this.state.searchQuery, lang); diff --git a/src/components/views/voip/PipView.tsx b/src/components/views/voip/PipView.tsx index c6ce0da159..0c6feec0d5 100644 --- a/src/components/views/voip/PipView.tsx +++ b/src/components/views/voip/PipView.tsx @@ -154,9 +154,10 @@ export default class PipView extends React.Component { public componentWillUnmount() { LegacyCallHandler.instance.removeListener(LegacyCallHandlerEvent.CallChangeRoom, this.updateCalls); LegacyCallHandler.instance.removeListener(LegacyCallHandlerEvent.CallState, this.updateCalls); - MatrixClientPeg.get().removeListener(CallEvent.RemoteHoldUnhold, this.onCallRemoteHold); + const cli = MatrixClientPeg.get(); + cli?.removeListener(CallEvent.RemoteHoldUnhold, this.onCallRemoteHold); RoomViewStore.instance.removeListener(UPDATE_EVENT, this.onRoomViewStoreUpdate); - const room = MatrixClientPeg.get().getRoom(this.state.viewedRoomId); + const room = cli?.getRoom(this.state.viewedRoomId); if (room) { WidgetLayoutStore.instance.off(WidgetLayoutStore.emissionForRoom(room), this.updateCalls); } diff --git a/src/languageHandler.tsx b/src/languageHandler.tsx index 323b279049..0fc5fbb4d2 100644 --- a/src/languageHandler.tsx +++ b/src/languageHandler.tsx @@ -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 { 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 { let url: string; if (typeof(webpackLangJsonUrl) === 'string') { // in Jest this 'url' isn't a URL, so just fall through url = webpackLangJsonUrl; diff --git a/src/stores/CallStore.ts b/src/stores/CallStore.ts index 9d8eeb8ff0..abfb6b54af 100644 --- a/src/stores/CallStore.ts +++ b/src/stores/CallStore.ts @@ -90,7 +90,7 @@ export class CallStore extends AsyncStoreWithClient<{}> { } this.callListeners.clear(); this.calls.clear(); - this.activeCalls = new Set(); + this._activeCalls.clear(); this.matrixClient.off(ClientEvent.Room, this.onRoom); this.matrixClient.off(RoomStateEvent.Events, this.onRoomState); diff --git a/test/.eslintrc.js b/test/.eslintrc.js deleted file mode 100644 index ee22692130..0000000000 --- a/test/.eslintrc.js +++ /dev/null @@ -1,26 +0,0 @@ -/* -Copyright 2022 The Matrix.org Foundation C.I.C. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -module.exports = { - env: { - mocha: true, - }, - - // mocha defines a 'this' - rules: { - "@babel/no-invalid-this": "off", - }, -}; diff --git a/yarn.lock b/yarn.lock index 9ca41fe8a3..154f58e620 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3198,11 +3198,6 @@ browser-process-hrtime@^1.0.0: resolved "https://registry.yarnpkg.com/browser-process-hrtime/-/browser-process-hrtime-1.0.0.tgz#3c9b4b7d782c8121e56f10106d84c0d0ffc94626" integrity sha512-9o5UecI3GhkpM6DrXr69PblIuWxPKk9Y0jHBRhdocZ2y7YECBFCsHm79Pr3OyR2AvjhDkabFJaDJMYRazHgsow== -browser-request@^0.3.3: - version "0.3.3" - resolved "https://registry.yarnpkg.com/browser-request/-/browser-request-0.3.3.tgz#9ece5b5aca89a29932242e18bf933def9876cc17" - integrity sha512-YyNI4qJJ+piQG6MMEuo7J3Bzaqssufx04zpEKYfSrl/1Op59HWali9zMtBpXnkmqMcOuWJPZvudrm9wISmnCbg== - browserslist@^4.20.2, browserslist@^4.21.3: version "4.21.3" resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.21.3.tgz#5df277694eb3c48bc5c4b05af3e8b7e09c5a6d1a" @@ -7087,11 +7082,6 @@ matrix-mock-request@^2.5.0: dependencies: expect "^28.1.0" -matrix-react-test-utils@^0.2.3: - version "0.2.3" - resolved "https://registry.yarnpkg.com/matrix-react-test-utils/-/matrix-react-test-utils-0.2.3.tgz#27653f9d6bbfddd1856e51860fad1503b039d617" - integrity sha512-NKZDlMEQzDZDQhBYyKBUtqidRvpkww3n9/GmGICkxtU2D6NetyBIfvm1Lf9o7167KSkPHJUVvDS9dzaS55jUnA== - matrix-web-i18n@^1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/matrix-web-i18n/-/matrix-web-i18n-1.3.0.tgz#d85052635215173541f56ea1af0cbefd6e09ecb3"