diff --git a/MatrixRoomUtils.Web/Shared/IndexComponents/IndexUserItem.razor b/MatrixRoomUtils.Web/Shared/IndexComponents/IndexUserItem.razor
deleted file mode 100644
index 975da43..0000000
--- a/MatrixRoomUtils.Web/Shared/IndexComponents/IndexUserItem.razor
+++ /dev/null
@@ -1,54 +0,0 @@
-@using MatrixRoomUtils.Core.Extensions
-@inject ILocalStorageService LocalStorage
-@inject NavigationManager NavigationManager
-
-<div style="margin-bottom: 1em;">
- <img style="border-radius: 50%; height: 3em; width: 3em;" src="@_avatarUrl"/>
- <p style="margin-left: 1em; margin-top: -0.5em; display: inline-block;">
- <input type="radio" name="csa" checked="@(RuntimeCache.LastUsedToken == User.AccessToken)" onclick="@SetCurrent" style="text-decoration-line: unset;"/>
- <b>@User.Profile.DisplayName</b> on <b>@User.LoginResponse.HomeServer</b>
- <a href="#" onclick="@RemoveUser">Remove</a>
- </p>
- <p style="margin-top: -1.5em; margin-left: 4em;">Member of @_roomCount rooms</p>
-
-</div>
-
-@code {
-
- [Parameter]
- public UserInfo User { get; set; } = null!;
-
- private string? _avatarUrl { get; set; }
- private int _roomCount { get; set; } = 0;
-
- protected override async Task OnInitializedAsync() {
- await LocalStorageWrapper.LoadFromLocalStorage(LocalStorage);
-
- if (User.Profile.AvatarUrl != null && User.Profile.AvatarUrl != "")
- _avatarUrl = RuntimeCache.CurrentHomeServer.ResolveMediaUri(User.Profile.AvatarUrl);
- else _avatarUrl = "https://api.dicebear.com/6.x/identicon/svg?seed=" + User.LoginResponse.UserId;
- try {
- _roomCount = (await RuntimeCache.CurrentHomeServer.GetJoinedRooms()).Count;
- }
- catch {
- _roomCount = -1;
- }
- await base.OnInitializedAsync();
- }
-
- private async Task RemoveUser() {
- Console.WriteLine(User.ToJson());
- RuntimeCache.LoginSessions.Remove(User.AccessToken);
-
- StateHasChanged();
- }
-
- private async Task SetCurrent() {
- RuntimeCache.LastUsedToken = User.AccessToken;
- //RuntimeCache.CurrentHomeserver = await MatrixAuth.ResolveHomeserverFromWellKnown(LocalStorageWrapper.LoginSessions[Token].LoginResponse.HomeServer);
- await LocalStorageWrapper.SaveToLocalStorage(LocalStorage);
- await LocalStorageWrapper.InitialiseRuntimeVariables(LocalStorage);
- StateHasChanged();
- }
-
-}
\ No newline at end of file
diff --git a/MatrixRoomUtils.Web/Shared/InlineUserItem.razor b/MatrixRoomUtils.Web/Shared/InlineUserItem.razor
index 44f3b0a..a498c70 100644
--- a/MatrixRoomUtils.Web/Shared/InlineUserItem.razor
+++ b/MatrixRoomUtils.Web/Shared/InlineUserItem.razor
@@ -1,11 +1,12 @@
@using MatrixRoomUtils.Core.Responses
@using MatrixRoomUtils.Core.StateEventTypes
+@using MatrixRoomUtils.Core.Helpers
<div style="background-color: #ffffff11; border-radius: 0.5em; height: 1em; display: inline-block; vertical-align: middle;" alt="@UserId">
- <img style="@(ChildContent != null ? "vertical-align: baseline;" : "vertical-align: top;") width: 1em; height: 1em; border-radius: 50%;" src="@ProfileAvatar"/>
+ <img style="@(ChildContent is not null ? "vertical-align: baseline;" : "vertical-align: top;") width: 1em; height: 1em; border-radius: 50%;" src="@ProfileAvatar"/>
<span style="position: relative; top: -5px;">@ProfileName</span>
<div style="display: inline-block;">
- @if (ChildContent != null) {
+ @if (ChildContent is not null) {
@ChildContent
}
</div>
@@ -21,7 +22,7 @@
public ProfileResponse User { get; set; }
[Parameter]
- public string UserId { get; set; }
+ public string? UserId { get; set; }
[Parameter]
public string? ProfileAvatar { get; set; } = null;
@@ -33,19 +34,16 @@
protected override async Task OnInitializedAsync() {
await base.OnInitializedAsync();
- await LocalStorageWrapper.LoadFromLocalStorage(LocalStorage);
-
+ var hs = await MRUStorage.GetCurrentSession();
+
await _semaphoreSlim.WaitAsync();
- if (User == null) {
- if (UserId == null) {
- throw new ArgumentNullException(nameof(UserId));
- }
- User = await RuntimeCache.CurrentHomeServer.GetProfile(UserId);
- }
+ if (User == null && UserId == null)
+ throw new ArgumentNullException(nameof(UserId));
+ User ??= await hs.GetProfile(UserId);
+
- // UserId = User.;
- ProfileAvatar ??= RuntimeCache.CurrentHomeServer.ResolveMediaUri(User.AvatarUrl);
+ ProfileAvatar ??= MediaResolver.ResolveMediaUri(hs.FullHomeServerDomain, User.AvatarUrl);
ProfileName ??= User.DisplayName;
_semaphoreSlim.Release();
diff --git a/MatrixRoomUtils.Web/Shared/LogView.razor b/MatrixRoomUtils.Web/Shared/LogView.razor
index 2f83cb2..d541b82 100644
--- a/MatrixRoomUtils.Web/Shared/LogView.razor
+++ b/MatrixRoomUtils.Web/Shared/LogView.razor
@@ -1,42 +1,41 @@
-@using System.Text
-@if (LocalStorageWrapper.Settings.DeveloperSettings.EnableLogViewers) {
- <u>Logs</u>
- <br/>
- <pre>
- @_stringBuilder
- </pre>
-}
-
-@code {
- StringBuilder _stringBuilder = new();
-
- protected override async Task OnInitializedAsync() {
- await LocalStorageWrapper.LoadFromLocalStorage(LocalStorage);
- if (!LocalStorageWrapper.Settings.DeveloperSettings.EnableConsoleLogging) {
- Console.WriteLine("Console logging disabled!");
- var _sw = new StringWriter();
- Console.SetOut(_sw);
- Console.SetError(_sw);
- return;
- }
- if (!LocalStorageWrapper.Settings.DeveloperSettings.EnableLogViewers) return;
- //intecept stdout with textwriter to get logs
- var sw = new StringWriter(_stringBuilder);
- Console.SetOut(sw);
- Console.SetError(sw);
- //keep updated
- var length = 0;
- Task.Run(async () => {
- while (true) {
- await Task.Delay(100);
- if (_stringBuilder.Length != length) {
- StateHasChanged();
- length = _stringBuilder.Length;
- }
- }
- // ReSharper disable once FunctionNeverReturns - This is intentional behavior
- });
- await base.OnInitializedAsync();
- }
-
-}
\ No newline at end of file
+@* @using System.Text *@
+@* @if (LocalStorageWrapper.Settings.DeveloperSettings.EnableLogViewers) { *@
+@* <u>Logs</u> *@
+@* <br/> *@
+@* <pre> *@
+@* @_stringBuilder *@
+@* </pre> *@
+@* } *@
+@* *@
+@* @code { *@
+@* StringBuilder _stringBuilder = new(); *@
+@* *@
+@* protected override async Task OnInitializedAsync() { *@
+@* if (!LocalStorageWrapper.Settings.DeveloperSettings.EnableConsoleLogging) { *@
+@* Console.WriteLine("Console logging disabled!"); *@
+@* var _sw = new StringWriter(); *@
+@* Console.SetOut(_sw); *@
+@* Console.SetError(_sw); *@
+@* return; *@
+@* } *@
+@* if (!LocalStorageWrapper.Settings.DeveloperSettings.EnableLogViewers) return; *@
+@* //intecept stdout with textwriter to get logs *@
+@* var sw = new StringWriter(_stringBuilder); *@
+@* Console.SetOut(sw); *@
+@* Console.SetError(sw); *@
+@* //keep updated *@
+@* var length = 0; *@
+@* Task.Run(async () => { *@
+@* while (true) { *@
+@* await Task.Delay(100); *@
+@* if (_stringBuilder.Length != length) { *@
+@* StateHasChanged(); *@
+@* length = _stringBuilder.Length; *@
+@* } *@
+@* } *@
+@* // ReSharper disable once FunctionNeverReturns - This is intentional behavior *@
+@* }); *@
+@* await base.OnInitializedAsync(); *@
+@* } *@
+@* *@
+@* } *@
\ No newline at end of file
diff --git a/MatrixRoomUtils.Web/Shared/MainLayout.razor b/MatrixRoomUtils.Web/Shared/MainLayout.razor
index 317f9e6..691acbb 100644
--- a/MatrixRoomUtils.Web/Shared/MainLayout.razor
+++ b/MatrixRoomUtils.Web/Shared/MainLayout.razor
@@ -29,14 +29,14 @@
using var hc = new HttpClient();
var hr = await hc.SendAsync(new HttpRequestMessage(HttpMethod.Head, NavigationManager.ToAbsoluteUri("/MRU-BIN.tar.xz").AbsoluteUri));
showDownload = hr.StatusCode == HttpStatusCode.OK;
-
- await LocalStorageWrapper.LoadFromLocalStorage(LocalStorage);
- if (!LocalStorageWrapper.Settings.DeveloperSettings.EnableConsoleLogging) {
- Console.WriteLine("Console logging disabled!");
- var sw = new StringWriter();
- Console.SetOut(sw);
- Console.SetError(sw);
- }
+
+ // TODO: fix console logging toggle
+ // if (!LocalStorageWrapper.Settings.DeveloperSettings.EnableConsoleLogging) {
+ // Console.WriteLine("Console logging disabled!");
+ // var sw = new StringWriter();
+ // Console.SetOut(sw);
+ // Console.SetError(sw);
+ // }
await base.OnInitializedAsync();
}
diff --git a/MatrixRoomUtils.Web/Shared/NavMenu.razor b/MatrixRoomUtils.Web/Shared/NavMenu.razor
index 9ddbd84..5f9ad8a 100644
--- a/MatrixRoomUtils.Web/Shared/NavMenu.razor
+++ b/MatrixRoomUtils.Web/Shared/NavMenu.razor
@@ -24,11 +24,6 @@
<hr style="margin-bottom: 0em;"/>
</div>
<div class="nav-item px-3">
- <NavLink class="nav-link" href="Export">
- <span class="oi oi-plus" aria-hidden="true"></span> Export data
- </NavLink>
- </div>
- <div class="nav-item px-3">
<NavLink class="nav-link" href="RoomManager">
<span class="oi oi-plus" aria-hidden="true"></span> Manage Rooms
</NavLink>
diff --git a/MatrixRoomUtils.Web/Shared/PortableDevTools.razor b/MatrixRoomUtils.Web/Shared/PortableDevTools.razor
index ffd7082..8ca10a0 100644
--- a/MatrixRoomUtils.Web/Shared/PortableDevTools.razor
+++ b/MatrixRoomUtils.Web/Shared/PortableDevTools.razor
@@ -1,26 +1,26 @@
-@if (Enabled) {
- <a href="/DevOptions">Portable devtools (enabled)</a>
- <div id="PortableDevTools" style="position: fixed; bottom: 0; right: 0; min-width: 200px; min-height: 100px; background: #0002;" draggable>
- <p>Cache size: @RuntimeCache.GenericResponseCache.Sum(x => x.Value.Cache.Count)</p>
- </div>
-}
-else {
- <a href="/DevOptions">Portable devtools (disabled)</a>
-}
-
-@code {
- private bool Enabled { get; set; } = LocalStorageWrapper.Settings.DeveloperSettings.EnablePortableDevtools;
-
- protected override async Task OnInitializedAsync() =>
- // if(!RuntimeCache.WasLoaded)
- // await LocalStorageWrapper.LoadFromLocalStorage(LocalStorage);
- // StateHasChanged();
- Task.Run(async () => {
- while (true) {
- await Task.Delay(100);
- Enabled = LocalStorageWrapper.Settings.DeveloperSettings.EnablePortableDevtools;
- StateHasChanged();
- }
- });
-
-}
\ No newline at end of file
+@* @if (Enabled) { *@
+@* <a href="/DevOptions">Portable devtools (enabled)</a> *@
+@* <div id="PortableDevTools" style="position: fixed; bottom: 0; right: 0; min-width: 200px; min-height: 100px; background: #0002;" draggable> *@
+@* $1$ <p>Cache size: @RuntimeCache.GenericResponseCache.Sum(x => x.Value.Cache.Count)</p> #1# *@
+@* </div> *@
+@* } *@
+@* else { *@
+@* <a href="/DevOptions">Portable devtools (disabled)</a> *@
+@* } *@
+@* *@
+@* @code { *@
+@* private bool Enabled { get; set; } = LocalStorageWrapper.Settings.DeveloperSettings.EnablePortableDevtools; *@
+@* *@
+@* protected override async Task OnInitializedAsync() => *@
+@* // if(!RuntimeCache.WasLoaded) *@
+@* // await LocalStorageWrapper.LoadFromLocalStorage(LocalStorage); *@
+@* // StateHasChanged(); *@
+@* Task.Run(async () => { *@
+@* while (true) { *@
+@* await Task.Delay(100); *@
+@* Enabled = LocalStorageWrapper.Settings.DeveloperSettings.EnablePortableDevtools; *@
+@* StateHasChanged(); *@
+@* } *@
+@* }); *@
+@* *@
+@* } *@
\ No newline at end of file
diff --git a/MatrixRoomUtils.Web/Shared/RoomList.razor b/MatrixRoomUtils.Web/Shared/RoomList.razor
index ca93fa6..ac2cbb3 100644
--- a/MatrixRoomUtils.Web/Shared/RoomList.razor
+++ b/MatrixRoomUtils.Web/Shared/RoomList.razor
@@ -1,4 +1,5 @@
@using MatrixRoomUtils.Web.Shared.RoomListComponents;
+@using MatrixRoomUtils.Core.StateEventTypes
<p>@Rooms.Count rooms total, @RoomsWithTypes.Sum(x=>x.Value.Count) fetched so far...</p>
@foreach (var category in RoomsWithTypes.OrderBy(x => x.Value.Count)) {
<RoomListCategory Category="@category"></RoomListCategory>
@@ -7,15 +8,13 @@
@code {
[Parameter]
- public List<Room> Rooms { get; set; }
+ public List<GenericRoom> Rooms { get; set; }
- Dictionary<string, List<Room>> RoomsWithTypes = new();
+ Dictionary<string, List<GenericRoom>> RoomsWithTypes = new();
protected override async Task OnInitializedAsync() {
if (RoomsWithTypes.Any()) return;
- await LocalStorageWrapper.LoadFromLocalStorage(LocalStorage);
-
var tasks = Rooms.Select(AddRoom);
await Task.WhenAll(tasks);
@@ -31,17 +30,17 @@
private static SemaphoreSlim _semaphoreSlim = new SemaphoreSlim(8, 8);
- private async Task AddRoom(Room room) {
+ private async Task AddRoom(GenericRoom room) {
await _semaphoreSlim.WaitAsync();
- var roomType = GetRoomTypeName(await room.GetRoomType());
+ var roomType = GetRoomTypeName((await room.GetCreateEventAsync()).Type);
if (roomType == "Room") {
- var shortcodeState = await room.GetStateAsync("org.matrix.mjolnir.shortcode");
- if (shortcodeState.HasValue) roomType = "Legacy policy room";
+ var shortcodeState = await room.GetStateAsync<MjolnirShortcodeEventData>("org.matrix.mjolnir.shortcode");
+ if (shortcodeState is not null) roomType = "Legacy policy room";
}
if (!RoomsWithTypes.ContainsKey(roomType)) {
- RoomsWithTypes.Add(roomType, new List<Room>());
+ RoomsWithTypes.Add(roomType, new List<GenericRoom>());
}
RoomsWithTypes[roomType].Add(room);
diff --git a/MatrixRoomUtils.Web/Shared/RoomListComponents/RoomListCategory.razor b/MatrixRoomUtils.Web/Shared/RoomListComponents/RoomListCategory.razor
index ecdcc68..a7e9399 100644
--- a/MatrixRoomUtils.Web/Shared/RoomListComponents/RoomListCategory.razor
+++ b/MatrixRoomUtils.Web/Shared/RoomListComponents/RoomListCategory.razor
@@ -16,9 +16,9 @@
@code {
[Parameter]
- public KeyValuePair<string, List<Room>> Category { get; set; }
+ public KeyValuePair<string, List<GenericRoom>> Category { get; set; }
private string roomType => Category.Key;
- private List<Room> rooms => Category.Value;
+ private List<GenericRoom> rooms => Category.Value;
}
\ No newline at end of file
diff --git a/MatrixRoomUtils.Web/Shared/RoomListComponents/RoomListSpace.razor b/MatrixRoomUtils.Web/Shared/RoomListComponents/RoomListSpace.razor
index c90ae8f..5d106c3 100644
--- a/MatrixRoomUtils.Web/Shared/RoomListComponents/RoomListSpace.razor
+++ b/MatrixRoomUtils.Web/Shared/RoomListComponents/RoomListSpace.razor
@@ -14,7 +14,7 @@
@code {
[Parameter]
- public Room Space { get; set; }
+ public GenericRoom Space { get; set; }
[Parameter, CascadingParameter]
public string? Breadcrumbs {
@@ -22,7 +22,7 @@
set => _breadcrumbs = value;
}
- private List<Room> Children { get; set; } = new();
+ private List<GenericRoom> Children { get; set; } = new();
protected override async Task OnInitializedAsync() {
if (Breadcrumbs == null) throw new ArgumentNullException(nameof(Breadcrumbs));
diff --git a/MatrixRoomUtils.Web/Shared/RoomListItem.razor b/MatrixRoomUtils.Web/Shared/RoomListItem.razor
index 6dc0683..53219d6 100644
--- a/MatrixRoomUtils.Web/Shared/RoomListItem.razor
+++ b/MatrixRoomUtils.Web/Shared/RoomListItem.razor
@@ -1,15 +1,17 @@
@using MatrixRoomUtils.Core.Extensions
@using System.Text.Json
+@using MatrixRoomUtils.Core.Helpers
+@using MatrixRoomUtils.Core.StateEventTypes
<div class="roomListItem" style="background-color: #ffffff11; border-radius: 25px; margin: 8px; width: fit-Content; @(hasDangerousRoomVersion ? "border: red 4px solid;" : hasOldRoomVersion ? "border: #FF0 1px solid;" : "")">
@if (ShowOwnProfile) {
- <img class="imageUnloaded @(string.IsNullOrWhiteSpace(profileAvatar) ? "" : "imageLoaded")" style="@(ChildContent != null ? "vertical-align: baseline;" : "") width: 32px; height: 32px; border-radius: 50%; @(hasCustomProfileAvatar ? "border-color: red; border-width: 3px; border-style: dashed;" : "")" src="@(profileAvatar ?? "/icon-192.png")" />
+ <img class="imageUnloaded @(string.IsNullOrWhiteSpace(profileAvatar) ? "" : "imageLoaded")" style="@(ChildContent is not null ? "vertical-align: baseline;" : "") width: 32px; height: 32px; border-radius: 50%; @(hasCustomProfileAvatar ? "border-color: red; border-width: 3px; border-style: dashed;" : "")" src="@(profileAvatar ?? "/icon-192.png")"/>
<span style="vertical-align: middle; margin-right: 8px; border-radius: 75px; @(hasCustomProfileName ? "background-color: red;" : "")">@(profileName ?? "Loading...")</span>
<span style="vertical-align: middle; padding-right: 8px; padding-left: 0px;">-></span>
}
- <img style="@(ChildContent != null ? "vertical-align: baseline;" : "") width: 32px; height: 32px; border-radius: 50%;" src="@roomIcon"/>
+ <img style="@(ChildContent is not null ? "vertical-align: baseline;" : "") width: 32px; height: 32px; border-radius: 50%;" src="@roomIcon"/>
<div style="display: inline-block;">
<span style="vertical-align: middle; padding-right: 8px;">@RoomName</span>
- @if (ChildContent != null) {
+ @if (ChildContent is not null) {
@ChildContent
}
</div>
@@ -22,7 +24,7 @@
public RenderFragment? ChildContent { get; set; }
[Parameter]
- public Room Room { get; set; }
+ public GenericRoom Room { get; set; }
[Parameter]
public string RoomId { get; set; }
@@ -47,11 +49,11 @@
protected override async Task OnInitializedAsync() {
await base.OnInitializedAsync();
- await LocalStorageWrapper.LoadFromLocalStorage(LocalStorage);
await _semaphoreSlim.WaitAsync();
- var hs = RuntimeCache.CurrentHomeServer;
+ var hs = await MRUStorage.GetCurrentSessionOrNavigate();
+ if (hs is null) return;
if (Room == null) {
if (RoomId == null) {
@@ -66,7 +68,7 @@
RoomName ??= await Room.GetNameAsync() ?? "Unnamed room: " + RoomId;
var ce = await Room.GetCreateEventAsync();
- if (ce != null) {
+ if (ce is not null) {
if (int.TryParse(ce.RoomVersion, out var rv) && rv < 10) {
hasOldRoomVersion = true;
}
@@ -76,47 +78,37 @@
}
}
- var state = await Room.GetStateAsync("m.room.avatar");
- if (state != null) {
+ var state = await Room.GetStateAsync<RoomAvatarEventData>("m.room.avatar");
+ if (state is not null) {
try {
- var url = state.Value.GetProperty("url").GetString();
- if (url != null) {
- roomIcon = hs.ResolveMediaUri(url);
+ var url = state.Url;
+ if (url is not null) {
+ roomIcon = MediaResolver.ResolveMediaUri(hs.FullHomeServerDomain, url);
Console.WriteLine($"Got avatar for room {RoomId}: {roomIcon} ({url})");
}
}
catch (InvalidOperationException e) {
- Console.WriteLine($"Failed to get avatar for room {RoomId}: {e.Message}\n{state.Value.ToJson()}");
+ Console.WriteLine($"Failed to get avatar for room {RoomId}: {e.Message}\n{state.ToJson()}");
+ }
+ catch (Exception e) {
+ Console.WriteLine(e);
}
}
if (ShowOwnProfile) {
var profile = await hs.GetProfile(hs.UserId, true);
- var memberState = await Room.GetStateAsync("m.room.member", hs.UserId);
- if (memberState.HasValue) {
- memberState.Value.TryGetProperty("avatar_url", out var _avatar);
- if (_avatar.ValueKind == JsonValueKind.String) {
- hasCustomProfileAvatar = _avatar.GetString() != profile.AvatarUrl;
- profileAvatar = hs.ResolveMediaUri(_avatar.GetString());
- }
- else {
- profileAvatar = "/icon-192.png";
- }
- memberState.Value.TryGetProperty("displayname", out var _name);
- if (_name.ValueKind == JsonValueKind.String) {
- hasCustomProfileName = _name.GetString() != profile.DisplayName;
- profileName = _name.GetString();
- // Console.WriteLine($"{profile.DisplayName} - {_name.GetString()}: {hasCustomProfileName}");
- }
- else {
- profileName = "Unnamed user";
- }
+ var memberState = await Room.GetStateAsync<RoomMemberEventData>("m.room.member", hs.UserId);
+ if (memberState is not null) {
+
+ hasCustomProfileAvatar = memberState.AvatarUrl != profile.AvatarUrl;
+ profileAvatar = MediaResolver.ResolveMediaUri(hs.FullHomeServerDomain, memberState.AvatarUrl ?? profile.AvatarUrl ?? "/icon-192.png");
+
+ hasCustomProfileName = memberState.Displayname != profile.DisplayName;
+ profileName = memberState.Displayname;
}
}
_semaphoreSlim.Release();
- if (Random.Shared.Next(100) == 1)
- await LocalStorageWrapper.SaveCacheToLocalStorage(LocalStorage);
}
}
\ No newline at end of file
diff --git a/MatrixRoomUtils.Web/Shared/TimelineComponents/TimelineMemberItem.razor b/MatrixRoomUtils.Web/Shared/TimelineComponents/TimelineMemberItem.razor
index 598ae7e..b7e0220 100644
--- a/MatrixRoomUtils.Web/Shared/TimelineComponents/TimelineMemberItem.razor
+++ b/MatrixRoomUtils.Web/Shared/TimelineComponents/TimelineMemberItem.razor
@@ -1,23 +1,24 @@
-@using MatrixRoomUtils.Core
-@using Microsoft.AspNetCore.Components
-@if (Event.membership"]!.GetValue<string>() == "ban") {
+@using MatrixRoomUtils.Core.Responses
+@using MatrixRoomUtils.Core.StateEventTypes
+
+@if (roomMemberData.Membership == "ban") {
<i>@Event.StateKey was banned</i>
}
-else if (Event.membership"]!.GetValue<string>() == "invite") {
+else if (roomMemberData.Membership == "invite") {
<i>@Event.StateKey was invited</i>
}
-else if (Event.membership"]!.GetValue<string>() == "join") {
- @if (Event.ReplacesState != null) {
- <i>@Event.StateKey changed their display name to @(Event.displayname"]!.GetValue<string>())</i>
+else if (roomMemberData.Membership == "join") {
+ @if (Event.ReplacesState is not null) {
+ <i>@Event.StateKey changed their display name to @(roomMemberData.Displayname ?? Event.Sender)</i>
}
else {
<i><InlineUserItem UserId="@Event.StateKey"></InlineUserItem> joined</i>
}
}
-else if (Event.membership"]!.GetValue<string>() == "leave") {
+else if (roomMemberData.Membership == "leave") {
<i>@Event.StateKey left</i>
}
-else if (Event.membership"]!.GetValue<string>() == "knock") {
+else if (roomMemberData.Membership == "knock") {
<i>@Event.StateKey knocked</i>
}
else {
@@ -30,6 +31,8 @@ else {
@code {
[Parameter]
- public StateEvent Event { get; set; }
+ public StateEventResponse Event { get; set; }
+
+ private RoomMemberEventData? roomMemberData => Event.TypedContent as RoomMemberEventData;
}
\ No newline at end of file
diff --git a/MatrixRoomUtils.Web/Shared/TimelineComponents/TimelineMessageItem.razor b/MatrixRoomUtils.Web/Shared/TimelineComponents/TimelineMessageItem.razor
index 6c26dc2..b1ce146 100644
--- a/MatrixRoomUtils.Web/Shared/TimelineComponents/TimelineMessageItem.razor
+++ b/MatrixRoomUtils.Web/Shared/TimelineComponents/TimelineMessageItem.razor
@@ -1,6 +1,6 @@
@using MatrixRoomUtils.Core.Responses
<pre>
- @ObjectExtensions.ToJson(Event.Content, indent: false)
+ @ObjectExtensions.ToJson(Event.RawContent, indent: false)
</pre>
@code {
diff --git a/MatrixRoomUtils.Web/Shared/UserListItem.razor b/MatrixRoomUtils.Web/Shared/UserListItem.razor
index 9b3cff1..a41ce49 100644
--- a/MatrixRoomUtils.Web/Shared/UserListItem.razor
+++ b/MatrixRoomUtils.Web/Shared/UserListItem.razor
@@ -1,11 +1,12 @@
@using MatrixRoomUtils.Core.Responses
@using MatrixRoomUtils.Core.StateEventTypes
+@using MatrixRoomUtils.Core.Helpers
<div style="background-color: #ffffff11; border-radius: 25px; margin: 8px; width: fit-Content;">
- <img style="@(ChildContent != null ? "vertical-align: baseline;" : "") width: 32px; height: 32px; border-radius: 50%;" src="@profileAvatar"/>
+ <img style="@(ChildContent is not null ? "vertical-align: baseline;" : "") width: 32px; height: 32px; border-radius: 50%;" src="@profileAvatar"/>
<span style="vertical-align: middle; margin-right: 8px; border-radius: 75px;">@profileName</span>
<div style="display: inline-block;">
- @if (ChildContent != null) {
+ @if (ChildContent is not null) {
@ChildContent
}
</div>
@@ -30,24 +31,24 @@
protected override async Task OnInitializedAsync() {
await base.OnInitializedAsync();
- await LocalStorageWrapper.LoadFromLocalStorage(LocalStorage);
+ var hs = await MRUStorage.GetCurrentSessionOrNavigate();
+ if (hs is null) return;
+
await _semaphoreSlim.WaitAsync();
if (User == null) {
if (UserId == null) {
throw new ArgumentNullException(nameof(UserId));
}
- User = await RuntimeCache.CurrentHomeServer.GetProfile(UserId);
+ User = await hs.GetProfile(UserId);
}
// UserId = User.;
- profileAvatar = RuntimeCache.CurrentHomeServer.ResolveMediaUri(User.AvatarUrl);
+ profileAvatar = MediaResolver.ResolveMediaUri(hs.FullHomeServerDomain, User.AvatarUrl);
profileName = User.DisplayName;
_semaphoreSlim.Release();
- if (Random.Shared.Next(100) == 1)
- await LocalStorageWrapper.SaveCacheToLocalStorage(LocalStorage);
}
}
\ No newline at end of file
|