diff --git a/MatrixRoomUtils.Web.Server/MatrixRoomUtils.Web.Server.csproj b/MatrixRoomUtils.Web.Server/MatrixRoomUtils.Web.Server.csproj
index f89a603..e7ea9aa 100644
--- a/MatrixRoomUtils.Web.Server/MatrixRoomUtils.Web.Server.csproj
+++ b/MatrixRoomUtils.Web.Server/MatrixRoomUtils.Web.Server.csproj
@@ -4,6 +4,7 @@
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
+ <LangVersion>preview</LangVersion>
</PropertyGroup>
<ItemGroup>
diff --git a/MatrixRoomUtils.Web/Classes/MRUStorageWrapper.cs b/MatrixRoomUtils.Web/Classes/MRUStorageWrapper.cs
index 14625fd..8ea85e9 100644
--- a/MatrixRoomUtils.Web/Classes/MRUStorageWrapper.cs
+++ b/MatrixRoomUtils.Web/Classes/MRUStorageWrapper.cs
@@ -1,4 +1,5 @@
using LibMatrix;
+using LibMatrix.Homeservers;
using LibMatrix.Responses;
using LibMatrix.Services;
using Microsoft.AspNetCore.Components;
@@ -20,13 +21,13 @@ public class MRUStorageWrapper {
_navigationManager = navigationManager;
}
- public async Task<List<LoginResponse>?> GetAllTokens() {
- return await _storageService.DataStorageProvider.LoadObjectAsync<List<LoginResponse>>("mru.tokens") ??
- new List<LoginResponse>();
+ public async Task<List<UserAuth>?> GetAllTokens() {
+ return await _storageService.DataStorageProvider.LoadObjectAsync<List<UserAuth>>("mru.tokens") ??
+ new List<UserAuth>();
}
- public async Task<LoginResponse?> GetCurrentToken() {
- var currentToken = await _storageService.DataStorageProvider.LoadObjectAsync<LoginResponse>("token");
+ public async Task<UserAuth?> GetCurrentToken() {
+ var currentToken = await _storageService.DataStorageProvider.LoadObjectAsync<UserAuth>("token");
var allTokens = await GetAllTokens();
if (allTokens is null or { Count: 0 }) {
await SetCurrentToken(null);
@@ -44,14 +45,14 @@ public class MRUStorageWrapper {
return currentToken;
}
- public async Task AddToken(LoginResponse loginResponse) {
- var tokens = await GetAllTokens() ?? new List<LoginResponse>();
+ public async Task AddToken(UserAuth UserAuth) {
+ var tokens = await GetAllTokens() ?? new List<UserAuth>();
- tokens.Add(loginResponse);
+ tokens.Add(UserAuth);
await _storageService.DataStorageProvider.SaveObjectAsync("mru.tokens", tokens);
}
- private async Task<AuthenticatedHomeServer?> GetCurrentSession() {
+ private async Task<AuthenticatedHomeserverGeneric?> GetCurrentSession() {
var token = await GetCurrentToken();
if (token == null) {
return null;
@@ -60,8 +61,8 @@ public class MRUStorageWrapper {
return await _homeserverProviderService.GetAuthenticatedWithToken(token.Homeserver, token.AccessToken);
}
- public async Task<AuthenticatedHomeServer?> GetCurrentSessionOrNavigate() {
- AuthenticatedHomeServer? session = null;
+ public async Task<AuthenticatedHomeserverGeneric?> GetCurrentSessionOrNavigate() {
+ AuthenticatedHomeserverGeneric? session = null;
try {
//catch if the token is invalid
@@ -94,7 +95,7 @@ public class MRUStorageWrapper {
public bool EnablePortableDevtools { get; set; }
}
- public async Task RemoveToken(LoginResponse auth) {
+ public async Task RemoveToken(UserAuth auth) {
var tokens = await GetAllTokens();
if (tokens == null) {
return;
@@ -104,5 +105,5 @@ public class MRUStorageWrapper {
await _storageService.DataStorageProvider.SaveObjectAsync("mru.tokens", tokens);
}
- public async Task SetCurrentToken(LoginResponse? auth) => await _storageService.DataStorageProvider.SaveObjectAsync("token", auth);
+ public async Task SetCurrentToken(UserAuth? auth) => await _storageService.DataStorageProvider.SaveObjectAsync("token", auth);
}
diff --git a/MatrixRoomUtils.Web/Classes/RoomCreationTemplates/DefaultRoomCreationTemplate.cs b/MatrixRoomUtils.Web/Classes/RoomCreationTemplates/DefaultRoomCreationTemplate.cs
index bb2eab9..3f67f33 100644
--- a/MatrixRoomUtils.Web/Classes/RoomCreationTemplates/DefaultRoomCreationTemplate.cs
+++ b/MatrixRoomUtils.Web/Classes/RoomCreationTemplates/DefaultRoomCreationTemplate.cs
@@ -2,7 +2,6 @@ using System.Text.Json.Nodes;
using LibMatrix;
using LibMatrix.Responses;
using LibMatrix.StateEventTypes.Spec;
-using LibMatrix.StateEventTypes;
namespace MatrixRoomUtils.Web.Classes.RoomCreationTemplates;
@@ -16,39 +15,39 @@ public class DefaultRoomCreationTemplate : IRoomCreationTemplate {
InitialState = new List<StateEvent> {
new() {
Type = "m.room.history_visibility",
- TypedContent = new {
- history_visibility = "world_readable"
+ TypedContent = new HistoryVisibilityEventContent() {
+ HistoryVisibility = "world_readable"
}
},
new() {
Type = "m.room.guest_access",
- TypedContent = new GuestAccessEventData {
+ TypedContent = new GuestAccessEventContent {
GuestAccess = "can_join"
}
},
new() {
Type = "m.room.join_rules",
- TypedContent = new JoinRulesEventData {
+ TypedContent = new JoinRulesEventContent {
JoinRule = "public"
}
},
new() {
Type = "m.room.server_acl",
- TypedContent = new {
- allow = new[] { "*" },
- deny = Array.Empty<string>(),
- allow_ip_literals = false
+ TypedContent = new ServerACLEventContent() {
+ Allow = new List<string>() { "*" },
+ Deny = new List<string>(),
+ AllowIpLiterals = false
}
},
new() {
Type = "m.room.avatar",
- TypedContent = new RoomAvatarEventData {
+ TypedContent = new RoomAvatarEventContent {
Url = "mxc://feline.support/UKNhEyrVsrAbYteVvZloZcFj"
}
}
},
Visibility = "public",
- PowerLevelContentOverride = new RoomPowerLevelEventData {
+ PowerLevelContentOverride = new RoomPowerLevelEventContent {
UsersDefault = 0,
EventsDefault = 100,
StateDefault = 50,
@@ -56,10 +55,10 @@ public class DefaultRoomCreationTemplate : IRoomCreationTemplate {
Redact = 50,
Kick = 50,
Ban = 50,
- NotificationsPl = new RoomPowerLevelEventData.NotificationsPL {
+ NotificationsPl = new RoomPowerLevelEventContent.NotificationsPL {
Room = 50
},
- Events = new Dictionary<string, int> {
+ Events = new() {
{ "im.vector.modular.widgets", 50 },
{ "io.element.voice_broadcast_info", 50 },
{ "m.reaction", 100 },
@@ -78,7 +77,7 @@ public class DefaultRoomCreationTemplate : IRoomCreationTemplate {
{ "org.matrix.msc3401.call", 50 },
{ "org.matrix.msc3401.call.member", 50 }
},
- Users = new Dictionary<string, int> {
+ Users = new() {
// { RuntimeCache.CurrentHomeServer.UserId, 100 }
//TODO: re-implement this
}
diff --git a/MatrixRoomUtils.Web/Classes/RoomInfo.cs b/MatrixRoomUtils.Web/Classes/RoomInfo.cs
index 111bfe0..0e21871 100644
--- a/MatrixRoomUtils.Web/Classes/RoomInfo.cs
+++ b/MatrixRoomUtils.Web/Classes/RoomInfo.cs
@@ -1,4 +1,5 @@
using LibMatrix;
+using LibMatrix.Interfaces;
using LibMatrix.Responses;
using LibMatrix.RoomTypes;
@@ -17,7 +18,7 @@ public class RoomInfo {
StateKey = stateKey
};
try {
- @event.TypedContent = await Room.GetStateAsync<object>(type, stateKey);
+ @event.TypedContent = await Room.GetStateAsync<EventContent>(type, stateKey);
}
catch (MatrixException e) {
if (e is { ErrorCode: "M_NOT_FOUND" }) @event.TypedContent = default!;
diff --git a/MatrixRoomUtils.Web/Classes/UserAuth.cs b/MatrixRoomUtils.Web/Classes/UserAuth.cs
new file mode 100644
index 0000000..e6f0954
--- /dev/null
+++ b/MatrixRoomUtils.Web/Classes/UserAuth.cs
@@ -0,0 +1,15 @@
+using LibMatrix.Responses;
+
+namespace MatrixRoomUtils.Web.Classes;
+
+public class UserAuth : LoginResponse {
+ public UserAuth() { }
+ public UserAuth(LoginResponse login) {
+ Homeserver = login.Homeserver;
+ UserId = login.UserId;
+ AccessToken = login.AccessToken;
+ DeviceId = login.DeviceId;
+ }
+
+ public string? Proxy { get; set; }
+}
diff --git a/MatrixRoomUtils.Web/MatrixRoomUtils.Web.csproj b/MatrixRoomUtils.Web/MatrixRoomUtils.Web.csproj
index fce3cfd..3c8d362 100644
--- a/MatrixRoomUtils.Web/MatrixRoomUtils.Web.csproj
+++ b/MatrixRoomUtils.Web/MatrixRoomUtils.Web.csproj
@@ -5,17 +5,23 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UseBlazorWebAssembly>true</UseBlazorWebAssembly>
+ <LinkIncremental>true</LinkIncremental>
+ <LangVersion>preview</LangVersion>
</PropertyGroup>
<ItemGroup>
- <PackageReference Include="Blazored.LocalStorage" Version="4.3.0" />
- <PackageReference Include="Blazored.SessionStorage" Version="2.3.0" />
+ <PackageReference Include="Blazored.LocalStorage" Version="4.4.0" />
+ <PackageReference Include="Blazored.SessionStorage" Version="2.4.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="7.0.10" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="7.0.10" PrivateAssets="all" />
</ItemGroup>
<ItemGroup>
+
+ <ProjectReference Condition="Exists('..\ArcaneLibs\ArcaneLibs.Blazor.Components\ArcaneLibs.Blazor.Components.csproj')" Include="..\ArcaneLibs\ArcaneLibs.Blazor.Components\ArcaneLibs.Blazor.Components.csproj" />
+ <PackageReference Condition="!Exists('..\ArcaneLibs\ArcaneLibs.Blazor.Components\ArcaneLibs.Blazor.Components.csproj')" Include="ArcaneLibs" Version="*-preview*" />
<ProjectReference Include="..\LibMatrix\LibMatrix\LibMatrix.csproj" />
</ItemGroup>
+
</Project>
diff --git a/MatrixRoomUtils.Web/Pages/About.razor b/MatrixRoomUtils.Web/Pages/About.razor
index 48c7686..17ed04a 100644
--- a/MatrixRoomUtils.Web/Pages/About.razor
+++ b/MatrixRoomUtils.Web/Pages/About.razor
@@ -1,6 +1,5 @@
@page "/About"
@using System.Net
-@using System.Net.Sockets
@inject NavigationManager NavigationManager
@inject ILocalStorageService LocalStorage
diff --git a/MatrixRoomUtils.Web/Pages/DebugTools.razor b/MatrixRoomUtils.Web/Pages/DebugTools.razor
index afb1da2..5d47277 100644
--- a/MatrixRoomUtils.Web/Pages/DebugTools.razor
+++ b/MatrixRoomUtils.Web/Pages/DebugTools.razor
@@ -1,7 +1,9 @@
@page "/Debug"
@using System.Reflection
+@using ArcaneLibs.Extensions
+@using LibMatrix
@using LibMatrix.Extensions
-@using LibMatrix.Interfaces
+@using LibMatrix.Homeservers
@inject ILocalStorageService LocalStorage
@inject NavigationManager NavigationManager
<h3>Debug Tools</h3>
@@ -50,7 +52,7 @@ else {
string get_request_result { get; set; } = "";
private async Task SendGetRequest() {
- var field = typeof(IHomeServer).GetRuntimeFields().First(x => x.ToString().Contains("<_httpClient>k__BackingField"));
+ var field = typeof(RemoteHomeServer).GetRuntimeFields().First(x => x.ToString().Contains("<_httpClient>k__BackingField"));
var hs = await MRUStorage.GetCurrentSessionOrNavigate();
if (hs == null) return;
var httpClient = field.GetValue(hs) as MatrixHttpClient;
diff --git a/MatrixRoomUtils.Web/Pages/DevOptions.razor b/MatrixRoomUtils.Web/Pages/DevOptions.razor
index bf499a3..8511a26 100644
--- a/MatrixRoomUtils.Web/Pages/DevOptions.razor
+++ b/MatrixRoomUtils.Web/Pages/DevOptions.razor
@@ -1,5 +1,6 @@
@page "/DevOptions"
@using LibMatrix.Extensions
+@using ArcaneLibs.Extensions
@inject NavigationManager NavigationManager
@inject ILocalStorageService LocalStorage
diff --git a/MatrixRoomUtils.Web/Pages/HSAdmin/RoomQuery.razor b/MatrixRoomUtils.Web/Pages/HSAdmin/RoomQuery.razor
index 679f324..a4f9d97 100644
--- a/MatrixRoomUtils.Web/Pages/HSAdmin/RoomQuery.razor
+++ b/MatrixRoomUtils.Web/Pages/HSAdmin/RoomQuery.razor
@@ -1,8 +1,10 @@
@page "/HSAdmin/RoomQuery"
-@using MatrixRoomUtils.Web.Shared.SimpleComponents
@using LibMatrix.Responses.Admin
@using LibMatrix.Filters
@using LibMatrix.Extensions
+@using LibMatrix
+@using LibMatrix.Homeservers
+@using ArcaneLibs.Extensions
<h3>Homeserver Administration - Room Query</h3>
@@ -168,15 +170,17 @@
private async Task Search() {
Results.Clear();
var hs = await MRUStorage.GetCurrentSessionOrNavigate();
- if (hs is null) return;
- var searchRooms = hs.Admin.SearchRoomsAsync(orderBy: OrderBy!, dir: Ascending ? "f" : "b", searchTerm: SearchTerm, localFilter: Filter).GetAsyncEnumerator();
- while (await searchRooms.MoveNextAsync()) {
- var room = searchRooms.Current;
- Console.WriteLine("Hit: " + room.ToJson(false));
- Results.Add(room);
- if (Results.Count % 10 == 0)
- StateHasChanged();
+ if (hs is AuthenticatedHomeserverSynapse synapse) {
+ var searchRooms = synapse.Admin.SearchRoomsAsync(orderBy: OrderBy!, dir: Ascending ? "f" : "b", searchTerm: SearchTerm, localFilter: Filter).GetAsyncEnumerator();
+ while (await searchRooms.MoveNextAsync()) {
+ var room = searchRooms.Current;
+ Console.WriteLine("Hit: " + room.ToJson(false));
+ Results.Add(room);
+ if (Results.Count % 10 == 0)
+ StateHasChanged();
+ }
}
+
}
private readonly Dictionary<string, string> validOrderBy = new() {
diff --git a/MatrixRoomUtils.Web/Pages/Index.razor b/MatrixRoomUtils.Web/Pages/Index.razor
index 1004ee3..e02c733 100644
--- a/MatrixRoomUtils.Web/Pages/Index.razor
+++ b/MatrixRoomUtils.Web/Pages/Index.razor
@@ -1,8 +1,9 @@
@page "/"
-@using MatrixRoomUtils.Web.Shared.SimpleComponents
@using LibMatrix.Responses
@using LibMatrix
@using LibMatrix.Helpers
+@using LibMatrix.Homeservers
+@using ArcaneLibs.Extensions
<PageTitle>Index</PageTitle>
@@ -13,25 +14,38 @@ Small collection of tools to do not-so-everyday things.
<h5>Signed in accounts - <a href="/Login">Add new account</a></h5>
<hr/>
<form>
- @foreach (var (auth, user) in _users.OrderByDescending(x=>x.Value.RoomCount)) {
- var _auth = auth;
- <div style="margin-bottom: 1em;">
- <img style="border-radius: 50%; height: 3em; width: 3em;" src="@user.AvatarUrl"/>
- <p style="margin-left: 1em; margin-top: -0.5em; display: inline-block;">
- <input type="radio" name="csa" checked="@(_currentSession.AccessToken == _auth.AccessToken)" @onclick="@(()=>SwitchSession(_auth))" style="text-decoration-line: unset;"/>
- <b>@user.DisplayName</b> on <b>@_auth.Homeserver</b>
- <a role="button" @onclick="@(() => RemoveUser(_auth))">Remove</a>
+ <table>
+ @foreach (var (auth, user) in _users.OrderByDescending(x => x.Value.RoomCount)) {
+ var _auth = auth;
+ <tr class="user-entry">
+ <td>
+ <img class="avatar" src="@user.AvatarUrl"/>
+ </td>
+ <td class="user-info">
+ @* <div class="user-info"> *@
+ <p>
+ <input type="radio" name="csa" checked="@(_currentSession.AccessToken == _auth.AccessToken)" @onclick="@(() => SwitchSession(_auth))" style="text-decoration-line: unset;"/>
+ <b>@user.DisplayName</b> on <b>@_auth.Homeserver</b>
+ </p>
+ <p>Member of @user.RoomCount rooms</p>
- </p>
- <p style="margin-top: -1.5em; margin-left: 4em;">Member of @user.RoomCount rooms</p>
-
- </div>
- }
+ <p>Not proxied</p>
+ </td>
+ <td>
+ <p>
+ <LinkButton href="">Manage</LinkButton>
+ <LinkButton OnClick="@(() => RemoveUser(_auth))">Remove</LinkButton>
+ </p>
+ </td>
+ @* </div> *@
+ </tr>
+ }
+ </table>
</form>
@code
{
- private Dictionary<LoginResponse, UserInfo> _users = new();
+ private Dictionary<UserAuth, UserInfo> _users = new();
protected override async Task OnInitializedAsync() {
_currentSession = await MRUStorage.GetCurrentToken();
@@ -39,13 +53,13 @@ Small collection of tools to do not-so-everyday things.
var tokens = await MRUStorage.GetAllTokens();
var profileTasks = tokens.Select(async token => {
UserInfo userInfo = new();
- AuthenticatedHomeServer hs;
+ AuthenticatedHomeserverGeneric hs;
try {
hs = await HomeserverProvider.GetAuthenticatedWithToken(token.Homeserver, token.AccessToken);
}
catch (MatrixException e) {
if (e.ErrorCode == "M_UNKNOWN_TOKEN") {
- NavigationManager.NavigateTo("/InvalidSession?ctx="+token.AccessToken);
+ NavigationManager.NavigateTo("/InvalidSession?ctx=" + token.AccessToken);
return;
}
throw;
@@ -53,6 +67,7 @@ Small collection of tools to do not-so-everyday things.
var roomCountTask = hs.GetJoinedRooms();
var profile = await hs.GetProfile(hs.WhoAmI.UserId);
userInfo.DisplayName = profile.DisplayName ?? hs.WhoAmI.UserId;
+ Console.WriteLine(profile.ToJson());
userInfo.AvatarUrl = MediaResolver.ResolveMediaUri(hs.FullHomeServerDomain,
profile.AvatarUrl
?? "https://api.dicebear.com/6.x/identicon/svg?seed=" + hs.WhoAmI.UserId
@@ -71,7 +86,7 @@ Small collection of tools to do not-so-everyday things.
internal int RoomCount { get; set; }
}
- private async Task RemoveUser(LoginResponse auth) {
+ private async Task RemoveUser(UserAuth auth) {
await MRUStorage.RemoveToken(auth);
if ((await MRUStorage.GetCurrentToken()).AccessToken == auth.AccessToken)
MRUStorage.SetCurrentToken((await MRUStorage.GetAllTokens()).FirstOrDefault());
@@ -80,8 +95,8 @@ Small collection of tools to do not-so-everyday things.
private LoginResponse _currentSession;
- private async Task SwitchSession(LoginResponse auth) {
- Console.WriteLine($"Switching to {auth.Homeserver} {auth.AccessToken} {auth.UserId}");
+ private async Task SwitchSession(UserAuth auth) {
+ Console.WriteLine($"Switching to {auth.Homeserver} {auth.UserId} via {auth.Proxy}");
await MRUStorage.SetCurrentToken(auth);
await OnInitializedAsync();
}
diff --git a/MatrixRoomUtils.Web/Pages/Index.razor.css b/MatrixRoomUtils.Web/Pages/Index.razor.css
new file mode 100644
index 0000000..c6b7bd7
--- /dev/null
+++ b/MatrixRoomUtils.Web/Pages/Index.razor.css
@@ -0,0 +1,25 @@
+.user-entry {
+ margin-bottom: 1em;
+}
+
+.avatar {
+ width: 4em;
+ height: 4em;
+ border-radius: 50%;
+ margin-right: 0.5em;
+ vertical-align: middle;
+}
+
+.user-entry > td {
+ margin-right: 0.5em;
+ vertical-align: middle;
+}
+
+.user-info {
+ margin-bottom: 0.5em;
+ display: inline-block;
+ vertical-align: middle;
+}
+.user-info > p {
+ margin: 0;
+}
diff --git a/MatrixRoomUtils.Web/Pages/InvalidSession.razor b/MatrixRoomUtils.Web/Pages/InvalidSession.razor
index f555be5..310abb1 100644
--- a/MatrixRoomUtils.Web/Pages/InvalidSession.razor
+++ b/MatrixRoomUtils.Web/Pages/InvalidSession.razor
@@ -1,5 +1,4 @@
@page "/InvalidSession"
-@using MatrixRoomUtils.Web.Shared.SimpleComponents
@using LibMatrix.Responses
@using LibMatrix
@@ -33,7 +32,7 @@ else {
[SupplyParameterFromQuery(Name = "ctx")]
public string Context { get; set; }
- private LoginResponse? _login { get; set; }
+ private UserAuth? _login { get; set; }
private bool _showRefreshDialog { get; set; }
@@ -70,7 +69,7 @@ else {
await Task.CompletedTask;
}
- private async Task SwitchSession(LoginResponse auth) {
+ private async Task SwitchSession(UserAuth auth) {
Console.WriteLine($"Switching to {auth.Homeserver} {auth.AccessToken} {auth.UserId}");
await MRUStorage.SetCurrentToken(auth);
await OnInitializedAsync();
@@ -79,7 +78,7 @@ else {
private async Task TryLogin() {
if(_login is null) throw new NullReferenceException("Login is null!");
try {
- var result = await HomeserverProvider.Login(_login.Homeserver, _login.UserId, _password);
+ var result = new UserAuth(await HomeserverProvider.Login(_login.Homeserver, _login.UserId, _password));
if (result is null) {
Console.WriteLine($"Failed to login to {_login.Homeserver} as {_login.UserId}!");
return;
diff --git a/MatrixRoomUtils.Web/Pages/KnownHomeserverList.razor b/MatrixRoomUtils.Web/Pages/KnownHomeserverList.razor
index 22a004d..4cd2032 100644
--- a/MatrixRoomUtils.Web/Pages/KnownHomeserverList.razor
+++ b/MatrixRoomUtils.Web/Pages/KnownHomeserverList.razor
@@ -1,10 +1,10 @@
@page "/KnownHomeserverList"
-@using System.Text.Json
@using System.Diagnostics
+@using ArcaneLibs.Extensions
@using LibMatrix
@using LibMatrix.Extensions
+@using LibMatrix.Homeservers
@using LibMatrix.RoomTypes
-@using LibMatrix.StateEventTypes
<h3>Known Homeserver List</h3>
<hr/>
@@ -36,7 +36,7 @@ else {
List<HomeServerInfo> HomeServers = new();
bool IsFinished { get; set; }
HomeServerInfoQueryProgress QueryProgress { get; set; } = new();
- AuthenticatedHomeServer hs { get; set; }
+ AuthenticatedHomeserverGeneric hs { get; set; }
protected override async Task OnInitializedAsync() {
hs = await MRUStorage.GetCurrentSessionOrNavigate();
if (hs is null) return;
@@ -91,7 +91,7 @@ else {
- // states.RemoveAll(x => x.Type != "m.room.member" || (x.TypedContent as RoomMemberEventData).Membership != "join");
+ // states.RemoveAll(x => x.Type != "m.room.member" || (x.TypedContent as RoomMemberEventContent).Membership != "join");
// Console.WriteLine($"Room {room.RoomId} has {states.Count} members");
// if (states.Count > memberLimit) {
// Console.WriteLine("Skipping!");
diff --git a/MatrixRoomUtils.Web/Pages/LoginPage.razor b/MatrixRoomUtils.Web/Pages/LoginPage.razor
index 9730cbe..a6ce469 100644
--- a/MatrixRoomUtils.Web/Pages/LoginPage.razor
+++ b/MatrixRoomUtils.Web/Pages/LoginPage.razor
@@ -1,7 +1,6 @@
@page "/Login"
@using System.Text.Json
@using LibMatrix.Responses
-@using MatrixRoomUtils.Web.Shared.SimpleComponents
@inject ILocalStorageService LocalStorage
@inject IJSRuntime JsRuntime
<h3>Login</h3>
@@ -12,6 +11,8 @@
--><FancyTextBox @bind-Value="@newRecordInput.username"></FancyTextBox><!--
--><span>:</span><!--
--><FancyTextBox @bind-Value="@newRecordInput.homeserver"></FancyTextBox>
+ via
+ <FancyTextBox @bind-Value="@newRecordInput.password" IsPassword="true"></FancyTextBox>
</span>
<span style="display: block;">
<label>Password:</label>
@@ -29,13 +30,27 @@
<thead>
<td>Username</td>
<td>Homeserver</td>
+ <td>Password</td>
+ <td>Proxy</td>
</thead>
- @foreach (var (homeserver, username, password) in records) {
- var record = (homeserver, username, password);
- <tr style="background-color: @(LoggedInSessions.Any(x => x.UserId == $"@{username}:{homeserver}") ? "green" : "unset")">
- <td style="border-width: 1px;">@username</td>
- <td style="border-width: 1px;">@homeserver</td>
- <td><a role="button" @onclick="() => records.Remove(record)">Remove</a></td>
+ @foreach (var record in records) {
+ var r = record;
+ <tr style="background-color: @(LoggedInSessions.Any(x => x.UserId == $"@{r.username}:{r.homeserver}" && x.Proxy == r.proxy) ? "green" : "unset")">
+ <td style="border-width: 1px;">
+ <FancyTextBox @bind-Value="@r.homeserver"></FancyTextBox>
+ </td>
+ <td style="border-width: 1px;">
+ <FancyTextBox @bind-Value="@r.username"></FancyTextBox>
+ </td>
+ <td style="border-width: 1px;">
+ <FancyTextBox @bind-Value="@r.password" IsPassword="true"></FancyTextBox>
+ </td>
+ <td style="border-width: 1px;">
+ <FancyTextBox @bind-Value="@r.proxy"></FancyTextBox>
+ </td>
+ <td>
+ <a role="button" @onclick="() => records.Remove(r)">Remove</a>
+ </td>
</tr>
}
</table>
@@ -45,17 +60,19 @@
<LogView></LogView>
@code {
- readonly List<(string homeserver, string username, string password)> records = new();
- (string homeserver, string username, string password) newRecordInput = ("", "", "");
+ readonly List<(string homeserver, string username, string password, string? proxy)> records = new();
+ (string homeserver, string username, string password, string? proxy) newRecordInput = ("", "", "", null);
- List<LoginResponse> LoggedInSessions { get; set; } = new();
+ List<UserAuth>? LoggedInSessions { get; set; } = new();
async Task Login() {
var loginTasks = records.Select(async record => {
- var (homeserver, username, password) = record;
- if (LoggedInSessions.Any(x => x.UserId == $"@{username}:{homeserver}")) return;
+ var (homeserver, username, password, proxy) = record;
+ if (LoggedInSessions.Any(x => x.UserId == $"@{username}:{homeserver}" && x.Proxy == proxy)) return;
try {
- var result = await HomeserverProvider.Login(homeserver, username, password);
+ var result = new UserAuth(await HomeserverProvider.Login(homeserver, username, password, proxy)) {
+ Proxy = proxy
+ };
if (result == null) {
Console.WriteLine($"Failed to login to {homeserver} as {username}!");
return;
@@ -81,20 +98,21 @@
}));
await using var rs = obj.File.OpenReadStream();
using var sr = new StreamReader(rs);
- var TsvData = await sr.ReadToEndAsync();
+ var tsvData = await sr.ReadToEndAsync();
records.Clear();
- foreach (var line in TsvData.Split('\n')) {
- var parts = line.Split('\t');
- if (parts.Length != 3)
+ foreach (var line in tsvData.Split('\n')) {
+ string?[] parts = line.Split('\t');
+ if (parts.Length < 3)
continue;
- records.Add((parts[0], parts[1], parts[2]));
+ string? via = parts.Length > 3 ? parts[3] : null;
+ records.Add((parts[0], parts[1], parts[2], via));
}
}
private async Task AddRecord() {
LoggedInSessions = await MRUStorage.GetAllTokens();
records.Add(newRecordInput);
- newRecordInput = ("", "", "");
+ newRecordInput = ("", "", "", null);
}
}
diff --git a/MatrixRoomUtils.Web/Pages/MediaLocator.razor b/MatrixRoomUtils.Web/Pages/MediaLocator.razor
index af6e67a..42c7b8e 100644
--- a/MatrixRoomUtils.Web/Pages/MediaLocator.razor
+++ b/MatrixRoomUtils.Web/Pages/MediaLocator.razor
@@ -1,5 +1,6 @@
@page "/MediaLocator"
@using LibMatrix
+@using LibMatrix.Homeservers
@inject HttpClient Http
<h3>Media locator</h3>
<hr/>
diff --git a/MatrixRoomUtils.Web/Pages/ModalTest.razor b/MatrixRoomUtils.Web/Pages/ModalTest.razor
index 2b1c9bc..1d14005 100644
--- a/MatrixRoomUtils.Web/Pages/ModalTest.razor
+++ b/MatrixRoomUtils.Web/Pages/ModalTest.razor
@@ -10,7 +10,7 @@
<ModalWindow X="@Random.Shared.Next(1400)" Y="@Random.Shared.Next(1000)" Title="@("Window " + i1)" OnCloseClicked="() => OnCloseClicked(i1)">
@for (var j = 0; j < i1; j++) {
<h1>@j</h1>
- }
+ }
</ModalWindow>
}
@@ -70,7 +70,7 @@
}
if(_windowInfos.Count > 750) multiplier = 2;
if(_windowInfos.Count > 1500) multiplier = 3;
-
+
}
await base.OnInitializedAsync();
diff --git a/MatrixRoomUtils.Web/Pages/Rooms/Create.razor b/MatrixRoomUtils.Web/Pages/Rooms/Create.razor
index 3b7d000..c6fd5b6 100644
--- a/MatrixRoomUtils.Web/Pages/Rooms/Create.razor
+++ b/MatrixRoomUtils.Web/Pages/Rooms/Create.razor
@@ -1,15 +1,15 @@
@page "/Rooms/Create"
@using System.Text.Json
@using System.Reflection
+@using ArcaneLibs.Extensions
@using LibMatrix
@using LibMatrix.Extensions
@using LibMatrix.Helpers
+@using LibMatrix.Homeservers
@using LibMatrix.Responses
@using LibMatrix.StateEventTypes.Spec
-@using LibMatrix.StateEventTypes
@using MatrixRoomUtils.Web.Classes.RoomCreationTemplates
@* @* ReSharper disable once RedundantUsingDirective - Must not remove this, Rider marks this as "unused" when it's not */ *@
-@using MatrixRoomUtils.Web.Shared.SimpleComponents
<h3>Room Manager - Create Room</h3>
@@ -135,7 +135,7 @@
}
else {
<details>
- <summary>@((creationEvent["m.room.server_acls"].TypedContent as ServerACLEventData).Allow.Count) allow rules</summary>
+ <summary>@((creationEvent["m.room.server_acls"].TypedContent as ServerACLEventContent).Allow.Count) allow rules</summary>
@* <StringListEditor @bind-Items="@serverAcl.Allow"></StringListEditor> *@
</details>
}
@@ -145,7 +145,7 @@
}
else {
<details>
- <summary>@((creationEvent["m.room.server_acls"].TypedContent as ServerACLEventData).Deny.Count) deny rules</summary>
+ <summary>@((creationEvent["m.room.server_acls"].TypedContent as ServerACLEventContent).Deny.Count) deny rules</summary>
@* <StringListEditor @bind-Items="@serverAcl.Allow"></StringListEditor> *@
</details>
}
@@ -251,14 +251,14 @@
private CreateRoomRequest? creationEvent { get; set; }
private Dictionary<string, CreateRoomRequest>? Presets { get; set; } = new();
- private AuthenticatedHomeServer? HomeServer { get; set; }
+ private AuthenticatedHomeserverGeneric? HomeServer { get; set; }
private MatrixException? _matrixException { get; set; }
- private HistoryVisibilityEventData? historyVisibility => creationEvent?["m.room.history_visibility"].TypedContent as HistoryVisibilityEventData;
- private GuestAccessEventData? guestAccessEvent => creationEvent?["m.room.guest_access"].TypedContent as GuestAccessEventData;
- private ServerACLEventData? serverAcl => creationEvent?["m.room.server_acls"].TypedContent as ServerACLEventData;
- private RoomAvatarEventData? roomAvatarEvent => creationEvent?["m.room.avatar"].TypedContent as RoomAvatarEventData;
+ private HistoryVisibilityEventContent? historyVisibility => creationEvent?["m.room.history_visibility"].TypedContent as HistoryVisibilityEventContent;
+ private GuestAccessEventContent? guestAccessEvent => creationEvent?["m.room.guest_access"].TypedContent as GuestAccessEventContent;
+ private ServerACLEventContent? serverAcl => creationEvent?["m.room.server_acls"].TypedContent as ServerACLEventContent;
+ private RoomAvatarEventContent? roomAvatarEvent => creationEvent?["m.room.avatar"].TypedContent as RoomAvatarEventContent;
protected override async Task OnInitializedAsync() {
HomeServer = await MRUStorage.GetCurrentSessionOrNavigate();
@@ -284,7 +284,7 @@
private async Task RoomIconFilePicked(InputFileChangeEventArgs obj) {
var res = await HomeServer.UploadFile(obj.File.Name, obj.File.OpenReadStream(), obj.File.ContentType);
Console.WriteLine(res);
- (creationEvent["m.room.avatar"].TypedContent as RoomAvatarEventData).Url = res;
+ (creationEvent["m.room.avatar"].TypedContent as RoomAvatarEventContent).Url = res;
StateHasChanged();
}
@@ -305,7 +305,7 @@
creationEvent.InitialState.Add(new StateEvent {
Type = "m.room.member",
StateKey = mxid,
- TypedContent = new RoomMemberEventData {
+ TypedContent = new RoomMemberEventContent {
Membership = "invite",
Reason = "Automatically invited at room creation time."
}
diff --git a/MatrixRoomUtils.Web/Pages/Rooms/Index.razor b/MatrixRoomUtils.Web/Pages/Rooms/Index.razor
index ad3a714..c2daba7 100644
--- a/MatrixRoomUtils.Web/Pages/Rooms/Index.razor
+++ b/MatrixRoomUtils.Web/Pages/Rooms/Index.razor
@@ -1,10 +1,10 @@
@page "/Rooms"
-@using LibMatrix.StateEventTypes
@using LibMatrix.StateEventTypes.Spec
@using LibMatrix.Filters
@using LibMatrix.Helpers
@using LibMatrix.Responses
<h3>Room list</h3>
+
<p>@Status</p>
@if (RenderContents) {
<RoomList Rooms="Rooms" GlobalProfile="@GlobalProfile"></RoomList>
@@ -16,7 +16,7 @@
public List<RoomInfo> KnownRooms { get; set; } = new();
private List<RoomInfo> Rooms { get; set; } = new();
- private ProfileResponseEventData GlobalProfile { get; set; }
+ private ProfileResponseEventContent GlobalProfile { get; set; }
private SyncFilter filter = new() {
AccountData = new SyncFilter.EventFilter {
@@ -93,7 +93,7 @@
if (!roomInfo.StateEvents.Any(x => x.Type == "m.room.name")) {
roomInfo.StateEvents.Add(new StateEventResponse {
Type = "m.room.name",
- TypedContent = new RoomNameEventData {
+ TypedContent = new RoomNameEventContent {
Name = roomInfo.Room.RoomId
}
});
@@ -101,7 +101,7 @@
if (!roomInfo.StateEvents.Any(x => x.Type == "m.room.avatar")) {
roomInfo.StateEvents.Add(new StateEventResponse {
Type = "m.room.avatar",
- TypedContent = new RoomAvatarEventData {
+ TypedContent = new RoomAvatarEventContent {
}
});
@@ -121,7 +121,7 @@
roomInfo.StateEvents.Add(new StateEventResponse {
Type = "m.room.member",
StateKey = hs.WhoAmI.UserId,
- TypedContent = await roomInfo.Room.GetStateAsync<RoomMemberEventData>("m.room.member", hs.WhoAmI.UserId) ?? new RoomMemberEventData {
+ TypedContent = await roomInfo.Room.GetStateAsync<RoomMemberEventContent>("m.room.member", hs.WhoAmI.UserId) ?? new RoomMemberEventContent {
Membership = "unknown"
}
});
diff --git a/MatrixRoomUtils.Web/Pages/Rooms/PolicyList.razor b/MatrixRoomUtils.Web/Pages/Rooms/PolicyList.razor
index 2b31389..d2b8360 100644
--- a/MatrixRoomUtils.Web/Pages/Rooms/PolicyList.razor
+++ b/MatrixRoomUtils.Web/Pages/Rooms/PolicyList.razor
@@ -1,11 +1,11 @@
@page "/Rooms/{RoomId}/Policies"
-@using LibMatrix.StateEventTypes
-@using System.Text.Json
@using LibMatrix
@using LibMatrix.Extensions
@using LibMatrix.Helpers
+@using LibMatrix.Homeservers
@using LibMatrix.Responses
@using LibMatrix.StateEventTypes.Spec
+@using ArcaneLibs.Extensions
<h3>Policy list editor - Editing @RoomId</h3>
<hr/>
@@ -33,8 +33,8 @@ else {
</tr>
</thead>
<tbody>
- @foreach (var policyEvent in PolicyEvents.Where(x => x.Type == "m.policy.rule.server" && (x.TypedContent as PolicyRuleStateEventData).Entity is not null)) {
- var policyData = policyEvent.TypedContent as PolicyRuleStateEventData;
+ @foreach (var policyEvent in PolicyEvents.Where(x => x.Type == "m.policy.rule.server" && (x.TypedContent as PolicyRuleEventContent).Entity is not null)) {
+ var policyData = policyEvent.TypedContent as PolicyRuleEventContent;
<tr>
<td>Entity: @policyData.Entity<br/>State: @policyEvent.StateKey</td>
<td>@policyData.Reason</td>
@@ -59,8 +59,8 @@ else {
</tr>
</thead>
<tbody>
- @foreach (var policyEvent in PolicyEvents.Where(x => x.Type == "m.policy.rule.server" && (x.TypedContent as PolicyRuleStateEventData).Entity == null)) {
- var policyData = policyEvent.TypedContent as PolicyRuleStateEventData;
+ @foreach (var policyEvent in PolicyEvents.Where(x => x.Type == "m.policy.rule.server" && (x.TypedContent as PolicyRuleEventContent).Entity == null)) {
+ var policyData = policyEvent.TypedContent as PolicyRuleEventContent;
<tr>
<td>@policyEvent.StateKey</td>
<td>@policyEvent.RawContent.ToJson(false, true)</td>
@@ -86,8 +86,8 @@ else {
</tr>
</thead>
<tbody>
- @foreach (var policyEvent in PolicyEvents.Where(x => x.Type == "m.policy.rule.room" && (x.TypedContent as PolicyRuleStateEventData).Entity is not null)) {
- var policyData = policyEvent.TypedContent as PolicyRuleStateEventData;
+ @foreach (var policyEvent in PolicyEvents.Where(x => x.Type == "m.policy.rule.room" && (x.TypedContent as PolicyRuleEventContent).Entity is not null)) {
+ var policyData = policyEvent.TypedContent as PolicyRuleEventContent;
<tr>
<td>Entity: @policyData.Entity<br/>State: @policyEvent.StateKey</td>
<td>@policyData.Reason</td>
@@ -111,7 +111,7 @@ else {
</tr>
</thead>
<tbody>
- @foreach (var policyEvent in PolicyEvents.Where(x => x.Type == "m.policy.rule.room" && (x.TypedContent as PolicyRuleStateEventData).Entity == null)) {
+ @foreach (var policyEvent in PolicyEvents.Where(x => x.Type == "m.policy.rule.room" && (x.TypedContent as PolicyRuleEventContent).Entity == null)) {
<tr>
<td>@policyEvent.StateKey</td>
<td>@policyEvent.RawContent!.ToJson(false, true)</td>
@@ -140,8 +140,8 @@ else {
</tr>
</thead>
<tbody>
- @foreach (var policyEvent in PolicyEvents.Where(x => x.Type == "m.policy.rule.user" && (x.TypedContent as PolicyRuleStateEventData).Entity is not null)) {
- var policyData = policyEvent.TypedContent as PolicyRuleStateEventData;
+ @foreach (var policyEvent in PolicyEvents.Where(x => x.Type == "m.policy.rule.user" && (x.TypedContent as PolicyRuleEventContent).Entity is not null)) {
+ var policyData = policyEvent.TypedContent as PolicyRuleEventContent;
<tr>
@if (_enableAvatars) {
<td scope="col">
@@ -170,7 +170,7 @@ else {
</tr>
</thead>
<tbody>
- @foreach (var policyEvent in PolicyEvents.Where(x => x.Type == "m.policy.rule.user" && (x.TypedContent as PolicyRuleStateEventData).Entity == null)) {
+ @foreach (var policyEvent in PolicyEvents.Where(x => x.Type == "m.policy.rule.user" && (x.TypedContent as PolicyRuleEventContent).Entity == null)) {
<tr>
<td>@policyEvent.StateKey</td>
<td>@policyEvent.RawContent.ToJson(false, true)</td>
@@ -245,8 +245,8 @@ else {
}
private async Task GetAllAvatars() {
- foreach (var policyEvent in PolicyEvents.Where(x => x.Type == "m.policy.rule.user" && (x.TypedContent as PolicyRuleStateEventData).Entity is not null)) {
- await GetAvatar((policyEvent.TypedContent as PolicyRuleStateEventData).Entity);
+ foreach (var policyEvent in PolicyEvents.Where(x => x.Type == "m.policy.rule.user" && (x.TypedContent as PolicyRuleEventContent).Entity is not null)) {
+ await GetAvatar((policyEvent.TypedContent as PolicyRuleEventContent).Entity);
}
StateHasChanged();
}
diff --git a/MatrixRoomUtils.Web/Pages/Rooms/Space.razor b/MatrixRoomUtils.Web/Pages/Rooms/Space.razor
index c37b8ab..ef0ea5a 100644
--- a/MatrixRoomUtils.Web/Pages/Rooms/Space.razor
+++ b/MatrixRoomUtils.Web/Pages/Rooms/Space.razor
@@ -1,8 +1,8 @@
@page "/Rooms/{RoomId}/Space"
-@using System.Text.Json
@using LibMatrix.Extensions
@using LibMatrix.Responses
@using LibMatrix.RoomTypes
+@using ArcaneLibs.Extensions
<h3>Room manager - Viewing Space</h3>
<button onclick="@JoinAllRooms">Join all rooms</button>
diff --git a/MatrixRoomUtils.Web/Pages/Rooms/StateEditor.razor b/MatrixRoomUtils.Web/Pages/Rooms/StateEditor.razor
index ef7cd51..fefcabc 100644
--- a/MatrixRoomUtils.Web/Pages/Rooms/StateEditor.razor
+++ b/MatrixRoomUtils.Web/Pages/Rooms/StateEditor.razor
@@ -1,8 +1,7 @@
@page "/Rooms/{RoomId}/State/Edit"
-@using System.Net.Http.Headers
-@using System.Text.Json
@using LibMatrix.Extensions
@using LibMatrix.Responses
+@using ArcaneLibs.Extensions
@inject ILocalStorageService LocalStorage
@inject NavigationManager NavigationManager
<h3>Room state editor - Editing @RoomId</h3>
diff --git a/MatrixRoomUtils.Web/Pages/Rooms/StateViewer.razor b/MatrixRoomUtils.Web/Pages/Rooms/StateViewer.razor
index 5a48b32..1c3f28b 100644
--- a/MatrixRoomUtils.Web/Pages/Rooms/StateViewer.razor
+++ b/MatrixRoomUtils.Web/Pages/Rooms/StateViewer.razor
@@ -1,8 +1,7 @@
@page "/Rooms/{RoomId}/State/View"
-@using System.Net.Http.Headers
-@using System.Text.Json
@using LibMatrix.Extensions
@using LibMatrix.Responses
+@using ArcaneLibs.Extensions
@inject ILocalStorageService LocalStorage
@inject NavigationManager NavigationManager
<h3>Room state viewer - Viewing @RoomId</h3>
diff --git a/MatrixRoomUtils.Web/Pages/Rooms/Timeline.razor b/MatrixRoomUtils.Web/Pages/Rooms/Timeline.razor
index 4a5298b..2c95c99 100644
--- a/MatrixRoomUtils.Web/Pages/Rooms/Timeline.razor
+++ b/MatrixRoomUtils.Web/Pages/Rooms/Timeline.razor
@@ -1,6 +1,7 @@
@page "/Rooms/{RoomId}/Timeline"
@using MatrixRoomUtils.Web.Shared.TimelineComponents
@using LibMatrix
+@using LibMatrix.Homeservers
@using LibMatrix.Responses
@using LibMatrix.StateEventTypes.Spec
<h3>RoomManagerTimeline</h3>
@@ -23,7 +24,7 @@
private List<MessagesResponse> Messages { get; } = new();
private List<StateEventResponse> Events { get; } = new();
- private AuthenticatedHomeServer? HomeServer { get; set; }
+ private AuthenticatedHomeserverGeneric? HomeServer { get; set; }
protected override async Task OnInitializedAsync() {
Console.WriteLine("RoomId: " + RoomId);
@@ -46,8 +47,9 @@
private StateEventResponse GetProfileEventBefore(StateEventResponse Event) => Events.TakeWhile(x => x != Event).Last(e => e.Type == "m.room.member" && e.StateKey == Event.Sender);
private Type ComponentType(StateEvent Event) => Event.TypedContent switch {
- RoomMessageEventData => typeof(TimelineMessageItem),
- RoomMemberEventData => typeof(TimelineMemberItem),
+ RoomMessageEventContent => typeof(TimelineMessageItem),
+ RoomMemberEventContent => typeof(TimelineMemberItem),
+ RoomCreateEventContent => typeof(TimelineRoomCreateItem),
_ => typeof(TimelineUnknownItem)
};
diff --git a/MatrixRoomUtils.Web/Pages/SpaceDebug.razor b/MatrixRoomUtils.Web/Pages/SpaceDebug.razor
new file mode 100644
index 0000000..c4c4ce8
--- /dev/null
+++ b/MatrixRoomUtils.Web/Pages/SpaceDebug.razor
@@ -0,0 +1,114 @@
+@page "/SpaceDebug"
+@using LibMatrix.StateEventTypes.Spec
+@using LibMatrix.RoomTypes
+@using LibMatrix.Filters
+<h3>SpaceDebug</h3>
+<hr/>
+
+<p>@Status</p>
+
+<b>Has parent:</b>
+<br/>
+
+@foreach (var (roomId, parents) in SpaceParents) {
+ <p>@roomId's parents</p>
+ <ul>
+ @foreach (var parent in parents) {
+ <li>@parent</li>
+ }
+ </ul>
+}
+
+<b>Space children:</b>
+
+@foreach (var (roomId, children) in SpaceChildren) {
+ <p>@roomId's children</p>
+ <ul>
+ @foreach (var child in children) {
+ <li>@child</li>
+ }
+ </ul>
+}
+
+@code {
+ private string _status = "Loading...";
+
+ public string Status {
+ get => _status;
+ set {
+ _status = value;
+ StateHasChanged();
+ }
+ }
+
+ public Dictionary<string, List<string>> SpaceChildren { get; set; } = new();
+ public Dictionary<string, List<string>> SpaceParents { get; set; } = new();
+
+ protected override async Task OnInitializedAsync() {
+ Status = "Getting homeserver...";
+ var hs = await MRUStorage.GetCurrentSessionOrNavigate();
+ if (hs is null) return;
+
+ Status = "Syncing...";
+ string nextBatch = null;
+ while (nextBatch != "end") {
+ var sync = await hs.SyncHelper.Sync(since: nextBatch, filter: new SyncFilter() {
+ Presence = new(0),
+ Room = new() {
+ AccountData = new(limit: 0),
+ Ephemeral = new(limit: 0),
+ State = new(limit: 1000, types: new() { "m.space.child", "m.space.parent" }),
+ Timeline = new(limit: 0)
+ },
+ AccountData = new(limit: 0)
+ });
+
+ if (sync is null) {
+ Status = "Sync failed";
+ continue;
+ }
+
+ if (sync.Rooms is null) {
+ Status = "No rooms in sync...";
+ nextBatch = "end";
+ continue;
+ }
+
+ if (sync.Rooms.Join is null) {
+ Status = "No joined rooms in sync...";
+ nextBatch = "end";
+ continue;
+ }
+
+ if (sync.Rooms.Join.Count == 0) {
+ Status = "Joined rooms list was empty...";
+ nextBatch = "end";
+ continue;
+ }
+
+ nextBatch = sync.NextBatch;
+ foreach (var (roomId, data) in sync.Rooms!.Join!) {
+ data.State?.Events?.ForEach(e => {
+ if (e.Type == "m.space.child") {
+ if (!SpaceChildren.ContainsKey(roomId)) SpaceChildren[roomId] = new();
+ if (e.RawContent is null) e.StateKey += " (null)";
+ else if (e.RawContent.Count == 0) e.StateKey += " (empty)";
+ SpaceChildren[roomId].Add(e.StateKey);
+ }
+ if (e.Type == "m.space.parent") {
+ if (!SpaceParents.ContainsKey(roomId)) SpaceParents[roomId] = new();
+ if (e.RawContent is null) e.StateKey += " (null)";
+ else if (e.RawContent.Count == 0) e.StateKey += " (empty)";
+ SpaceParents[roomId].Add(e.StateKey);
+ }
+ });
+ }
+ Status = $"Synced {sync.Rooms.Join.Count} rooms, found {SpaceChildren.Count} spaces, {SpaceParents.Count} parents";
+ }
+ Status = $"Synced: found {SpaceChildren.Count}->{SpaceChildren.Sum(x => x.Value.Count)} spaces, {SpaceParents.Count}->{SpaceParents.Sum(x => x.Value.Count)} parents!";
+
+ await base.OnInitializedAsync();
+ }
+
+
+}
diff --git a/MatrixRoomUtils.Web/Shared/InlineUserItem.razor b/MatrixRoomUtils.Web/Shared/InlineUserItem.razor
index db66309..af2fa29 100644
--- a/MatrixRoomUtils.Web/Shared/InlineUserItem.razor
+++ b/MatrixRoomUtils.Web/Shared/InlineUserItem.razor
@@ -2,6 +2,7 @@
@using LibMatrix.StateEventTypes.Spec
@using LibMatrix
@using LibMatrix.Helpers
+@using LibMatrix.Homeservers
<div style="background-color: #ffffff11; border-radius: 0.5em; height: 1em; display: inline-block; vertical-align: middle;" alt="@UserId">
<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>
@@ -20,10 +21,10 @@
public RenderFragment? ChildContent { get; set; }
[Parameter]
- public ProfileResponseEventData User { get; set; }
+ public ProfileResponseEventContent User { get; set; }
[Parameter]
- public ProfileResponseEventData MemberEvent { get; set; }
+ public ProfileResponseEventContent MemberEvent { get; set; }
[Parameter]
public string? UserId { get; set; }
@@ -35,7 +36,7 @@
public string? ProfileName { get; set; } = null;
[Parameter]
- public AuthenticatedHomeServer? HomeServer { get; set; }
+ public AuthenticatedHomeserverGeneric? HomeServer { get; set; }
private static SemaphoreSlim _semaphoreSlim = new(128);
@@ -50,7 +51,7 @@
throw new ArgumentNullException(nameof(UserId));
if (MemberEvent != null) {
- User = new ProfileResponseEventData {
+ User = new ProfileResponseEventContent {
AvatarUrl = MemberEvent.AvatarUrl,
DisplayName = MemberEvent.DisplayName
};
diff --git a/MatrixRoomUtils.Web/Shared/ModalWindow.razor b/MatrixRoomUtils.Web/Shared/ModalWindow.razor
deleted file mode 100644
index beb7198..0000000
--- a/MatrixRoomUtils.Web/Shared/ModalWindow.razor
+++ /dev/null
@@ -1,86 +0,0 @@
-@using LibMatrix.Extensions
-<div class="r-modal" style="top: @(_y)px; left: @(_x)px;">
- <div class="titlebar" @onmousedown="MouseDown" @onmouseup="MouseUp" @onmousemove="MouseMove" @onmouseleave="MouseMove">
- <b class="title" @ref="_titleRef">@Title</b>
- <button class="btnclose" @onclick="OnCloseClicked">X</button>
- <button class="btncollapse" @onclick="@(() => Collapsed = !Collapsed)">_</button>
- </div>
- <div class="r-modal-content" style="@((Collapsed ? "height: 0px;" : "") + $"min-width: {MinWidth}px;")">
- @ChildContent
- </div>
-</div>
-
-@code {
-
- [Parameter]
- public RenderFragment? ChildContent { get; set; }
-
- [Parameter]
- public string Title { get; set; } = "Untitled window";
-
- [Parameter]
- public double X { get; set; } = 60;
-
- [Parameter]
- public double Y { get; set; } = 60;
-
- [Parameter]
- public double MinWidth { get; set; } = 100;
-
- [Parameter]
- public Action OnCloseClicked { get; set; }
-
- [Parameter]
- public bool Collapsed { get; set; } = false;
-
- private ElementReference _titleRef;
-
- private double _x = 60;
- private double _y = 60;
-
- protected override async Task OnInitializedAsync() {
- _x = X;
- _y = Y;
- await base.OnInitializedAsync();
- }
-
- protected override async Task OnAfterRenderAsync(bool firstRender) {
- //set minwidth to title width
- MinWidth = await JSRuntime.InvokeAsync<int>("getWidth", _titleRef) + 75;
- await base.OnAfterRenderAsync(firstRender);
- }
-
- private void WindowDrag(DragEventArgs obj) {
- Console.WriteLine("Drag: " + obj.ToJson());
-
- _x += obj.MovementX;
- _y += obj.MovementY;
-
- StateHasChanged();
- }
-
- private bool isDragging = false;
- private double dragX = 0;
- private double dragY = 0;
-
- private void MouseDown(MouseEventArgs obj) {
- isDragging = true;
- dragX = obj.ClientX;
- dragY = obj.ClientY;
- }
-
- private void MouseUp(MouseEventArgs obj) {
- isDragging = false;
- }
-
- private void MouseMove(MouseEventArgs obj) {
- if (!isDragging) return;
-
- _x += obj.ClientX - dragX;
- _y += obj.ClientY - dragY;
- dragX = obj.ClientX;
- dragY = obj.ClientY;
- StateHasChanged();
- }
-
-}
diff --git a/MatrixRoomUtils.Web/Shared/ModalWindow.razor.css b/MatrixRoomUtils.Web/Shared/ModalWindow.razor.css
deleted file mode 100644
index 6d08114..0000000
--- a/MatrixRoomUtils.Web/Shared/ModalWindow.razor.css
+++ /dev/null
@@ -1,70 +0,0 @@
-.r-modal {
- position: absolute;
- width: fit-content;
- height: fit-content;
- z-index: 1000;
-}
-.r-modal:hover {
- z-index: 1001;
-}
-
-.r-modal > .titlebar {
- position: absolute;
- display: block;
- top: 0;
- left: 0;
- width: 100%;
- height: 25px;
- background-color: #000;
- user-select: none;
-}
-
-.r-modal > .titlebar > .title {
- position: relative;
- top: 0;
- left: 0;
- width: fit-content;
- text-wrap: nowrap;
- height: 100%;
- line-height: 25px;
- padding-left: 10px;
- color: #fff;
-}
-
-.r-modal > .titlebar > .btnclose {
- position: absolute;
- top: 0;
- right: 0;
- width: 25px;
- height: 100%;
- line-height: 25px;
- text-align: center;
- color: #fff;
- background-color: #111;
- cursor: pointer;
-}
-.r-modal > .titlebar > .btncollapse {
- position: absolute;
- top: 0;
- right: 25px;
- width: 25px;
- height: 100%;
- line-height: 25px;
- text-align: center;
- color: #fff;
- background-color: #111;
- cursor: pointer;
-}
-
-.r-modal > .r-modal-content {
- position: relative;
- top: 25px;
- left: 0;
- width: fit-content;
- height: fit-content;
- min-width: 150px;
- max-width: 75vw;
- max-height: 75vh;
- overflow: auto;
- background-color: #111;
-}
diff --git a/MatrixRoomUtils.Web/Shared/RoomList.razor b/MatrixRoomUtils.Web/Shared/RoomList.razor
index 3b057a4..b0548cb 100644
--- a/MatrixRoomUtils.Web/Shared/RoomList.razor
+++ b/MatrixRoomUtils.Web/Shared/RoomList.razor
@@ -3,6 +3,7 @@
@using LibMatrix.StateEventTypes.Spec
@using LibMatrix
@using LibMatrix.Extensions
+@using ArcaneLibs.Extensions
@if(Rooms.Count != RoomsWithTypes.Sum(x=>x.Value.Count)) {
<p>Fetching room details... @RoomsWithTypes.Sum(x=>x.Value.Count) out of @Rooms.Count done!</p>
@foreach (var category in RoomsWithTypes.OrderBy(x => x.Value.Count)) {
@@ -20,7 +21,7 @@ else {
[Parameter]
public List<RoomInfo> Rooms { get; set; }
[Parameter]
- public ProfileResponseEventData? GlobalProfile { get; set; }
+ public ProfileResponseEventContent? GlobalProfile { get; set; }
Dictionary<string, List<RoomInfo>> RoomsWithTypes = new();
@@ -51,7 +52,7 @@ else {
await _semaphoreSlim.WaitAsync();
string roomType;
try {
- var createEvent = (await room.GetStateEvent("m.room.create")).TypedContent as RoomCreateEventData;
+ var createEvent = (await room.GetStateEvent("m.room.create")).TypedContent as RoomCreateEventContent;
roomType = GetRoomTypeName(createEvent.Type);
if (roomType == "Room") {
diff --git a/MatrixRoomUtils.Web/Shared/RoomListComponents/RoomListCategory.razor b/MatrixRoomUtils.Web/Shared/RoomListComponents/RoomListCategory.razor
index 381ecd1..d717186 100644
--- a/MatrixRoomUtils.Web/Shared/RoomListComponents/RoomListCategory.razor
+++ b/MatrixRoomUtils.Web/Shared/RoomListComponents/RoomListCategory.razor
@@ -2,18 +2,19 @@
@using MatrixRoomUtils.Web.Classes.Constants
@using LibMatrix.StateEventTypes.Spec
@using LibMatrix
+@using LibMatrix.Homeservers
<details>
<summary>@roomType (@rooms.Count)</summary>
@foreach (var room in rooms) {
<div class="room-list-item">
<RoomListItem RoomInfo="@room" ShowOwnProfile="@(roomType == "Room")"></RoomListItem>
@* @if (RoomVersionDangerLevel(room) != 0 && *@
- @* (room.StateEvents.FirstOrDefault(x=>x.Type == "m.room.power_levels")?.TypedContent is RoomPowerLevelEventData powerLevels && powerLevels.UserHasPermission(HomeServer.UserId, "m.room.tombstone"))) { *@
+ @* (room.StateEvents.FirstOrDefault(x=>x.Type == "m.room.power_levels")?.TypedContent is RoomPowerLevelEventContent powerLevels && powerLevels.UserHasPermission(HomeServer.UserId, "m.room.tombstone"))) { *@
@* <MatrixRoomUtils.Web.Shared.SimpleComponents.LinkButton Color="@(RoomVersionDangerLevel(room) == 2 ? "#ff0000" : "#ff8800")" href="@($"/Rooms/Create?Import={room.Room.RoomId}")">Upgrade room</MatrixRoomUtils.Web.Shared.SimpleComponents.LinkButton> *@
@* } *@
- <MatrixRoomUtils.Web.Shared.SimpleComponents.LinkButton href="@($"/Rooms/{room.Room.RoomId}/Timeline")">View timeline</MatrixRoomUtils.Web.Shared.SimpleComponents.LinkButton>
- <MatrixRoomUtils.Web.Shared.SimpleComponents.LinkButton href="@($"/Rooms/{room.Room.RoomId}/State/View")">View state</MatrixRoomUtils.Web.Shared.SimpleComponents.LinkButton>
- <MatrixRoomUtils.Web.Shared.SimpleComponents.LinkButton href="@($"/Rooms/{room.Room.RoomId}/State/Edit")">Edit state</MatrixRoomUtils.Web.Shared.SimpleComponents.LinkButton>
+ <LinkButton href="@($"/Rooms/{room.Room.RoomId}/Timeline")">View timeline</LinkButton>
+ <LinkButton href="@($"/Rooms/{room.Room.RoomId}/State/View")">View state</LinkButton>
+ <LinkButton href="@($"/Rooms/{room.Room.RoomId}/State/Edit")">Edit state</LinkButton>
@if (roomType == "Space") {
<RoomListSpace Space="@room"></RoomListSpace>
@@ -29,10 +30,10 @@
public KeyValuePair<string, List<RoomInfo>> Category { get; set; }
[Parameter]
- public ProfileResponseEventData? GlobalProfile { get; set; }
+ public ProfileResponseEventContent? GlobalProfile { get; set; }
[CascadingParameter]
- public AuthenticatedHomeServer HomeServer { get; set; } = null!;
+ public AuthenticatedHomeserverGeneric Homeserver { get; set; } = null!;
private string roomType => Category.Key;
private List<RoomInfo> rooms => Category.Value;
@@ -40,7 +41,7 @@
private int RoomVersionDangerLevel(RoomInfo room) {
var roomVersion = room.StateEvents.FirstOrDefault(x => x.Type == "m.room.create");
if (roomVersion is null) return 0;
- return roomVersion.TypedContent is not RoomCreateEventData roomVersionContent ? 0
+ return roomVersion.TypedContent is not RoomCreateEventContent roomVersionContent ? 0
: RoomConstants.DangerousRoomVersions.Contains(roomVersionContent.RoomVersion) ? 2
: roomVersionContent.RoomVersion != RoomConstants.RecommendedRoomVersion ? 1 : 0;
}
diff --git a/MatrixRoomUtils.Web/Shared/RoomListComponents/RoomListSpace.razor b/MatrixRoomUtils.Web/Shared/RoomListComponents/RoomListSpace.razor
index 0867b48..1b54577 100644
--- a/MatrixRoomUtils.Web/Shared/RoomListComponents/RoomListSpace.razor
+++ b/MatrixRoomUtils.Web/Shared/RoomListComponents/RoomListSpace.razor
@@ -30,7 +30,7 @@
protected override async Task OnInitializedAsync() {
if (Breadcrumbs == null) throw new ArgumentNullException(nameof(Breadcrumbs));
await Task.Delay(Random.Shared.Next(1000, 10000));
- var rooms = Space.Room.AsSpace.GetRoomsAsync();
+ var rooms = Space.Room.AsSpace.GetChildrenAsync();
await foreach (var room in rooms) {
if (Breadcrumbs.Contains(room.RoomId)) continue;
var roomInfo = KnownRooms.FirstOrDefault(x => x.Room.RoomId == room.RoomId);
diff --git a/MatrixRoomUtils.Web/Shared/RoomListItem.razor b/MatrixRoomUtils.Web/Shared/RoomListItem.razor
index 79844ef..b74643b 100644
--- a/MatrixRoomUtils.Web/Shared/RoomListItem.razor
+++ b/MatrixRoomUtils.Web/Shared/RoomListItem.razor
@@ -1,6 +1,7 @@
@using System.Text.Json
@using LibMatrix
@using LibMatrix.Helpers
+@using LibMatrix.Homeservers
@using LibMatrix.RoomTypes
@using LibMatrix.StateEventTypes.Spec
@using LibMatrix.StateEventTypes
@@ -44,10 +45,10 @@
public bool ShowOwnProfile { get; set; } = false;
[Parameter]
- public RoomMemberEventData? OwnMemberState { get; set; }
+ public RoomMemberEventContent? OwnMemberState { get; set; }
[CascadingParameter]
- public ProfileResponseEventData? GlobalProfile { get; set; }
+ public ProfileResponseEventContent? GlobalProfile { get; set; }
private string? roomName { get; set; }
@@ -57,7 +58,7 @@
private bool hasDangerousRoomVersion { get; set; } = false;
private static SemaphoreSlim _semaphoreSlim = new(8);
- private static AuthenticatedHomeServer? hs { get; set; }
+ private static AuthenticatedHomeserverGeneric? hs { get; set; }
protected override async Task OnInitializedAsync() {
await base.OnInitializedAsync();
@@ -102,7 +103,7 @@
private async Task LoadOwnProfile() {
if (!ShowOwnProfile) return;
try {
- OwnMemberState ??= (await RoomInfo.GetStateEvent("m.room.member", hs.UserId)).TypedContent as RoomMemberEventData;
+ OwnMemberState ??= (await RoomInfo.GetStateEvent("m.room.member", hs.UserId)).TypedContent as RoomMemberEventContent;
GlobalProfile ??= await hs.GetProfile(hs.UserId);
}
catch (MatrixException e) {
@@ -117,7 +118,7 @@
}
private async Task CheckRoomVersion() {
- var ce = (await RoomInfo.GetStateEvent("m.room.create")).TypedContent as RoomCreateEventData;
+ var ce = (await RoomInfo.GetStateEvent("m.room.create")).TypedContent as RoomCreateEventContent;
if (int.TryParse(ce.RoomVersion, out var rv)) {
if (rv < 10)
hasOldRoomVersion = true;
@@ -133,9 +134,9 @@
private async Task GetRoomInfo() {
try {
- roomName ??= ((await RoomInfo.GetStateEvent("m.room.name"))?.TypedContent as RoomNameEventData)?.Name ?? RoomId;
+ roomName ??= ((await RoomInfo.GetStateEvent("m.room.name"))?.TypedContent as RoomNameEventContent)?.Name ?? RoomId;
- var state = (await RoomInfo.GetStateEvent("m.room.avatar")).TypedContent as RoomAvatarEventData;
+ var state = (await RoomInfo.GetStateEvent("m.room.avatar")).TypedContent as RoomAvatarEventContent;
if (state?.Url is { } url) {
roomIcon = MediaResolver.ResolveMediaUri(hs.FullHomeServerDomain, url);
// Console.WriteLine($"Got avatar for room {RoomId}: {roomIcon} ({url})");
diff --git a/MatrixRoomUtils.Web/Shared/SimpleComponents/DictionaryEditor.razor b/MatrixRoomUtils.Web/Shared/SimpleComponents/DictionaryEditor.razor
deleted file mode 100644
index afd1fdc..0000000
--- a/MatrixRoomUtils.Web/Shared/SimpleComponents/DictionaryEditor.razor
+++ /dev/null
@@ -1,38 +0,0 @@
-@using LibMatrix.Extensions
-<table>
- @foreach (var i in Items.Keys) {
- var key = i;
- <input value="@Items[key]" @oninput="obj => inputChanged(obj, key)">
- <button @onclick="() => { Items.Remove(key); ItemsChanged.InvokeAsync(); }">Remove</button>
- <br/>
- }
-</table>
-<button @onclick="() => { Items.Add(string.Empty, default); ItemsChanged.InvokeAsync(); }">Add</button>
-
-@code {
-
- [Parameter]
- public Dictionary<string, object> Items { get; set; } = new();
-
- [Parameter]
- [EditorRequired]
- public EventCallback ItemsChanged { get; set; }
-
- [Parameter]
- public Func<string, string>? KeyFormatter { get; set; }
-
- [Parameter]
- public Action? OnFocusLost { get; set; }
-
- protected override Task OnInitializedAsync() {
- Console.WriteLine($"DictionaryEditor initialized with {Items.Count} items: {Items.ToJson()}");
- return base.OnInitializedAsync();
- }
-
- private void inputChanged(ChangeEventArgs obj, string key) {
- Console.WriteLine($"StringListEditor inputChanged {key} {obj.Value}");
- Items[key] = obj.Value.ToString();
- ItemsChanged.InvokeAsync();
- }
-
-}
diff --git a/MatrixRoomUtils.Web/Shared/SimpleComponents/FancyTextBox.razor b/MatrixRoomUtils.Web/Shared/SimpleComponents/FancyTextBox.razor
deleted file mode 100644
index 966c44d..0000000
--- a/MatrixRoomUtils.Web/Shared/SimpleComponents/FancyTextBox.razor
+++ /dev/null
@@ -1,29 +0,0 @@
-@inject IJSRuntime JsRuntime
-@if (isVisible) {
- <input autofocus type="@(IsPassword ? "password" : "text")" @bind="Value" @onfocusout="() => { isVisible = false; ValueChanged.InvokeAsync(Value); }" @ref="elementToFocus"/>
-}
-else {
- <span class="fancy-textbox-inline" tabindex="0" style="@(string.IsNullOrEmpty(Value) ? "min-width: 50px;" : "")" @onfocusin="() => isVisible = true">@(Formatter?.Invoke(Value) ?? (IsPassword ? string.Join("", Value.Select(x => '*')) : Value))</span>
-}
-
-@code {
-
- [Parameter]
- public string Value { get; set; }
-
- [Parameter]
- public bool IsPassword { get; set; } = false;
-
- [Parameter]
- public EventCallback<string> ValueChanged { get; set; }
-
- [Parameter]
- public Func<string?, string>? Formatter { get; set; }
-
- private bool isVisible { get; set; } = false;
-
- private ElementReference elementToFocus;
-
- protected override async Task OnAfterRenderAsync(bool firstRender) => await JsRuntime.InvokeVoidAsync("BlazorFocusElement", elementToFocus);
-
-}
\ No newline at end of file
diff --git a/MatrixRoomUtils.Web/Shared/SimpleComponents/FancyTextBox.razor.css b/MatrixRoomUtils.Web/Shared/SimpleComponents/FancyTextBox.razor.css
deleted file mode 100644
index 01b2c6f..0000000
--- a/MatrixRoomUtils.Web/Shared/SimpleComponents/FancyTextBox.razor.css
+++ /dev/null
@@ -1,5 +0,0 @@
-.fancy-textbox-inline {
- border-bottom: #ccc solid 1px;
- height: 1.4em;
- display: inline-block;
-}
\ No newline at end of file
diff --git a/MatrixRoomUtils.Web/Shared/SimpleComponents/LinkButton.razor b/MatrixRoomUtils.Web/Shared/SimpleComponents/LinkButton.razor
deleted file mode 100644
index b800989..0000000
--- a/MatrixRoomUtils.Web/Shared/SimpleComponents/LinkButton.razor
+++ /dev/null
@@ -1,20 +0,0 @@
-<a href="@href" class="btn btn-primary" @onclick="@(() => OnClick?.Invoke())"
- style="background-color: @(Color ?? "#1b6ec2");">
- @ChildContent
-</a>
-
-@code {
-
- [Parameter]
- public string? href { get; set; }
-
- [Parameter]
- public RenderFragment ChildContent { get; set; }
-
- [Parameter]
- public string? Color { get; set; }
-
- [Parameter]
- public Func<Task>? OnClick { get; set; }
-
-}
diff --git a/MatrixRoomUtils.Web/Shared/SimpleComponents/StringListEditor.razor b/MatrixRoomUtils.Web/Shared/SimpleComponents/StringListEditor.razor
deleted file mode 100644
index 2bd6ed5..0000000
--- a/MatrixRoomUtils.Web/Shared/SimpleComponents/StringListEditor.razor
+++ /dev/null
@@ -1,29 +0,0 @@
-@for (var i = 0; i < Items.Count; i++) {
- var self = i;
- <button @onclick="() => { Items.RemoveAt(self); ItemsChanged.InvokeAsync(); }">Remove</button>
- <FancyTextBox Value="@Items[self]" ValueChanged="@(obj => inputChanged(obj, self))"/>
- <br/>
-}
-<button @onclick="() => { Items.Add(string.Empty); ItemsChanged.InvokeAsync(); }">Add</button>
-
-@code {
-
- [Parameter]
- public List<string> Items { get; set; } = new();
-
- [Parameter]
- [EditorRequired]
- public EventCallback ItemsChanged { get; set; }
-
- protected override Task OnInitializedAsync() {
- Console.WriteLine($"StringListEditor initialized with {Items.Count} items: {string.Join(",", Items)}");
- return base.OnInitializedAsync();
- }
-
- private void inputChanged(string obj, int i) {
- Console.WriteLine($"StringListEditor inputChanged {i} {obj}");
- Items[i] = obj;
- ItemsChanged.InvokeAsync();
- }
-
-}
\ No newline at end of file
diff --git a/MatrixRoomUtils.Web/Shared/SimpleComponents/ToggleSlider.razor b/MatrixRoomUtils.Web/Shared/SimpleComponents/ToggleSlider.razor
deleted file mode 100644
index 1a38e26..0000000
--- a/MatrixRoomUtils.Web/Shared/SimpleComponents/ToggleSlider.razor
+++ /dev/null
@@ -1,72 +0,0 @@
-<input type="checkbox"/><span>@ChildContent</span>
-
-<div class="container">
- <label class="switch" for="checkbox">
- <input type="checkbox" id="checkbox" @bind="Value"/>
- <div class="slider round"></div>
- </label>
-</div>
-
-<style>
- .switch {
- display: inline-block;
- height: 16px;
- position: relative;
- width: 32px;
- }
-
- .switch input {
- display:none;
- }
-
- .slider {
- background-color: #ccc;
- bottom: 0;
- cursor: pointer;
- left: 0;
- position: absolute;
- right: 0;
- top: 0;
- transition: .4s;
- }
-
- .slider:before {
- background-color: #fff;
- bottom: -5px;
- content: "";
- height: 26px;
- left: -8px;
- position: absolute;
- transition: .4s;
- width: 26px;
- }
-
- input:checked + .slider {
- background-color: #66bb6a;
- }
-
- input:checked + .slider:before {
- transform: translateX(24px);
- }
-
- .slider.round {
- border-radius: 24px;
- }
-
- .slider.round:before {
- border-radius: 50%;
- }
-</style>
-
-@code {
-
- [Parameter]
- public RenderFragment? ChildContent { get; set; }
-
- [Parameter]
- public bool Value { get; set; }
-
- [Parameter]
- public EventCallback<bool> ValueChanged { get; set; }
-
-}
\ No newline at end of file
diff --git a/MatrixRoomUtils.Web/Shared/TimelineComponents/BaseTimelineItem.razor b/MatrixRoomUtils.Web/Shared/TimelineComponents/BaseTimelineItem.razor
index 5172fa4..e4ee873 100644
--- a/MatrixRoomUtils.Web/Shared/TimelineComponents/BaseTimelineItem.razor
+++ b/MatrixRoomUtils.Web/Shared/TimelineComponents/BaseTimelineItem.razor
@@ -1,5 +1,6 @@
@using LibMatrix.Responses
@using LibMatrix
+@using LibMatrix.Homeservers
<h3>BaseTimelineItem</h3>
@code {
@@ -11,6 +12,6 @@
public List<StateEventResponse> Events { get; set; }
[Parameter]
- public AuthenticatedHomeServer HomeServer { get; set; }
+ public AuthenticatedHomeserverGeneric Homeserver { get; set; }
}
diff --git a/MatrixRoomUtils.Web/Shared/TimelineComponents/TimelineMemberItem.razor b/MatrixRoomUtils.Web/Shared/TimelineComponents/TimelineMemberItem.razor
index d67fdab..c450211 100644
--- a/MatrixRoomUtils.Web/Shared/TimelineComponents/TimelineMemberItem.razor
+++ b/MatrixRoomUtils.Web/Shared/TimelineComponents/TimelineMemberItem.razor
@@ -1,6 +1,6 @@
-@using LibMatrix.StateEventTypes
@using LibMatrix.StateEventTypes.Spec
@using LibMatrix.Extensions
+@using ArcaneLibs.Extensions
@inherits BaseTimelineItem
@if (roomMemberData is not null) {
@@ -15,7 +15,7 @@
<i>@Event.StateKey changed their display name to @(roomMemberData.Displayname ?? Event.Sender)</i>
break;
case "join":
- <i><InlineUserItem User="@(new ProfileResponseEventData())" HomeServer="@HomeServer" UserId="@Event.StateKey"></InlineUserItem> joined</i>
+ <i><InlineUserItem User="@(new ProfileResponseEventContent())" HomeServer="@Homeserver" UserId="@Event.StateKey"></InlineUserItem> joined</i>
break;
case "leave":
<i>@Event.StateKey left</i>
@@ -26,8 +26,8 @@
default:
<i>@Event.StateKey has an unknown state:</i>
<pre>
- @Event.ToJson()
- </pre>
+ @Event.ToJson()
+ </pre>
break;
}
}
@@ -42,6 +42,6 @@ else {
@code {
- private RoomMemberEventData? roomMemberData => Event.TypedContent as RoomMemberEventData;
+ private RoomMemberEventContent? roomMemberData => Event.TypedContent as RoomMemberEventContent;
}
diff --git a/MatrixRoomUtils.Web/Shared/TimelineComponents/TimelineMessageItem.razor b/MatrixRoomUtils.Web/Shared/TimelineComponents/TimelineMessageItem.razor
index 13cce88..5dd87e0 100644
--- a/MatrixRoomUtils.Web/Shared/TimelineComponents/TimelineMessageItem.razor
+++ b/MatrixRoomUtils.Web/Shared/TimelineComponents/TimelineMessageItem.razor
@@ -1,4 +1,5 @@
@using LibMatrix.Extensions
+@using ArcaneLibs.Extensions
@inherits BaseTimelineItem
<pre>
diff --git a/MatrixRoomUtils.Web/Shared/TimelineComponents/TimelineRoomCreateItem.razor b/MatrixRoomUtils.Web/Shared/TimelineComponents/TimelineRoomCreateItem.razor
index 8053a47..9c48455 100644
--- a/MatrixRoomUtils.Web/Shared/TimelineComponents/TimelineRoomCreateItem.razor
+++ b/MatrixRoomUtils.Web/Shared/TimelineComponents/TimelineRoomCreateItem.razor
@@ -1,10 +1,11 @@
@using LibMatrix.StateEventTypes.Spec
@using LibMatrix.Extensions
+@using ArcaneLibs.Extensions
@inherits BaseTimelineItem
<p>
@Event.Sender created the room with room version @CreationEventContent.RoomVersion
- @CreationEventContent.Federate ? "and" : "without" federating with other servers.<br/>
+ @(CreationEventContent.Federate ?? false ? "and" : "without") federating with other servers.<br/>
This room is of type @(CreationEventContent.Type ?? "Untyped room (usually a chat room)")
</p>
<pre>
@@ -13,6 +14,6 @@
@code {
- private RoomCreateEventData CreationEventContent => Event.TypedContent as RoomCreateEventData;
+ private RoomCreateEventContent CreationEventContent => Event.TypedContent as RoomCreateEventContent;
}
diff --git a/MatrixRoomUtils.Web/Shared/TimelineComponents/TimelineUnknownItem.razor b/MatrixRoomUtils.Web/Shared/TimelineComponents/TimelineUnknownItem.razor
index 8166f8a..69845d9 100644
--- a/MatrixRoomUtils.Web/Shared/TimelineComponents/TimelineUnknownItem.razor
+++ b/MatrixRoomUtils.Web/Shared/TimelineComponents/TimelineUnknownItem.razor
@@ -1,4 +1,5 @@
@using LibMatrix.Extensions
+@using ArcaneLibs.Extensions
@inherits BaseTimelineItem
<div>
diff --git a/MatrixRoomUtils.Web/Shared/UserListItem.razor b/MatrixRoomUtils.Web/Shared/UserListItem.razor
index a85a68d..7a55380 100644
--- a/MatrixRoomUtils.Web/Shared/UserListItem.razor
+++ b/MatrixRoomUtils.Web/Shared/UserListItem.razor
@@ -19,7 +19,7 @@
public RenderFragment? ChildContent { get; set; }
[Parameter]
- public ProfileResponseEventData User { get; set; }
+ public ProfileResponseEventContent User { get; set; }
[Parameter]
public string UserId { get; set; }
diff --git a/MatrixRoomUtils.Web/_Imports.razor b/MatrixRoomUtils.Web/_Imports.razor
index cb08515..a92153d 100644
--- a/MatrixRoomUtils.Web/_Imports.razor
+++ b/MatrixRoomUtils.Web/_Imports.razor
@@ -12,7 +12,7 @@
@using MatrixRoomUtils.Web.Classes
@using MatrixRoomUtils.Web.Shared
-@using LinkButton = MatrixRoomUtils.Web.Shared.SimpleComponents.LinkButton
+@using ArcaneLibs.Blazor.Components
@inject NavigationManager NavigationManager
@inject MRUStorageWrapper MRUStorage
|