about summary refs log tree commit diff
path: root/MatrixUtils.Web/Pages/Client/ClientComponents/ClientSyncWrapper.cs
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2024-05-03 19:40:00 +0200
committerRory& <root@rory.gay>2024-05-03 19:40:00 +0200
commit222f475dfd662980d5e0b9f27efa951f91604364 (patch)
tree71777992828134ee89249a7e37339bc4aa89ba86 /MatrixUtils.Web/Pages/Client/ClientComponents/ClientSyncWrapper.cs
parentCleanup, work on index2, some tooling updates (diff)
downloadMatrixUtils-222f475dfd662980d5e0b9f27efa951f91604364.tar.xz
All kinds of changes
Diffstat (limited to 'MatrixUtils.Web/Pages/Client/ClientComponents/ClientSyncWrapper.cs')
-rw-r--r--MatrixUtils.Web/Pages/Client/ClientComponents/ClientSyncWrapper.cs41
1 files changed, 41 insertions, 0 deletions
diff --git a/MatrixUtils.Web/Pages/Client/ClientComponents/ClientSyncWrapper.cs b/MatrixUtils.Web/Pages/Client/ClientComponents/ClientSyncWrapper.cs
new file mode 100644
index 0000000..16051b8
--- /dev/null
+++ b/MatrixUtils.Web/Pages/Client/ClientComponents/ClientSyncWrapper.cs
@@ -0,0 +1,41 @@
+using System.Collections.ObjectModel;
+using ArcaneLibs;
+using LibMatrix;
+using LibMatrix.Helpers;
+using LibMatrix.Homeservers;
+using LibMatrix.Responses;
+using MatrixUtils.Abstractions;
+
+namespace MatrixUtils.Web.Pages.Client.ClientComponents;
+
+public class ClientSyncWrapper(AuthenticatedHomeserverGeneric homeserver) : NotifyPropertyChanged {
+    private SyncHelper _syncHelper = new SyncHelper(homeserver) {
+        MinimumDelay = TimeSpan.FromMilliseconds(2000),
+        IsInitialSync = false
+    };
+    private string _status = "Loading...";
+
+    public ObservableCollection<StateEvent> AccountData { get; set; } = new();
+    public ObservableCollection<RoomInfo> Rooms { get; set; } = new();
+
+    public string Status {
+        get => _status;
+        set => SetField(ref _status, value);
+    }
+
+    public async Task Start() {
+        Task.Yield();
+        var resp = _syncHelper.EnumerateSyncAsync();
+        Status = $"[{DateTime.Now:s}] Syncing...";
+        await foreach (var response in resp) {
+            Task.Yield();
+            Status = $"[{DateTime.Now:s}] {response.Rooms?.Join?.Count ?? 0 + response.Rooms?.Invite?.Count ?? 0 + response.Rooms?.Leave?.Count ?? 0} rooms, {response.AccountData?.Events?.Count ?? 0} account data, {response.ToDevice?.Events?.Count ?? 0} to-device, {response.DeviceLists?.Changed?.Count ?? 0} device lists, {response.Presence?.Events?.Count ?? 0} presence updates";
+            await HandleSyncResponse(response);
+            await Task.Yield();
+        }
+    }
+
+    private async Task HandleSyncResponse(SyncResponse resp) {
+        
+    }
+}
\ No newline at end of file