about summary refs log tree commit diff
path: root/MatrixRoomUtils.Desktop/MainWindow.axaml.cs
diff options
context:
space:
mode:
Diffstat (limited to 'MatrixRoomUtils.Desktop/MainWindow.axaml.cs')
-rw-r--r--MatrixRoomUtils.Desktop/MainWindow.axaml.cs19
1 files changed, 15 insertions, 4 deletions
diff --git a/MatrixRoomUtils.Desktop/MainWindow.axaml.cs b/MatrixRoomUtils.Desktop/MainWindow.axaml.cs
index 41e0888..f89bbfa 100644
--- a/MatrixRoomUtils.Desktop/MainWindow.axaml.cs
+++ b/MatrixRoomUtils.Desktop/MainWindow.axaml.cs
@@ -1,5 +1,7 @@
 using Avalonia.Controls;
+using Avalonia.Data;
 using Avalonia.Interactivity;
+using MatrixRoomUtils.Web.Classes;
 using Microsoft.Extensions.DependencyInjection;
 using Microsoft.Extensions.Logging;
 
@@ -7,13 +9,18 @@ namespace MatrixRoomUtils.Desktop;
 
 public partial class MainWindow : Window {
     private readonly ILogger<MainWindow> _logger;
+    private readonly IServiceScopeFactory _scopeFactory;
     private readonly MRUStorageWrapper _storageWrapper;
     private readonly MRUDesktopConfiguration _configuration;
+    public static MainWindow Instance { get; private set; } = null!;
 
-    public MainWindow(ILogger<MainWindow> logger, IServiceScopeFactory scopeFactory) {
+    public MainWindow(ILogger<MainWindow> logger, IServiceScopeFactory scopeFactory, SentryService _) {
+        Instance = this;
         _logger = logger;
+        _scopeFactory = scopeFactory;
         _configuration = scopeFactory.CreateScope().ServiceProvider.GetRequiredService<MRUDesktopConfiguration>();
         _storageWrapper = scopeFactory.CreateScope().ServiceProvider.GetRequiredService<MRUStorageWrapper>();
+
         _logger.LogInformation("Initialising MainWindow");
 
         InitializeComponent();
@@ -22,15 +29,19 @@ public partial class MainWindow : Window {
         _logger.LogInformation("Data location: " + _configuration.DataStoragePath);
 
 
-        for (int i = 0; i < 100; i++) {
-            roomList.Children.Add(new RoomListEntry());
-        }
+        // for (int i = 0; i < 100; i++) {
+            // roomList.Children.Add(new RoomListEntry());
+        // }
     }
 
     // ReSharper disable once AsyncVoidMethod
     protected override async void OnLoaded(RoutedEventArgs e) {
         _logger.LogInformation("async onloaded override");
         var hs = await _storageWrapper.GetCurrentSessionOrPrompt();
+        var rooms = await hs.GetJoinedRooms();
+        foreach (var room in rooms) {
+            roomList.Children.Add(new RoomListEntry(_scopeFactory, new RoomInfo(room)));
+        }
         base.OnLoaded(e);
     }