mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 11:35:04 +01:00
fixes linter errors and removes some unneeded async/await
This commit is contained in:
parent
8b91d8fac8
commit
cadca70946
@ -58,7 +58,7 @@ export class ViewModel<O extends Options = Options> extends EventEmitter<{change
|
|||||||
return this._options[name];
|
return this._options[name];
|
||||||
}
|
}
|
||||||
|
|
||||||
observeNavigation(type: string, onChange: (value: string | true | undefined, type: string) => void) {
|
observeNavigation(type: string, onChange: (value: string | true | undefined, type: string) => void): void {
|
||||||
const segmentObservable = this.navigation.observe(type);
|
const segmentObservable = this.navigation.observe(type);
|
||||||
const unsubscribe = segmentObservable.subscribe((value: string | true | undefined) => {
|
const unsubscribe = segmentObservable.subscribe((value: string | true | undefined) => {
|
||||||
onChange(value, type);
|
onChange(value, type);
|
||||||
@ -103,7 +103,7 @@ export class ViewModel<O extends Options = Options> extends EventEmitter<{change
|
|||||||
//
|
//
|
||||||
// translated string should probably always be bindings, unless we're fine with a refresh when changing the language?
|
// translated string should probably always be bindings, unless we're fine with a refresh when changing the language?
|
||||||
// we probably are, if we're using routing with a url, we could just refresh.
|
// we probably are, if we're using routing with a url, we could just refresh.
|
||||||
i18n(parts: TemplateStringsArray, ...expr: any[]) {
|
i18n(parts: TemplateStringsArray, ...expr: any[]): string {
|
||||||
// just concat for now
|
// just concat for now
|
||||||
let result = "";
|
let result = "";
|
||||||
for (let i = 0; i < parts.length; ++i) {
|
for (let i = 0; i < parts.length; ++i) {
|
||||||
|
@ -55,7 +55,7 @@ export class LoginViewModel extends ViewModel<Options> {
|
|||||||
this._loginToken = loginToken;
|
this._loginToken = loginToken;
|
||||||
this._client = new Client(this.platform);
|
this._client = new Client(this.platform);
|
||||||
this._homeserver = defaultHomeserver;
|
this._homeserver = defaultHomeserver;
|
||||||
void this._initViewModels();
|
this._initViewModels();
|
||||||
}
|
}
|
||||||
|
|
||||||
get passwordLoginViewModel(): PasswordLoginViewModel {
|
get passwordLoginViewModel(): PasswordLoginViewModel {
|
||||||
@ -98,11 +98,11 @@ export class LoginViewModel extends ViewModel<Options> {
|
|||||||
return !!this._abortQueryOperation;
|
return !!this._abortQueryOperation;
|
||||||
}
|
}
|
||||||
|
|
||||||
goBack() {
|
goBack(): void {
|
||||||
this.navigation.push("session");
|
this.navigation.push("session");
|
||||||
}
|
}
|
||||||
|
|
||||||
async _initViewModels() {
|
_initViewModels(): void {
|
||||||
if (this._loginToken) {
|
if (this._loginToken) {
|
||||||
this._hideHomeserver = true;
|
this._hideHomeserver = true;
|
||||||
this._completeSSOLoginViewModel = this.track(new CompleteSSOLoginViewModel(
|
this._completeSSOLoginViewModel = this.track(new CompleteSSOLoginViewModel(
|
||||||
@ -115,11 +115,11 @@ export class LoginViewModel extends ViewModel<Options> {
|
|||||||
this.emitChange("completeSSOLoginViewModel");
|
this.emitChange("completeSSOLoginViewModel");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
await this.queryHomeserver();
|
void this.queryHomeserver();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_showPasswordLogin() {
|
_showPasswordLogin(): void {
|
||||||
this._passwordLoginViewModel = this.track(new PasswordLoginViewModel(
|
this._passwordLoginViewModel = this.track(new PasswordLoginViewModel(
|
||||||
this.childOptions({
|
this.childOptions({
|
||||||
loginOptions: this._loginOptions,
|
loginOptions: this._loginOptions,
|
||||||
@ -128,19 +128,19 @@ export class LoginViewModel extends ViewModel<Options> {
|
|||||||
this.emitChange("passwordLoginViewModel");
|
this.emitChange("passwordLoginViewModel");
|
||||||
}
|
}
|
||||||
|
|
||||||
_showSSOLogin() {
|
_showSSOLogin(): void {
|
||||||
this._startSSOLoginViewModel = this.track(
|
this._startSSOLoginViewModel = this.track(
|
||||||
new StartSSOLoginViewModel(this.childOptions({loginOptions: this._loginOptions}))
|
new StartSSOLoginViewModel(this.childOptions({loginOptions: this._loginOptions}))
|
||||||
);
|
);
|
||||||
this.emitChange("startSSOLoginViewModel");
|
this.emitChange("startSSOLoginViewModel");
|
||||||
}
|
}
|
||||||
|
|
||||||
_showError(message: string) {
|
_showError(message: string): void {
|
||||||
this._errorMessage = message;
|
this._errorMessage = message;
|
||||||
this.emitChange("errorMessage");
|
this.emitChange("errorMessage");
|
||||||
}
|
}
|
||||||
|
|
||||||
_setBusy(status: boolean) {
|
_setBusy(status: boolean): void {
|
||||||
this._isBusy = status;
|
this._isBusy = status;
|
||||||
this._passwordLoginViewModel?.setBusy(status);
|
this._passwordLoginViewModel?.setBusy(status);
|
||||||
this._startSSOLoginViewModel?.setBusy(status);
|
this._startSSOLoginViewModel?.setBusy(status);
|
||||||
@ -193,14 +193,14 @@ export class LoginViewModel extends ViewModel<Options> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
_disposeViewModels() {
|
_disposeViewModels(): void {
|
||||||
this._startSSOLoginViewModel = this.disposeTracked(this._startSSOLoginViewModel);
|
this._startSSOLoginViewModel = this.disposeTracked(this._startSSOLoginViewModel);
|
||||||
this._passwordLoginViewModel = this.disposeTracked(this._passwordLoginViewModel);
|
this._passwordLoginViewModel = this.disposeTracked(this._passwordLoginViewModel);
|
||||||
this._completeSSOLoginViewModel = this.disposeTracked(this._completeSSOLoginViewModel);
|
this._completeSSOLoginViewModel = this.disposeTracked(this._completeSSOLoginViewModel);
|
||||||
this.emitChange("disposeViewModels");
|
this.emitChange("disposeViewModels");
|
||||||
}
|
}
|
||||||
|
|
||||||
async setHomeserver(newHomeserver: string): void {
|
async setHomeserver(newHomeserver: string): Promise<void> {
|
||||||
this._homeserver = newHomeserver;
|
this._homeserver = newHomeserver;
|
||||||
// clear everything set by queryHomeserver
|
// clear everything set by queryHomeserver
|
||||||
this._loginOptions = undefined;
|
this._loginOptions = undefined;
|
||||||
@ -226,7 +226,7 @@ export class LoginViewModel extends ViewModel<Options> {
|
|||||||
void this.queryHomeserver();
|
void this.queryHomeserver();
|
||||||
}
|
}
|
||||||
|
|
||||||
async queryHomeserver(): void {
|
async queryHomeserver(): Promise<void> {
|
||||||
// don't repeat a query we've just done
|
// don't repeat a query we've just done
|
||||||
if (this._homeserver === this._queriedHomeserver || this._homeserver === "") {
|
if (this._homeserver === this._queriedHomeserver || this._homeserver === "") {
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user