feat(admin_menu): add server feedback handling for announcement submissions
Implement bidirectional communication for announcement submissions: - Display server feedback messages (e.g., announcement already in progress) in the admin menu - Keep the menu open after sending to allow users to retry if submission fails - Add net.Receive handler to process server responses - Show countdown timer when announcement is already in progress - Close menu only on successful publication, not on rejection This improves UX by giving admins visibility into why their submission failed and allowing them to correct and resubmit without losing their input.
This commit is contained in:
@@ -124,7 +124,11 @@ local function OpenAAdminMenu()
|
||||
local len = EntryLen(msgEntry)
|
||||
local over = len > maxLen
|
||||
|
||||
if over then
|
||||
-- retour du serveur (ex : annonce déjà en cours) sinon le warning de dépassement
|
||||
if frame.sendFeedback and (frame.sendFeedbackUntil or 0) > SysTime() then
|
||||
DrawWarning(0, h * 0.5 - 8, 16)
|
||||
draw.SimpleText(frame.sendFeedback, "bladw_text_Medium", 24, h * 0.5, COL_WARN, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER)
|
||||
elseif over then
|
||||
DrawWarning(0, h * 0.5 - 8, 16)
|
||||
draw.SimpleText("Trop de caractères", "bladw_text_Medium", 24, h * 0.5, COL_RED, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER)
|
||||
end
|
||||
@@ -177,15 +181,30 @@ local function OpenAAdminMenu()
|
||||
return
|
||||
end
|
||||
|
||||
-- on envoie mais on NE ferme PAS : c'est la réponse serveur qui fermera si c'est publié,
|
||||
-- comme ça si c'est refusé l'admin garde son texte
|
||||
net.Start("bladWSendAnnouncement")
|
||||
net.WriteString(selectedPreset)
|
||||
net.WriteString(titleEntry:GetValue())
|
||||
net.WriteString(msgEntry:GetValue())
|
||||
net.SendToServer()
|
||||
|
||||
frame:Remove()
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
-- réponse du serveur après un envoi : publié -> on ferme, refusé -> on garde le menu + on dit pourquoi
|
||||
net.Receive("bladWAnnouncementResult", function()
|
||||
local ok = net.ReadBool()
|
||||
local left = net.ReadUInt(8)
|
||||
|
||||
if not IsValid(BladW_AdminMenu) then return end
|
||||
|
||||
if ok then
|
||||
BladW_AdminMenu:Remove()
|
||||
else
|
||||
BladW_AdminMenu.sendFeedback = left > 0 and ("Annonce déjà en cours (" .. left .. "s)") or "Envoi impossible"
|
||||
BladW_AdminMenu.sendFeedbackUntil = SysTime() + 5
|
||||
end
|
||||
end)
|
||||
|
||||
return OpenAAdminMenu
|
||||
|
||||
Reference in New Issue
Block a user