返回提交历史
Modified
src/controllers/custom/setAccountCheatController.ts
+13
-14
Modified
static/webui/script.js
+2
-0
XFEstudio/SpaceNinjaServer
fix(webui): update cached data when toggling account cheats (#3872)
Closes #3870 Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/3872 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
11f933df
代码差异
2 个文件
+15
-14
@@ -1,6 +1,6 @@
1
1
import { getInventory } from "../../services/inventoryService.ts";
2
2
import { getAccountForRequest, hasPermission } from "../../services/loginService.ts";
3
import { sendWsBroadcastEx, sendWsBroadcastTo } from "../../services/wsService.ts";
3
import { sendWsBroadcastEx, sendWsBroadcastTo, sendWsBroadcastToWebui } from "../../services/wsService.ts";
4
4
import {
5
5
accountCheatBooleans,
6
6
accountCheatNumbers,
@@ -50,21 +50,20 @@ export const setAccountCheatController: RequestHandler = async (req, res) => {
50
50
}
51
51
52
52
res.end();
53
if (
54
[
55
"infiniteCredits",
56
"infinitePlatinum",
57
"infiniteEndo",
58
"infiniteRegalAya",
59
"infiniteTrades",
60
"infiniteGifts",
61
"skipAllDialogue",
62
"skipAllPopups"
63
].indexOf(payload.key) != -1
64
) {
53
54
if (["infiniteCredits", "infinitePlatinum", "infiniteEndo", "infiniteRegalAya"].indexOf(payload.key) != -1) {
55
// Game and all webui tabs need to refresh the inventory
65
56
sendWsBroadcastTo(account._id.toString(), { update_inventory: true, sync_inventory: true });
57
} else if (["infiniteTrades", "infiniteGifts", "skipAllDialogue", "skipAllPopups"].indexOf(payload.key) != -1) {
58
// Only game and other webui tabs need to refresh the inventory
59
sendWsBroadcastEx(
60
{ update_inventory: true, sync_inventory: true },
61
account._id.toString(),
62
parseInt(String(req.query.wsid))
63
);
66
64
} else {
67
sendWsBroadcastEx({ update_inventory: true }, account._id.toString(), parseInt(String(req.query.wsid)));
65
// Only other webui tabs need to refresh the inventory
66
sendWsBroadcastToWebui({ update_inventory: true }, account._id.toString(), parseInt(String(req.query.wsid)));
68
67
}
69
68
};
70
69
@@ -3562,6 +3562,7 @@ document.querySelectorAll("#account-cheats input[type=checkbox]").forEach(elm =>
3562
3562
})
3563
3563
}).done(res => {
3564
3564
elm.checked = value;
3565
inventory_data[elm.id] = value;
3565
3566
if (res == "retroactivable") {
3566
3567
if (window.confirm(loc("cheats_retroactivePrompt"))) {
3567
3568
$.get("/custom/retroactivelyApplyCheat?" + window.authz + "&cheat=" + elm.id);
@@ -3604,6 +3605,7 @@ document.querySelectorAll("#account-cheats .input-group").forEach(grp => {
3604
3605
})
3605
3606
}).done(() => {
3606
3607
input.value = value;
3608
inventory_data[elm.id] = value;
3607
3609
});
3608
3610
});
3609
3611
};