sync inventory when focus schools were unlocked

This commit is contained in:
Sainan 2025-09-08 06:09:02 +02:00
parent 88f343f39a
commit d52cbb9ac4
2 changed files with 22 additions and 10 deletions

View File

@ -62,6 +62,7 @@ interface IWsMsgFromClient {
nonce: number;
};
logout?: boolean;
sync_inventory?: boolean;
}
interface IWsMsgToClient {
@ -168,16 +169,24 @@ const wsOnConnect = (ws: WebSocket, req: http.IncomingMessage): void => {
}
if (data.logout) {
const accountId = (ws as IWsCustomData).accountId;
(ws as IWsCustomData).accountId = undefined;
await Account.updateOne(
{
_id: accountId,
ClientType: "webui"
},
{
Nonce: 0
}
);
if (accountId) {
(ws as IWsCustomData).accountId = undefined;
await Account.updateOne(
{
_id: accountId,
ClientType: "webui"
},
{
Nonce: 0
}
);
}
}
if (data.sync_inventory) {
const accountId = (ws as IWsCustomData).accountId;
if (accountId) {
sendWsBroadcastToGame(accountId, { sync_inventory: true });
}
}
} catch (e) {
logError(e as Error, `processing websocket message`);

View File

@ -2993,6 +2993,9 @@ function doUnlockAllFocusSchools() {
toast(loc("code_focusAllUnlocked"));
} else {
toast(loc("code_focusUnlocked").split("|COUNT|").join(Object.keys(missingFocusUpgrades).length));
if (ws_is_open) {
window.ws.send(JSON.stringify({ sync_inventory: true }));
}
}
});
});