Improve admin message seen/dismiss state. (#26223)
Fixes #26211 Admin messages now have separate "seen" and "dismissed" fields. The idea is that an admin should be able to tell whether a user pressed the "dismiss for now" button. Instead of using "seen" as "show this message to players when they join", "dismissed" is now used for this. Existing notes in the database will automatically be marked as dismissed on migration. A note cannot be dismissed without being seen (enforced via constraint in the database too, aren't I fancy). As part of this, it has become impossible for a player to play without dismissing the message in some form. Instead of a shitty popup window, the popup is now a fullscreen overlay that blocks clicks behind it, making the game unplayable. Also, if a user somehow has multiple messages they will be combined into one popup. Also I had enough respect for the codebase to make it look better and clean up the code somewhat. Yippee.
This commit is contained in:
committed by
GitHub
parent
f87480dd36
commit
d776c4b392
@@ -1,3 +1,4 @@
|
||||
using System.Linq;
|
||||
using Content.Server.Administration.Commands;
|
||||
using Content.Server.Chat.Managers;
|
||||
using Content.Server.EUI;
|
||||
@@ -52,7 +53,7 @@ public sealed class AdminNotesSystem : EntitySystem
|
||||
|
||||
private async void OnPlayerStatusChanged(object? sender, SessionStatusEventArgs e)
|
||||
{
|
||||
if (e.NewStatus != SessionStatus.Connected)
|
||||
if (e.NewStatus != SessionStatus.InGame)
|
||||
return;
|
||||
|
||||
var messages = await _notes.GetNewMessages(e.Session.UserId);
|
||||
@@ -69,19 +70,11 @@ public sealed class AdminNotesSystem : EntitySystem
|
||||
_chat.SendAdminAlert(Loc.GetString("admin-notes-watchlist", ("player", username), ("message", watchlist.Message)));
|
||||
}
|
||||
|
||||
foreach (var message in messages)
|
||||
{
|
||||
var messageString = Loc.GetString("admin-notes-new-message", ("admin", message.CreatedBy?.LastSeenUserName ?? "[System]"), ("message", message.Message));
|
||||
// Only open the popup if the user hasn't seen it yet
|
||||
if (!message.Seen)
|
||||
{
|
||||
var ui = new AdminMessageEui();
|
||||
_euis.OpenEui(ui, e.Session);
|
||||
ui.SetMessage(message);
|
||||
var messagesToShow = messages.OrderBy(x => x.CreatedAt).Where(x => !x.Dismissed).ToArray();
|
||||
if (messagesToShow.Length == 0)
|
||||
return;
|
||||
|
||||
// Only send the message if they haven't seen it yet
|
||||
_chat.DispatchServerMessage(e.Session, messageString);
|
||||
}
|
||||
}
|
||||
var ui = new AdminMessageEui(messagesToShow);
|
||||
_euis.OpenEui(ui, e.Session);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user