blob: 4a5bddf3e7102e2450403dc059e55e3fe8ff66fa (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
@page "/RoomManager/Space/{RoomId}"
@using MatrixRoomUtils.Core.Extensions
@using System.Text.Json
<h3>Room manager - Viewing Space</h3>
<button onclick="@JoinAllRooms">Join all rooms</button>
@foreach (var room in Rooms)
{
<RoomListItem Room="room" ShowOwnProfile="true"></RoomListItem>
}
<br/>
<details style="background: #0002;">
<summary style="background: #fff1;">State list</summary>
@foreach (var stateEvent in States.OrderBy(x => x.state_key).ThenBy(x => x.type))
{
<p>@stateEvent.state_key/@stateEvent.type:</p>
<pre>@stateEvent.content.ToJson()</pre>
}
</details>
@code {
[Parameter]
public string RoomId { get; set; } = "invalid!!!!!!";
private Room? Room { get; set; }
private StateEvent<object>[] States { get; set; } = Array.Empty<StateEvent<object>>();
private List<Room> Rooms { get; set; } = new();
protected override async Task OnInitializedAsync()
{
await LocalStorageWrapper.LoadFromLocalStorage(LocalStorage);
Room = await RuntimeCache.CurrentHomeServer.GetRoom(RoomId.Replace('~', '.'));
var state = await Room.GetStateAsync("");
if (state != null)
{
Console.WriteLine(state.Value.ToJson());
States = state.Value.Deserialize<StateEvent<object>[]>()!;
foreach (var stateEvent in States)
{
if (stateEvent.type == "m.space.child")
{
// if (stateEvent.content.ToJson().Length < 5) return;
var roomId = stateEvent.state_key;
var room = await RuntimeCache.CurrentHomeServer.GetRoom(roomId);
if (room != null)
{
Rooms.Add(room);
}
}
}
// if(state.Value.TryGetProperty("type", out var type))
// {
// }
// else
// {
// //this is fine, apprently...
// //Console.WriteLine($"Room {room.RoomId} has no content.type in m.room.create!");
// }
}
await base.OnInitializedAsync();
}
private async Task JoinAllRooms()
{
foreach (var room in Rooms)
{
room.JoinAsync();
}
}
}
|