diff --git a/src/services/wsService.ts b/src/services/wsService.ts index 21244273..0e35d0c2 100644 --- a/src/services/wsService.ts +++ b/src/services/wsService.ts @@ -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`); diff --git a/static/webui/script.js b/static/webui/script.js index 9d15b4fe..0a757340 100644 --- a/static/webui/script.js +++ b/static/webui/script.js @@ -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 })); + } } }); });