Various work
1 files changed, 12 insertions, 1 deletions
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;
|