From 9ce293b8baa1039c8cad9be9fdc6bbd374ff020b Mon Sep 17 00:00:00 2001 From: Lilian Date: Wed, 26 Mar 2025 00:07:32 +0100 Subject: [PATCH] [frontend/core] Fix potential null reference exceptions --- Iceshrimp.Frontend/Core/Services/NoteStore/NoteStore.cs | 2 +- Iceshrimp.Frontend/Core/Services/NoteStore/NotificationStore.cs | 2 +- Iceshrimp.Frontend/Core/Services/NoteStore/RelatedStore.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Iceshrimp.Frontend/Core/Services/NoteStore/NoteStore.cs b/Iceshrimp.Frontend/Core/Services/NoteStore/NoteStore.cs index 27150cf6..74a51ed1 100644 --- a/Iceshrimp.Frontend/Core/Services/NoteStore/NoteStore.cs +++ b/Iceshrimp.Frontend/Core/Services/NoteStore/NoteStore.cs @@ -36,7 +36,7 @@ internal class NoteStore : NoteMessageProvider, IDisposable note.Poll = noteResponse.Poll; AnyNoteChanged?.Invoke(this, note); - NoteChangedHandlers.First(p => p.Key == note.Id).Value.Invoke(this, note); + NoteChangedHandlers.FirstOrDefault(p => p.Key == note.Id).Value?.Invoke(this, note); } } public void Delete(string id) diff --git a/Iceshrimp.Frontend/Core/Services/NoteStore/NotificationStore.cs b/Iceshrimp.Frontend/Core/Services/NoteStore/NotificationStore.cs index 500658cd..48935606 100644 --- a/Iceshrimp.Frontend/Core/Services/NoteStore/NotificationStore.cs +++ b/Iceshrimp.Frontend/Core/Services/NoteStore/NotificationStore.cs @@ -87,7 +87,7 @@ internal class NotificationStore : NoteMessageProvider, IAsyncDisposable el.Value.Note.Attachments = noteResponse.Attachments; el.Value.Note.Reactions = noteResponse.Reactions; el.Value.Note.Poll = noteResponse.Poll; - NoteChangedHandlers.First(p => p.Key == noteResponse.Id).Value.Invoke(this, el.Value.Note); + NoteChangedHandlers.FirstOrDefault(p => p.Key == noteResponse.Id).Value?.Invoke(this, el.Value.Note); } } } diff --git a/Iceshrimp.Frontend/Core/Services/NoteStore/RelatedStore.cs b/Iceshrimp.Frontend/Core/Services/NoteStore/RelatedStore.cs index 13f21273..c385f997 100644 --- a/Iceshrimp.Frontend/Core/Services/NoteStore/RelatedStore.cs +++ b/Iceshrimp.Frontend/Core/Services/NoteStore/RelatedStore.cs @@ -37,7 +37,7 @@ internal class RelatedStore : NoteMessageProvider, IDisposable note.Reactions = noteResponse.Reactions; note.Poll = noteResponse.Poll; - NoteChangedHandlers.First(p => p.Key == note.Id).Value.Invoke(this, note); + NoteChangedHandlers.FirstOrDefault(p => p.Key == note.Id).Value?.Invoke(this, note); NoteChanged?.Invoke(this, note); } }