fix(dashboard): keep player search and review data current

Prevent slow or periodic account/player lookup responses from replacing a newer search, make both dashboard layouts usable on narrow screens, and use the unified dashboard masterpiece routes for staff and owner review images. Propagate approved username changes through moderation-facing history and cover report-name propagation with an end-to-end regression test.
This commit is contained in:
Snipzil committed 2026-10-19 12:29:09 -04:00
1 parent 8e7b193621
commit 9f69b3511b
4 files changed
+101 -14

No files matched your search

+16 -1
View File
@@ -803,7 +803,10 @@ const storableUsernameProblem = username => {
};
// gives the account a new username, and carries it into everyone's buddy and
// block lists. returns "invalid_username" or "username_taken", else null.
// block lists. The staff dashboard stores a few human-readable names beside
// account ids; keep those labels current too, so a rename does not split a
// player's history across two names. Returns "invalid_username" or
// "username_taken", else null.
// the player must not be online: the game knows them by the old name.
// with `anyName` (the admin panel) the sign-up rules about length and
// characters do not apply; see storableUsernameProblem.
@@ -825,6 +828,18 @@ const rename = (account, username, anyName = false) => {
}
db.prepare("UPDATE accounts SET username = ?, username_key = ? WHERE id = ?").run(username, newKey, account.id);
console.log(`[accounts] renamed "${logText(account.username)}" to "${logText(username)}" (id ${logText(account.id)})`);
for (const [table, column] of [
["reports", "reporter"], ["reports", "target"], ["feedback", "username"],
["chat_log", "username"], ["chat_log", "to_name"], ["appeals", "username"],
["ban_log", "username"], ["mod_log", "by"], ["mod_log", "target"],
]) {
// A few lean unit tests load the account store without every dashboard
// module. The tables are present in the actual server, but keep rename
// usable in that smaller setup too.
if (db.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = ?").get(table)) {
db.prepare(`UPDATE ${table} SET ${column} = ? WHERE ${column} = ? COLLATE NOCASE`).run(username, account.username);
}
}
byKey.delete(oldKey);
account.username = username;
byKey.set(newKey, account);