From 6769b0fd6f37cbc27646fa0ca8e458489c935039 Mon Sep 17 00:00:00 2001 From: Rory& Date: Tue, 9 Dec 2025 23:42:07 +0100 Subject: Commit various changes that never made it into git --- .../PolicyEditorComponents/MassPolicyEditorModal.razor | 10 +++++----- .../Shared/PolicyEditorComponents/PolicyEditorModal.razor | 10 +++++----- .../Shared/TimelineComponents/BaseTimelineItem.razor | 12 +++++------- 3 files changed, 15 insertions(+), 17 deletions(-) (limited to 'MatrixUtils.Web/Shared') diff --git a/MatrixUtils.Web/Shared/PolicyEditorComponents/MassPolicyEditorModal.razor b/MatrixUtils.Web/Shared/PolicyEditorComponents/MassPolicyEditorModal.razor index bb4b672..b49358d 100644 --- a/MatrixUtils.Web/Shared/PolicyEditorComponents/MassPolicyEditorModal.razor +++ b/MatrixUtils.Web/Shared/PolicyEditorComponents/MassPolicyEditorModal.razor @@ -96,7 +96,7 @@ private bool VerifyIntent { get; set; } - private static FrozenSet KnownPolicyTypes = StateEvent.KnownStateEventTypes.Where(x => x.IsAssignableTo(typeof(PolicyRuleEventContent))).ToFrozenSet(); + private static FrozenSet KnownPolicyTypes = MatrixEvent.KnownEventTypes.Where(x => x.IsAssignableTo(typeof(PolicyRuleEventContent))).ToFrozenSet(); private static Dictionary PolicyTypes = KnownPolicyTypes .ToDictionary(x => x.GetCustomAttributes().First(y => !string.IsNullOrWhiteSpace(y.EventName)).EventName, x => x); @@ -177,20 +177,20 @@ // var tasks = entities.Select(x => ExecuteBan(Room, x)).ToList(); // await Task.WhenAll(tasks); - + var events = entities.Select(entity => { var content = Activator.CreateInstance(PolicyTypes[MappedType!]) as PolicyRuleEventContent ?? throw new InvalidOperationException("Failed to create event content"); content.Recommendation = Recommendation; content.Reason = Reason; content.Entity = entity; - return new StateEvent() { + return new MatrixEvent() { Type = MappedType, TypedContent = content, StateKey = content.GetDraupnir2StateKey() }; }); - - foreach(var chunk in events.Chunk(50)) + + foreach (var chunk in events.Chunk(50)) await Room.BulkSendEventsAsync(chunk); OnSaved.Invoke(); diff --git a/MatrixUtils.Web/Shared/PolicyEditorComponents/PolicyEditorModal.razor b/MatrixUtils.Web/Shared/PolicyEditorComponents/PolicyEditorModal.razor index 0205e16..501ca99 100644 --- a/MatrixUtils.Web/Shared/PolicyEditorComponents/PolicyEditorModal.razor +++ b/MatrixUtils.Web/Shared/PolicyEditorComponents/PolicyEditorModal.razor @@ -113,7 +113,7 @@ @code { [Parameter] - public StateEventResponse? PolicyEvent { + public MatrixEventResponse? PolicyEvent { get => _policyEvent; set { if (value is not null && value != _policyEvent) @@ -139,10 +139,10 @@ } [Parameter] - public Action? OnSave { get; set; } + public Action? OnSave { get; set; } [Parameter] - public Func? OnSaveAsync { get; set; } + public Func? OnSaveAsync { get; set; } private async Task InvokeOnSave() { if (OnSave is not null) @@ -154,12 +154,12 @@ public PolicyRuleEventContent? PolicyData { get; set; } - private static FrozenSet KnownPolicyTypes = StateEvent.KnownStateEventTypes.Where(x => x.IsAssignableTo(typeof(PolicyRuleEventContent))).ToFrozenSet(); + private static FrozenSet KnownPolicyTypes = MatrixEvent.KnownEventTypes.Where(x => x.IsAssignableTo(typeof(PolicyRuleEventContent))).ToFrozenSet(); private static Dictionary PolicyTypes = KnownPolicyTypes .ToDictionary(x => x.GetCustomAttributes().First(y => !string.IsNullOrWhiteSpace(y.EventName)).EventName, x => x); - private StateEventResponse? _policyEvent; + private MatrixEventResponse? _policyEvent; private string? MappedType { get => _policyEvent?.Type; diff --git a/MatrixUtils.Web/Shared/TimelineComponents/BaseTimelineItem.razor b/MatrixUtils.Web/Shared/TimelineComponents/BaseTimelineItem.razor index f107eb3..80c69f2 100644 --- a/MatrixUtils.Web/Shared/TimelineComponents/BaseTimelineItem.razor +++ b/MatrixUtils.Web/Shared/TimelineComponents/BaseTimelineItem.razor @@ -6,19 +6,19 @@ @code { [Parameter] - public StateEventResponse Event { get; set; } + public MatrixEventResponse Event { get; set; } [Parameter] - public List Events { get; set; } + public List Events { get; set; } [Parameter] public AuthenticatedHomeserverGeneric Homeserver { get; set; } - public IEnumerable EventsBefore => Events.TakeWhile(e => e.EventId != Event.EventId); + public IEnumerable EventsBefore => Events.TakeWhile(e => e.EventId != Event.EventId); - public IEnumerable MatchingEventsBefore => EventsBefore.Where(x => x.Type == Event.Type && x.StateKey == Event.StateKey); + public IEnumerable MatchingEventsBefore => EventsBefore.Where(x => x.Type == Event.Type && x.StateKey == Event.StateKey); - public StateEventResponse? PreviousState => MatchingEventsBefore.LastOrDefault(); + public MatrixEventResponse? PreviousState => MatchingEventsBefore.LastOrDefault(); public RoomMemberEventContent? CurrentSenderMemberEventContent => EventsBefore.LastOrDefault(x => x.Type == "m.room.member" && x.StateKey == Event.Sender)? .TypedContent as RoomMemberEventContent; @@ -27,6 +27,4 @@ public bool HasPreviousMessage => EventsBefore.Last() is { Type: "m.room.message" } response && response.Sender == Event.Sender; - - } \ No newline at end of file -- cgit 1.5.1