]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix admin note updates duplicating visually across all open note windows (#15471)
authorDrSmugleaf <DrSmugleaf@users.noreply.github.com>
Mon, 17 Apr 2023 06:18:54 +0000 (23:18 -0700)
committerGitHub <noreply@github.com>
Mon, 17 Apr 2023 06:18:54 +0000 (23:18 -0700)
Content.Server/Administration/Notes/AdminNotesEui.cs
Content.Server/Administration/Notes/AdminNotesExtensions.cs
Content.Server/Administration/Notes/AdminNotesManager.cs
Content.Server/Administration/Notes/IAdminNotesManager.cs
Content.Shared/Administration/Notes/SharedAdminNote.cs

index da6286a2528dc7843d330bfb5a0fc67144caec10..5aadd1520ebedfdd1dcb69148741baf378e2bf21 100644 (file)
@@ -117,13 +117,19 @@ public sealed class AdminNotesEui : BaseEui
 
     private void NoteModified(SharedAdminNote note)
     {
+        if (note.Player != NotedPlayer)
+            return;
+
         Notes[note.Id] = note;
         StateDirty();
     }
 
-    private void NoteDeleted(int id)
+    private void NoteDeleted(SharedAdminNote note)
     {
-        Notes.Remove(id);
+        if (note.Player != NotedPlayer)
+            return;
+
+        Notes.Remove(note.Id);
         StateDirty();
     }
 
index 12d35c62020d12b359112dddb907f6597fc5a9cb..c8ef366510b209c6f7a5aef7d01dd8db97984e1a 100644 (file)
@@ -10,6 +10,7 @@ public static class AdminNotesExtensions
         return new SharedAdminNote(
             note.Id,
             note.RoundId,
+            note.PlayerUserId,
             note.Message,
             note.CreatedBy.LastSeenUserName,
             note.LastEditedBy.LastSeenUserName,
index 2ef1508084f508f17bb23107f2797d055eaeebd2..dca26e009f5152e721eed0008e6eef9975da0e42 100644 (file)
@@ -22,7 +22,7 @@ public sealed class AdminNotesManager : IAdminNotesManager, IPostInjectInit
 
     public event Action<SharedAdminNote>? NoteAdded;
     public event Action<SharedAdminNote>? NoteModified;
-    public event Action<int>? NoteDeleted;
+    public event Action<SharedAdminNote>? NoteDeleted;
 
     private ISawmill _sawmill = default!;
 
@@ -66,6 +66,7 @@ public sealed class AdminNotesManager : IAdminNotesManager, IPostInjectInit
         var note = new SharedAdminNote(
             noteId,
             round,
+            player,
             message,
             createdBy.Name,
             createdBy.Name,
@@ -89,7 +90,17 @@ public sealed class AdminNotesManager : IAdminNotesManager, IPostInjectInit
         var deletedAt = DateTime.UtcNow;
         await _db.DeleteAdminNote(noteId, deletedBy.UserId, deletedAt);
 
-        NoteDeleted?.Invoke(noteId);
+        var sharedNote = new SharedAdminNote(
+            noteId,
+            note.RoundId,
+            note.PlayerUserId,
+            note.Message,
+            note.CreatedBy.LastSeenUserName,
+            note.LastEditedBy.LastSeenUserName,
+            note.CreatedAt,
+            note.LastEditedAt
+        );
+        NoteDeleted?.Invoke(sharedNote);
     }
 
     public async Task ModifyNote(int noteId, IPlayerSession editedBy, string message)
@@ -110,6 +121,7 @@ public sealed class AdminNotesManager : IAdminNotesManager, IPostInjectInit
         var sharedNote = new SharedAdminNote(
             noteId,
             note.RoundId,
+            note.PlayerUserId,
             message,
             note.CreatedBy.LastSeenUserName,
             editedBy.Name,
index ae4e7712b27857631b65743436deccc9b2038e49..ec48eaea475bed5a51b12f1cc4dc6750297b40e8 100644 (file)
@@ -9,7 +9,7 @@ public interface IAdminNotesManager
 {
     event Action<SharedAdminNote>? NoteAdded;
     event Action<SharedAdminNote>? NoteModified;
-    event Action<int>? NoteDeleted;
+    event Action<SharedAdminNote>? NoteDeleted;
 
     bool CanCreate(IPlayerSession admin);
     bool CanDelete(IPlayerSession admin);
index 4f3e60c5d45a99df52c9c9543efe370641a6d012..aa15f6541285863d7bcee59e138cfc792f604e17 100644 (file)
@@ -3,4 +3,4 @@
 namespace Content.Shared.Administration.Notes;
 
 [Serializable, NetSerializable]
-public sealed record SharedAdminNote(int Id, int? Round, string Message, string CreatedByName, string EditedByName, DateTime CreatedAt, DateTime LastEditedAt);
+public sealed record SharedAdminNote(int Id, int? Round, Guid Player, string Message, string CreatedByName, string EditedByName, DateTime CreatedAt, DateTime LastEditedAt);