- @foreach (var prop in PolicyCollection.PropertiesToDisplay.Values) {
- if (prop.Name == "Entity") {
-
- @TruncateMxid(TypedContent.Entity)
- @foreach (var dup in PolicyInfo.DuplicatedBy) {
-
- Duplicated by @dup.FriendlyTypeName.ToLower() @TruncateMxid(dup.RawContent["entity"]?.GetValue())
- }
- @foreach (var dup in PolicyInfo.MadeRedundantBy) {
-
- Also matched by @dup.FriendlyTypeName.ToLower() @TruncateMxid(dup.RawContent["entity"]?.GetValue())
- }
- @if (RenderEventInfo) {
-
-
- @PolicyInfo.Policy.Type/@PolicyInfo.Policy.StateKey by @PolicyInfo.Policy.Sender at @PolicyInfo.Policy.OriginServerTs
-
- }
- |
- }
- else {
- @prop.GetGetMethod()?.Invoke(TypedContent, null) |
- }
- }
@* @if (PowerLevels.UserHasStatePermission(Homeserver.WhoAmI.UserId, Policy.Type)) { *@
@@ -41,7 +18,7 @@
Remove
@if (Policy.IsLegacyType) {
- Update policy type
+ Update type
}
@if (TypedContent.Entity?.StartsWith("@*:", StringComparison.Ordinal) == true) {
@@ -66,6 +43,30 @@
}
|
+ @foreach (var prop in PolicyCollection.PropertiesToDisplay.Values) {
+ if (prop.Name == "Entity") {
+
+ @TruncateMxid(TypedContent.Entity)
+ @foreach (var dup in PolicyInfo.DuplicatedBy) {
+
+ Duplicated by @dup.FriendlyTypeName.ToLower() @TruncateMxid(dup.RawContent["entity"]?.GetValue())
+ }
+ @foreach (var dup in PolicyInfo.MadeRedundantBy) {
+
+ Also matched by @dup.FriendlyTypeName.ToLower() @TruncateMxid(dup.RawContent["entity"]?.GetValue())
+ }
+ @if (RenderEventInfo) {
+
+
+ @PolicyInfo.Policy.Type/@PolicyInfo.Policy.StateKey by @PolicyInfo.Policy.Sender at @PolicyInfo.Policy.OriginServerTimestamp
+
+ }
+ |
+ }
+ else {
+ @prop.GetGetMethod()?.Invoke(TypedContent, null) |
+ }
+ }
@if (IsEditing) {
@@ -95,6 +96,9 @@
[Parameter]
public bool RenderEventInfo { get; set; }
+ [Parameter]
+ public required Action PolicyCollectionStateHasChanged { get; set; }
+
private StateEventResponse Policy => PolicyInfo.Policy;
private bool IsEditing {
@@ -142,8 +146,42 @@
private async Task RemovePolicyAsync() {
await Room.SendStateEventAsync(Policy.Type, Policy.StateKey, new { });
- IsVisible = false;
- StateHasChanged();
+ bool shouldUpdateVisibility = true;
+ PolicyCollection.ActivePolicies.Remove((Policy.Type, Policy.StateKey));
+ PolicyCollection.RemovedPolicies.Add((Policy.Type, Policy.StateKey), PolicyInfo);
+ if (PolicyInfo.DuplicatedBy.Count > 0) {
+ foreach (var evt in PolicyInfo.DuplicatedBy) {
+ var matchingEntry = PolicyCollection.ActivePolicies
+ .FirstOrDefault(x => StateEvent.Equals(x.Value.Policy, evt)).Value;
+ var removals = matchingEntry.DuplicatedBy.RemoveAll(x => StateEvent.Equals(x, Policy));
+ Console.WriteLine($"Removed {removals} duplicates from {evt.EventId}, matching entry: {matchingEntry.ToJson()}");
+ if (PolicyCollection.ViewType == PolicyList.PolicyCollection.SpecialViewType.Duplicates && matchingEntry.DuplicatedBy.Count == 0) {
+ PolicyCollection.ActivePolicies.Remove((matchingEntry.Policy.Type, matchingEntry.Policy.StateKey));
+ PolicyCollection.RemovedPolicies.Add((matchingEntry.Policy.Type, matchingEntry.Policy.StateKey), matchingEntry);
+ Console.WriteLine($"Also removed {matchingEntry.Policy.EventId} as it is now redundant");
+ }
+ }
+
+ PolicyCollectionStateHasChanged();
+ shouldUpdateVisibility = false;
+ }
+
+ if (PolicyInfo.MadeRedundantBy.Count > 0) {
+ foreach (var evt in PolicyInfo.MadeRedundantBy) {
+ var matchingEntry = PolicyCollection.ActivePolicies
+ .FirstOrDefault(x => StateEvent.Equals(x.Value.Policy, evt)).Value;
+ var removals = matchingEntry.MadeRedundantBy.RemoveAll(x => StateEvent.Equals(x, Policy));
+ Console.WriteLine($"Removed {removals} redundants from {evt.EventId}, matching entry: {matchingEntry.ToJson()}");
+ }
+
+ PolicyCollectionStateHasChanged();
+ shouldUpdateVisibility = false;
+ }
+
+ if (shouldUpdateVisibility) {
+ IsVisible = false;
+ StateHasChanged();
+ }
// PolicyEventsByType[policyEvent.MappedType].Remove(policyEvent);
// await LoadStatesAsync();
}
diff --git a/MatrixUtils.Web/Pages/Rooms/Space.razor b/MatrixUtils.Web/Pages/Rooms/Space.razor
index 86a4c13..fc9c9bf 100644
--- a/MatrixUtils.Web/Pages/Rooms/Space.razor
+++ b/MatrixUtils.Web/Pages/Rooms/Space.razor
@@ -120,7 +120,7 @@
var room = Room!.Homeserver.GetRoom(roomId);
if (room is null) return;
try {
- await room.JoinAsync(ServersInSpace.ToArray());
+ await room.JoinAsync(ServersInSpace.Take(10).ToArray());
var joined = false;
while (!joined) {
var ce = await room.GetCreateEventAsync();
@@ -132,6 +132,7 @@
}
}
joined = true;
+ await Task.Delay(1000);
}
}
catch (Exception e) {
diff --git a/MatrixUtils.Web/Pages/Tools/Index.razor b/MatrixUtils.Web/Pages/Tools/Index.razor
index 4a44753..a0abcd4 100644
--- a/MatrixUtils.Web/Pages/Tools/Index.razor
+++ b/MatrixUtils.Web/Pages/Tools/Index.razor
@@ -12,6 +12,7 @@
No data loaded.
+}
+else {
+