forked from ComputerTech/aprhodite
Fix admin panel: live AI access toggle, auto-refresh after actions
- Grant/Revoke AI button now notifies target user live via ai_unlock event - ai_unlock handler updated to support both grant and revoke - Admin panel auto-refreshes user/ban/mute lists after any action
This commit is contained in:
parent
887482d3db
commit
fa030a32b7
5
app.py
5
app.py
|
|
@ -1074,6 +1074,11 @@ def on_admin_toggle_ai(data):
|
|||
target_sid = username_to_sid.get(target_user.username.lower())
|
||||
if target_sid and target_sid in connected_users:
|
||||
connected_users[target_sid]["has_ai_access"] = target_user.has_ai_access
|
||||
# Notify target so their UI updates immediately
|
||||
socketio.emit("ai_unlock", {
|
||||
"has_ai_access": target_user.has_ai_access,
|
||||
"msg": "Premium access granted! Unlimited Violet." if target_user.has_ai_access else "Premium access revoked."
|
||||
}, to=target_sid)
|
||||
|
||||
status = "granted" if target_user.has_ai_access else "revoked"
|
||||
emit("admin_action_ok", {"msg": f"AI access {status} for {target_user.username}"})
|
||||
|
|
|
|||
|
|
@ -376,10 +376,10 @@ socket.on("ai_response", async (data) => {
|
|||
});
|
||||
|
||||
socket.on("ai_unlock", (data) => {
|
||||
state.hasAiAccess = true;
|
||||
state.hasAiAccess = data.has_ai_access !== undefined ? data.has_ai_access : true;
|
||||
updateVioletBadge();
|
||||
paywallModal.classList.add("hidden");
|
||||
addMessage("ai-violet", { system: true, text: data.msg });
|
||||
if (data.msg) addMessage("ai-violet", { system: true, text: data.msg });
|
||||
});
|
||||
|
||||
socket.on("ignore_status", (data) => {
|
||||
|
|
@ -875,7 +875,13 @@ function adminToast(msg) {
|
|||
setTimeout(() => t.classList.add("hidden"), 2500);
|
||||
}
|
||||
|
||||
socket.on("admin_action_ok", (data) => adminToast(data.msg));
|
||||
socket.on("admin_action_ok", (data) => {
|
||||
adminToast(data.msg);
|
||||
// Refresh the admin user list so buttons update
|
||||
socket.emit("admin_get_users");
|
||||
socket.emit("admin_get_bans");
|
||||
socket.emit("admin_get_mutes");
|
||||
});
|
||||
|
||||
// ── Users pane ───────────────────────────────────────────────────────────
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue