From 8838a3b20ba95bca34954b6ec828991adb028d4d Mon Sep 17 00:00:00 2001 From: Rory& Date: Mon, 10 Mar 2025 07:41:43 +0100 Subject: Various work --- ModerationClient/ViewModels/LoginViewModel.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'ModerationClient/ViewModels/LoginViewModel.cs') diff --git a/ModerationClient/ViewModels/LoginViewModel.cs b/ModerationClient/ViewModels/LoginViewModel.cs index 32f0d6e..34c8d28 100644 --- a/ModerationClient/ViewModels/LoginViewModel.cs +++ b/ModerationClient/ViewModels/LoginViewModel.cs @@ -1,13 +1,15 @@ using System; using System.Threading.Tasks; +using LibMatrix.Services; using ModerationClient.Services; namespace ModerationClient.ViewModels; -public partial class LoginViewModel(MatrixAuthenticationService authService) : ViewModelBase +public partial class LoginViewModel(MatrixAuthenticationService authService, HomeserverResolverService hsResolver) : ViewModelBase { private Exception? _exception; public string Username { get; set; } + public string? Homeserver { get; set; } public string Password { get; set; } public Exception? Exception { @@ -15,6 +17,15 @@ public partial class LoginViewModel(MatrixAuthenticationService authService) : V private set => SetProperty(ref _exception, value); } + public async Task ResolveHomeserverAsync() { + try { + string[] parts = Username.Split(':', 2); + Homeserver = (await hsResolver.ResolveHomeserverFromWellKnown(Username, enableServer: false)).Client; + } catch (Exception e) { + Console.WriteLine(e); + } + } + public async Task LoginAsync() { try { Exception = null; -- cgit 1.5.1