chore(webui): don't refresh inventory for sell on the tab that issued it (#2506)

Reviewed-on: OpenWF/SpaceNinjaServer#2506
Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
This commit is contained in:
Sainan 2025-07-18 15:36:10 -07:00 committed by Sainan
parent b0e80fcfa8
commit 90ab560620
4 changed files with 17 additions and 11 deletions

View File

@ -15,7 +15,7 @@ import { InventorySlot } from "@/src/types/inventoryTypes/inventoryTypes";
import { ExportDojoRecipes } from "warframe-public-export-plus"; import { ExportDojoRecipes } from "warframe-public-export-plus";
import { IInventoryChanges } from "@/src/types/purchaseTypes"; import { IInventoryChanges } from "@/src/types/purchaseTypes";
import { TInventoryDatabaseDocument } from "@/src/models/inventoryModels/inventoryModel"; import { TInventoryDatabaseDocument } from "@/src/models/inventoryModels/inventoryModel";
import { sendWsBroadcastTo } from "@/src/services/wsService"; import { sendWsBroadcastEx } from "@/src/services/wsService";
export const sellController: RequestHandler = async (req, res) => { export const sellController: RequestHandler = async (req, res) => {
const payload = JSON.parse(String(req.body)) as ISellRequest; const payload = JSON.parse(String(req.body)) as ISellRequest;
@ -295,7 +295,7 @@ export const sellController: RequestHandler = async (req, res) => {
res.json({ res.json({
inventoryChanges: inventoryChanges // "inventoryChanges" for this response instead of the usual "InventoryChanges" inventoryChanges: inventoryChanges // "inventoryChanges" for this response instead of the usual "InventoryChanges"
}); });
sendWsBroadcastTo(accountId, { update_inventory: true }); sendWsBroadcastEx({ update_inventory: true }, accountId, parseInt(String(req.query.wsid)));
}; };
interface ISellRequest { interface ISellRequest {

View File

@ -2,7 +2,7 @@ import { RequestHandler } from "express";
import { config, syncConfigWithDatabase } from "@/src/services/configService"; import { config, syncConfigWithDatabase } from "@/src/services/configService";
import { getAccountForRequest, isAdministrator } from "@/src/services/loginService"; import { getAccountForRequest, isAdministrator } from "@/src/services/loginService";
import { saveConfig } from "@/src/services/configWriterService"; import { saveConfig } from "@/src/services/configWriterService";
import { sendWsBroadcastExcept } from "@/src/services/wsService"; import { sendWsBroadcastEx } from "@/src/services/wsService";
export const getConfigController: RequestHandler = async (req, res) => { export const getConfigController: RequestHandler = async (req, res) => {
const account = await getAccountForRequest(req); const account = await getAccountForRequest(req);
@ -25,7 +25,7 @@ export const setConfigController: RequestHandler = async (req, res) => {
const [obj, idx] = configIdToIndexable(id); const [obj, idx] = configIdToIndexable(id);
obj[idx] = value; obj[idx] = value;
} }
sendWsBroadcastExcept(parseInt(String(req.query.wsid)), { config_reloaded: true }); sendWsBroadcastEx({ config_reloaded: true }, undefined, parseInt(String(req.query.wsid)));
syncConfigWithDatabase(); syncConfigWithDatabase();
await saveConfig(); await saveConfig();
res.end(); res.end();

View File

@ -43,7 +43,7 @@ export const stopWsServers = (promises: Promise<void>[]): void => {
let lastWsid: number = 0; let lastWsid: number = 0;
interface IWsCustomData extends ws { interface IWsCustomData extends ws {
id?: number; id: number;
accountId?: string; accountId?: string;
} }
@ -181,18 +181,24 @@ export const sendWsBroadcastTo = (accountId: string, data: IWsMsgToClient): void
} }
}; };
export const sendWsBroadcastExcept = (wsid: number | undefined, data: IWsMsgToClient): void => { export const sendWsBroadcastEx = (data: IWsMsgToClient, accountId?: string, excludeWsid?: number): void => {
const msg = JSON.stringify(data); const msg = JSON.stringify(data);
if (wsServer) { if (wsServer) {
for (const client of wsServer.clients) { for (const client of wsServer.clients) {
if ((client as IWsCustomData).id != wsid) { if (
(!accountId || (client as IWsCustomData).accountId == accountId) &&
(client as IWsCustomData).id != excludeWsid
) {
client.send(msg); client.send(msg);
} }
} }
} }
if (wssServer) { if (wssServer) {
for (const client of wssServer.clients) { for (const client of wssServer.clients) {
if ((client as IWsCustomData).id != wsid) { if (
(!accountId || (client as IWsCustomData).accountId == accountId) &&
(client as IWsCustomData).id != excludeWsid
) {
client.send(msg); client.send(msg);
} }
} }

View File

@ -1746,7 +1746,7 @@ function disposeOfGear(category, oid) {
]; ];
revalidateAuthz().then(() => { revalidateAuthz().then(() => {
$.post({ $.post({
url: "/api/sell.php?" + window.authz, url: "/api/sell.php?" + window.authz + "&wsid=" + wsid,
contentType: "text/plain", contentType: "text/plain",
data: JSON.stringify(data) data: JSON.stringify(data)
}); });
@ -1768,7 +1768,7 @@ function disposeOfItems(category, type, count) {
]; ];
revalidateAuthz().then(() => { revalidateAuthz().then(() => {
$.post({ $.post({
url: "/api/sell.php?" + window.authz, url: "/api/sell.php?" + window.authz + "&wsid=" + wsid,
contentType: "text/plain", contentType: "text/plain",
data: JSON.stringify(data) data: JSON.stringify(data)
}); });
@ -2202,7 +2202,7 @@ function doRemoveUnrankedMods() {
req.done(inventory => { req.done(inventory => {
window.itemListPromise.then(itemMap => { window.itemListPromise.then(itemMap => {
$.post({ $.post({
url: "/api/sell.php?" + window.authz, url: "/api/sell.php?" + window.authz + "&wsid=" + wsid,
contentType: "text/plain", contentType: "text/plain",
data: JSON.stringify({ data: JSON.stringify({
SellCurrency: "SC_RegularCredits", SellCurrency: "SC_RegularCredits",