diff --git a/MatrixRoomUtils.Web/Pages/Index.razor b/MatrixRoomUtils.Web/Pages/Index.razor
index 804fde3..68a4f26 100644
--- a/MatrixRoomUtils.Web/Pages/Index.razor
+++ b/MatrixRoomUtils.Web/Pages/Index.razor
@@ -1,4 +1,5 @@
@page "/"
+@inject ILogger<Index> logger
@using LibMatrix.Responses
@using LibMatrix
@using LibMatrix.Homeservers
@@ -26,7 +27,6 @@ Small collection of tools to do not-so-everyday things.
<p>
<input type="radio" name="csa" checked="@(_currentSession.AccessToken == _auth.AccessToken)" @onclick="@(() => SwitchSession(_auth))" style="text-decoration-line: unset;"/>
<b>@__auth.UserInfo.DisplayName</b> on <b>@_auth.Homeserver</b><br/>
-
</p>
<span style="display: inline-block; width: 128px;">@__auth.UserInfo.RoomCount rooms</span>
<a style="color: #888888" href="@("/ServerInfo/"+__auth.Homeserver.ServerName+"/")">@__auth.ServerVersion.Server.Name @__auth.ServerVersion.Server.Version</a>
@@ -91,20 +91,24 @@ Small collection of tools to do not-so-everyday things.
}
throw;
}
+ catch (HttpRequestException e) {
+ logger.LogError(e, $"Failed to instantiate AuthenticatedHomeserver for {_auth}, homeserver may be offline?", token.UserId);
+ return;
+ }
var roomCountTask = hs.GetJoinedRooms();
var profile = await hs.GetProfileAsync(hs.WhoAmI.UserId);
userInfo.DisplayName = profile.DisplayName ?? hs.WhoAmI.UserId;
Console.WriteLine(profile.ToJson());
- userInfo.AvatarUrl = string.IsNullOrWhiteSpace(profile.AvatarUrl) ? "https://api.dicebear.com/6.x/identicon/svg?seed=" + hs.WhoAmI.UserId : hs.ResolveMediaUri(profile.AvatarUrl);
- userInfo.RoomCount = (await roomCountTask).Count;
- // _users.Add(token, userInfo);
_auth.Add(new() {
- UserInfo = userInfo,
+ UserInfo = new() {
+ AvatarUrl = string.IsNullOrWhiteSpace(profile.AvatarUrl) ? "https://api.dicebear.com/6.x/identicon/svg?seed=" + hs.WhoAmI.UserId : hs.ResolveMediaUri(profile.AvatarUrl),
+ RoomCount = (await roomCountTask).Count,
+ DisplayName = profile.DisplayName ?? hs.WhoAmI.UserId
+ },
UserAuth = token,
ServerVersion = await hs.GetServerVersionAsync(),
Homeserver = hs
});
- // StateHasChanged();
});
await Task.WhenAll(profileTasks);
await base.OnInitializedAsync();
diff --git a/MatrixRoomUtils.Web/Pages/Rooms/Index.razor b/MatrixRoomUtils.Web/Pages/Rooms/Index.razor
index 60f4f62..e137b6c 100644
--- a/MatrixRoomUtils.Web/Pages/Rooms/Index.razor
+++ b/MatrixRoomUtils.Web/Pages/Rooms/Index.razor
@@ -8,6 +8,7 @@
@using LibMatrix.Extensions
@using LibMatrix.Responses
@using System.Collections.ObjectModel
+@using System.Diagnostics
@inject ILogger<Index> logger
<h3>Room list</h3>
@@ -60,36 +61,36 @@
}
};
- private static SyncFilter profileUpdateFilter = new() {
- AccountData = new SyncFilter.EventFilter {
- NotTypes = new List<string> { "*" },
- Limit = 1
- },
- Presence = new SyncFilter.EventFilter {
- NotTypes = new List<string> { "*" },
- Limit = 1
- },
- Room = new SyncFilter.RoomFilter {
- AccountData = new SyncFilter.RoomFilter.StateFilter {
- NotTypes = new List<string> { "*" },
- Limit = 1
- },
- Ephemeral = new SyncFilter.RoomFilter.StateFilter {
- NotTypes = new List<string> { "*" },
- Limit = 1
- },
- State = new SyncFilter.RoomFilter.StateFilter {
- Types = new List<string> {
- "m.room.member"
- },
- Senders = new()
- },
- Timeline = new SyncFilter.RoomFilter.StateFilter {
- NotTypes = new List<string> { "*" },
- Limit = 1
- }
- }
- };
+ // private static SyncFilter profileUpdateFilter = new() {
+ // AccountData = new SyncFilter.EventFilter {
+ // NotTypes = new List<string> { "*" },
+ // Limit = 1
+ // },
+ // Presence = new SyncFilter.EventFilter {
+ // NotTypes = new List<string> { "*" },
+ // Limit = 1
+ // },
+ // Room = new SyncFilter.RoomFilter {
+ // AccountData = new SyncFilter.RoomFilter.StateFilter {
+ // NotTypes = new List<string> { "*" },
+ // Limit = 1
+ // },
+ // Ephemeral = new SyncFilter.RoomFilter.StateFilter {
+ // NotTypes = new List<string> { "*" },
+ // Limit = 1
+ // },
+ // State = new SyncFilter.RoomFilter.StateFilter {
+ // Types = new List<string> {
+ // "m.room.member"
+ // },
+ // Senders = new()
+ // },
+ // Timeline = new SyncFilter.RoomFilter.StateFilter {
+ // NotTypes = new List<string> { "*" },
+ // Limit = 1
+ // }
+ // }
+ // };
protected override async Task OnInitializedAsync() {
Homeserver = await MRUStorage.GetCurrentSessionOrNavigate();
@@ -103,20 +104,23 @@
var syncHelper = new SyncHelper(Homeserver, logger) {
Timeout = 10000,
- Filter = filter
- };
- profileUpdateFilter.Room.State.Senders.Add(Homeserver.WhoAmI.UserId);
- var profileSyncHelper = new SyncHelper(Homeserver, logger) {
- Timeout = 10000,
- Filter = profileUpdateFilter
+ Filter = filter,
+ MinimumDelay = TimeSpan.FromMilliseconds(5000)
};
+ // profileUpdateFilter.Room.State.Senders.Add(Homeserver.WhoAmI.UserId);
+ // var profileSyncHelper = new SyncHelper(Homeserver, logger) {
+ // Timeout = 10000,
+ // Filter = profileUpdateFilter,
+ // MinimumDelay = TimeSpan.FromMilliseconds(5000)
+ // };
RunSyncLoop(syncHelper);
- RunSyncLoop(profileSyncHelper);
+ // RunSyncLoop(profileSyncHelper);
RunQueueProcessor();
await base.OnInitializedAsync();
}
-
+
private async Task RunQueueProcessor() {
+ var renderTimeSw = Stopwatch.StartNew();
while (true) {
try {
if (queue.Count == 0) {
@@ -126,7 +130,7 @@
}
Console.WriteLine("Queue no longer empty!");
}
- if (queue.TryDequeue(out var queueEntry)) {
+ while (queue.TryDequeue(out var queueEntry)) {
var (roomId, roomData) = queueEntry;
Console.WriteLine($"Dequeued room {roomId}");
RoomInfo room;
@@ -159,9 +163,9 @@
if (queue.Count > 10) RenderContents = false;
await Task.Delay(RenderContents ? 25 : 25);
}
- else {
- Console.WriteLine("Failed to dequeue item");
- }
+ // else {
+ // Console.WriteLine("Failed to dequeue item");
+ // }
}
catch (Exception e) {
Console.WriteLine("QueueWorker exception: " + e);
|