diff --git a/ModerationClient/ViewModels/ClientViewModel.cs b/ModerationClient/ViewModels/ClientViewModel.cs
index 1e287ec..312b46a 100644
--- a/ModerationClient/ViewModels/ClientViewModel.cs
+++ b/ModerationClient/ViewModels/ClientViewModel.cs
@@ -30,6 +30,7 @@ public partial class ClientViewModel : ViewModelBase {
private readonly CommandLineConfiguration _cfg;
private SpaceNode? _currentSpace;
private readonly SpaceNode _allRoomsNode;
+ private string _status = "Loading...";
public ObservableCollection<SpaceNode> DisplayedSpaces { get; } = [];
public ObservableDictionary<string, RoomNode> AllRooms { get; } = new();
@@ -38,12 +39,22 @@ public partial class ClientViewModel : ViewModelBase {
set => SetProperty(ref _currentSpace, value);
}
+ public string Status {
+ get => _status + " " + DateTime.Now;
+ set => SetProperty(ref _status, value);
+ }
+
public async Task Run() {
+ Status = "Interrupted.";
+ return;
+ Status = "Doing initial sync...";
var sh = new SyncStateResolver(_authService.Homeserver, _logger, storageProvider: new FileStorageProvider(Path.Combine(_cfg.ProfileDirectory, "syncCache")));
// var res = await sh.SyncAsync();
//await sh.OptimiseStore();
while (true) {
+ // Status = "Syncing...";
var res = await sh.ContinueAsync();
+ Status = $"Processing sync... {res.next.NextBatch}";
await ApplySpaceChanges(res.next);
//OnPropertyChanged(nameof(CurrentSpace));
//OnPropertyChanged(nameof(CurrentSpace.ChildRooms));
@@ -52,6 +63,7 @@ public partial class ClientViewModel : ViewModelBase {
// GC.Collect(i, GCCollectionMode.Forced, blocking: true);
// GC.WaitForPendingFinalizers();
// }
+ Status = "Syncing...";
}
}
@@ -72,7 +84,7 @@ public partial class ClientViewModel : ViewModelBase {
}
}
- // await Task.WhenAll(tasks);
+ await Task.WhenAll(tasks);
return;
diff --git a/ModerationClient/ViewModels/MainWindowViewModel.cs b/ModerationClient/ViewModels/MainWindowViewModel.cs
index 01ec6d6..be64de4 100644
--- a/ModerationClient/ViewModels/MainWindowViewModel.cs
+++ b/ModerationClient/ViewModels/MainWindowViewModel.cs
@@ -1,14 +1,16 @@
using System;
+using Avalonia;
using ModerationClient.Services;
using ModerationClient.Views;
namespace ModerationClient.ViewModels;
public partial class MainWindowViewModel(MatrixAuthenticationService authService, CommandLineConfiguration cfg) : ViewModelBase {
- public MainWindow? MainWindow { get; set; }
-
+ // public MainWindow? MainWindow { get; set; }
+
private float _scale = 1.0f;
private ViewModelBase _currentViewModel = new LoginViewModel(authService);
+ private Size _physicalSize = new Size(300, 220);
public ViewModelBase CurrentViewModel {
get => _currentViewModel;
@@ -21,13 +23,23 @@ public partial class MainWindowViewModel(MatrixAuthenticationService authService
public float Scale {
get => _scale;
set {
- SetProperty(ref _scale, (float)Math.Round(value, 2));
- OnPropertyChanged(nameof(ChildTargetWidth));
- OnPropertyChanged(nameof(ChildTargetHeight));
+ if (SetProperty(ref _scale, (float)Math.Round(value, 2))) {
+ OnPropertyChanged(nameof(ChildTargetWidth));
+ OnPropertyChanged(nameof(ChildTargetHeight));
+ }
}
}
- public int ChildTargetWidth => (int)(MainWindow?.Width / Scale ?? 1);
- public int ChildTargetHeight => (int)(MainWindow?.Height / Scale ?? 1);
-
+ public int ChildTargetWidth => (int)(PhysicalSize.Width / Scale);
+ public int ChildTargetHeight => (int)(PhysicalSize.Height / Scale);
+
+ public Size PhysicalSize {
+ get => _physicalSize;
+ set {
+ if (SetProperty(ref _physicalSize, value)) {
+ OnPropertyChanged(nameof(ChildTargetWidth));
+ OnPropertyChanged(nameof(ChildTargetHeight));
+ }
+ }
+ }
}
\ No newline at end of file
diff --git a/ModerationClient/ViewModels/UserManagement/UserManagementViewModel.cs b/ModerationClient/ViewModels/UserManagement/UserManagementViewModel.cs
new file mode 100644
index 0000000..7a2ad63
--- /dev/null
+++ b/ModerationClient/ViewModels/UserManagement/UserManagementViewModel.cs
@@ -0,0 +1,63 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Collections.Specialized;
+using System.Diagnostics;
+using System.IO;
+using System.Linq;
+using System.Text.Json;
+using System.Threading.Tasks;
+using ArcaneLibs.Collections;
+using ArcaneLibs.Extensions;
+using LibMatrix.EventTypes.Spec.State;
+using LibMatrix.Helpers;
+using LibMatrix.Homeservers;
+using LibMatrix.Homeservers.ImplementationDetails.Synapse.Models.Responses;
+using LibMatrix.Responses;
+using MatrixUtils.Abstractions;
+using Microsoft.Extensions.Logging;
+using ModerationClient.Services;
+
+namespace ModerationClient.ViewModels;
+
+public partial class UserManagementViewModel : ViewModelBase {
+ public UserManagementViewModel(ILogger<UserManagementViewModel> logger, MatrixAuthenticationService authService, CommandLineConfiguration cfg) {
+ _logger = logger;
+ _authService = authService;
+ _cfg = cfg;
+ _ = Task.Run(Run).ContinueWith(x=>x.Exception?.Handle(y=> {
+ Console.WriteLine(y);
+ return true;
+ }));
+ }
+
+ private readonly ILogger<UserManagementViewModel> _logger;
+ private readonly MatrixAuthenticationService _authService;
+ private readonly CommandLineConfiguration _cfg;
+ private string _status = "Loading...";
+ public ObservableCollection<User> Users { get; set; } = [];
+
+ public string Status {
+ get => _status + " " + DateTime.Now;
+ set => SetProperty(ref _status, value);
+ }
+
+ public async Task Run() {
+ Users.Clear();
+ Status = "Doing initial sync...";
+ if (_authService.Homeserver is not AuthenticatedHomeserverSynapse synapse) {
+ Console.WriteLine("This client only supports Synapse homeservers.");
+ return;
+ }
+
+ await foreach (var user in synapse.Admin.SearchUsersAsync(chunkLimit: 100)) {
+ Console.WriteLine("USERMANAGER GOT USER: " + user.ToJson(indent:false, ignoreNull: true));
+ Users.Add(JsonSerializer.Deserialize<User>(user.ToJson())!);
+ }
+ Console.WriteLine("Done.");
+ }
+}
+
+public class User : AdminUserListResult.AdminUserListResultUser {
+
+}
\ No newline at end of file
|