mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 03:25:12 +01:00
typescript-ifying StartSSOLoginViewModel
This commit is contained in:
parent
749e038a47
commit
53c4ecb69b
@ -17,7 +17,7 @@ limitations under the License.
|
|||||||
import {Client} from "../../matrix/Client.js";
|
import {Client} from "../../matrix/Client.js";
|
||||||
import {Options as BaseOptions, ViewModel} from "../ViewModel";
|
import {Options as BaseOptions, ViewModel} from "../ViewModel";
|
||||||
import {PasswordLoginViewModel} from "./PasswordLoginViewModel";
|
import {PasswordLoginViewModel} from "./PasswordLoginViewModel";
|
||||||
import {StartSSOLoginViewModel} from "./StartSSOLoginViewModel.js";
|
import {StartSSOLoginViewModel} from "./StartSSOLoginViewModel";
|
||||||
import {CompleteSSOLoginViewModel} from "./CompleteSSOLoginViewModel.js";
|
import {CompleteSSOLoginViewModel} from "./CompleteSSOLoginViewModel.js";
|
||||||
import {LoadStatus} from "../../matrix/Client.js";
|
import {LoadStatus} from "../../matrix/Client.js";
|
||||||
import {SessionLoadViewModel} from "../SessionLoadViewModel.js";
|
import {SessionLoadViewModel} from "../SessionLoadViewModel.js";
|
||||||
@ -64,7 +64,7 @@ export class LoginViewModel extends ViewModel<SegmentType, Options> {
|
|||||||
return this._passwordLoginViewModel;
|
return this._passwordLoginViewModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
get startSSOLoginViewModel(): StartSSOLoginViewModel {
|
get startSSOLoginViewModel(): StartSSOLoginViewModel | undefined {
|
||||||
return this._startSSOLoginViewModel;
|
return this._startSSOLoginViewModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,25 +14,35 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {ViewModel} from "../ViewModel";
|
import type {SSOLoginHelper} from "../../matrix/login";
|
||||||
|
import {Options as BaseOptions, ViewModel} from "../ViewModel";
|
||||||
|
import type {LoginOptions} from "./LoginViewModel";
|
||||||
|
|
||||||
|
|
||||||
|
type Options = {
|
||||||
|
loginOptions: LoginOptions | undefined;
|
||||||
|
} & BaseOptions;
|
||||||
|
|
||||||
export class StartSSOLoginViewModel extends ViewModel{
|
export class StartSSOLoginViewModel extends ViewModel{
|
||||||
constructor(options) {
|
private _sso?: SSOLoginHelper;
|
||||||
|
private _isBusy = false;
|
||||||
|
|
||||||
|
constructor(options: Options) {
|
||||||
super(options);
|
super(options);
|
||||||
this._sso = options.loginOptions.sso;
|
this._sso = options.loginOptions!.sso;
|
||||||
this._isBusy = false;
|
this._isBusy = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
get isBusy() { return this._isBusy; }
|
get isBusy(): boolean { return this._isBusy; }
|
||||||
|
|
||||||
setBusy(status) {
|
setBusy(status: boolean): void {
|
||||||
this._isBusy = status;
|
this._isBusy = status;
|
||||||
this.emitChange("isBusy");
|
this.emitChange("isBusy");
|
||||||
}
|
}
|
||||||
|
|
||||||
async startSSOLogin() {
|
async startSSOLogin(): Promise<void> {
|
||||||
await this.platform.settingsStorage.setString("sso_ongoing_login_homeserver", this._sso.homeserver);
|
await this.platform.settingsStorage.setString("sso_ongoing_login_homeserver", this._sso!.homeserver);
|
||||||
const link = this._sso.createSSORedirectURL(this.urlCreator.createSSOCallbackURL());
|
const link = this._sso!.createSSORedirectURL(this.urlCreator.createSSOCallbackURL());
|
||||||
this.platform.openUrl(link);
|
this.platform.openUrl(link);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user