From 9460daa7262a88a6955ef2d61b89fe83ce63849f Mon Sep 17 00:00:00 2001 From: Rory& Date: Fri, 9 May 2025 17:28:08 +0200 Subject: Add helper to check if type and state key for 2 events match, or 2 events are equal --- LibMatrix/StateEvent.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'LibMatrix/StateEvent.cs') diff --git a/LibMatrix/StateEvent.cs b/LibMatrix/StateEvent.cs index ef760e1..e2ac87e 100644 --- a/LibMatrix/StateEvent.cs +++ b/LibMatrix/StateEvent.cs @@ -100,13 +100,10 @@ public class StateEvent { [JsonPropertyName("replaces_state")] public string? ReplacesState { get; set; } - private JsonObject? _rawContent; - [JsonPropertyName("content")] - public JsonObject? RawContent { - get => _rawContent; - set => _rawContent = value; - } + // [field: AllowNull, MaybeNull] + [NotNull] + public JsonObject? RawContent { get; set; } //debug [JsonIgnore] @@ -122,6 +119,9 @@ public class StateEvent { [JsonIgnore] public string InternalContentTypeName => TypedContent?.GetType().Name ?? "null"; + + public static bool TypeKeyPairMatches(StateEventResponse x, StateEventResponse y) => x.Type == y.Type && x.StateKey == y.StateKey; + public static bool Equals(StateEventResponse x, StateEventResponse y) => x.Type == y.Type && x.StateKey == y.StateKey && x.RawContent.Equals(y.RawContent); } public class StateEventResponse : StateEvent { -- cgit 1.5.1