返回提交历史
Modified
src/controllers/custom/abilityOverrideController.ts
+1
-0
Modified
src/controllers/custom/addCurrencyController.ts
+7
-4
Modified
src/controllers/custom/popArchonCrystalUpgradeController.ts
+1
-1
Modified
src/controllers/custom/pushArchonCrystalUpgradeController.ts
+1
-1
Modified
src/controllers/custom/setBoosterController.ts
+1
-1
Modified
src/controllers/custom/setInvigorationController.ts
+1
-0
Modified
src/controllers/custom/setUmbraEchoesController.ts
+1
-0
Modified
src/controllers/custom/unlockLevelCapController.ts
+0
-1
Modified
static/webui/script.js
+64
-31
XFEstudio/SpaceNinjaServer
chore(webui): avoid redownloading entire inventory after basic actions (#3861)
Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/3861 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
3c6c2050
代码差异
9 个文件
+77
-39
@@ -20,6 +20,7 @@ export const abilityOverrideController: RequestHandler = async (req, res) => {
20
20
item.Configs[request.configIndex].AbilityOverride = undefined;
21
21
}
22
22
await inventory.save();
23
res.json(item.toJSON());
23
24
}
24
25
}
25
26
res.end();
@@ -11,9 +11,7 @@ export const addCurrencyController: RequestHandler = async (req, res) => {
11
11
let projection = request.currency as string;
12
12
if (request.currency.startsWith("Vault")) projection = "GuildId";
13
13
const inventory = await getInventory(account._id, projection);
14
if (request.currency == "FusionPoints") {
15
addFusionPoints(inventory, request.delta);
16
} else if (request.currency == "VaultRegularCredits" || request.currency == "VaultPremiumCredits") {
14
if (request.currency == "VaultRegularCredits" || request.currency == "VaultPremiumCredits") {
17
15
const guild = await getGuildForRequestEx(req, inventory);
18
16
if (await hasGuildPermission(guild, account._id, GuildPermission.Treasurer)) {
19
17
guild[request.currency] ??= 0;
@@ -23,8 +21,13 @@ export const addCurrencyController: RequestHandler = async (req, res) => {
23
21
}
24
22
} else {
25
23
if (hasPermission(account, currencyToPermission[request.currency])) {
26
inventory[request.currency] += request.delta;
24
if (request.currency == "FusionPoints") {
25
addFusionPoints(inventory, request.delta);
26
} else {
27
inventory[request.currency] += request.delta;
28
}
27
29
}
30
res.json(inventory[request.currency]);
28
31
}
29
32
if (!request.currency.startsWith("Vault")) {
30
33
await inventory.save();
@@ -12,7 +12,7 @@ export const popArchonCrystalUpgradeController: RequestHandler = async (req, res
12
12
x => x.UpgradeType != (req.query.type as string)
13
13
);
14
14
await inventory.save();
15
res.end();
15
res.json(suit.toJSON());
16
16
broadcastInventoryUpdate(req);
17
17
return;
18
18
}
@@ -15,7 +15,7 @@ export const pushArchonCrystalUpgradeController: RequestHandler = async (req, re
15
15
suit.ArchonCrystalUpgrades.push({ UpgradeType: req.query.type as string });
16
16
}
17
17
await inventory.save();
18
res.end();
18
res.json(suit.toJSON());
19
19
broadcastInventoryUpdate(req);
20
20
return;
21
21
}
@@ -17,6 +17,6 @@ export const setBoosterController: RequestHandler = async (req, res) => {
17
17
}
18
18
}
19
19
await inventory.save();
20
res.end();
20
res.json(inventory.Boosters);
21
21
broadcastInventoryUpdate(req);
22
22
};
@@ -14,6 +14,7 @@ export const setInvigorationController: RequestHandler = async (req, res) => {
14
14
suit.OffensiveUpgrade = hasUpgrades ? request.OffensiveUpgrade : undefined;
15
15
suit.UpgradesExpiry = hasUpgrades ? new Date(request.UpgradesExpiry) : undefined;
16
16
await inventory.save();
17
res.json(suit.toJSON());
17
18
broadcastInventoryUpdate(req);
18
19
}
19
20
res.end();
@@ -11,6 +11,7 @@ export const setUmbraEchoesController: RequestHandler = async (req, res) => {
11
11
if (suit) {
12
12
suit.UmbraDate = request.UmbraDate ? new Date(request.UmbraDate) : undefined;
13
13
await inventory.save();
14
res.json(suit.toJSON());
14
15
broadcastInventoryUpdate(req);
15
16
}
16
17
res.end();
@@ -10,7 +10,6 @@ export const unlockLevelCapController: RequestHandler = async (req, res) => {
10
10
const inventory = await getInventory(accountId, data.Category);
11
11
const equipment = inventory[data.Category].id(data.ItemId)!;
12
12
13
equipment.Polarized ??= 0;
14
13
equipment.Polarized = data.Polarized;
15
14
16
15
await inventory.save();
@@ -1368,6 +1368,7 @@ async function populateInventoryRoute() {
1368
1368
a.href = "#";
1369
1369
a.onclick = function (event) {
1370
1370
event.preventDefault();
1371
a.parentNode.removeChild(a);
1371
1372
unlockLevelCap(category, item.ItemId.$oid, (itemMap[item.ItemType].maxLevelCap - 30) / 2);
1372
1373
};
1373
1374
a.title = loc("code_unlockLevelCap");
@@ -1640,6 +1641,7 @@ async function populateInventoryRoute() {
1640
1641
a.href = "#";
1641
1642
a.onclick = function (event) {
1642
1643
event.preventDefault();
1644
tr.parentNode.removeChild(tr);
1643
1645
removeCustomization(item.ItemType);
1644
1646
};
1645
1647
a.title = loc("code_remove");
@@ -1713,7 +1715,8 @@ async function populateInventoryRoute() {
1713
1715
a.href = "#";
1714
1716
a.onclick = function (event) {
1715
1717
event.preventDefault();
1716
removeCountItems(item.ItemType, item.ItemCount);
1718
tr.parentNode.removeChild(tr);
1719
removeShipDecoration(item.ItemType, item.ItemCount);
1717
1720
};
1718
1721
a.title = loc("code_remove");
1719
1722
a.innerHTML = icons.trash;
@@ -2275,17 +2278,17 @@ function removeCustomization(uniqueName) {
2275
2278
revalidateAuthz().then(() => {
2276
2279
const req = $.get("/custom/removeCustomization?" + window.authz + "&itemType=" + uniqueName);
2277
2280
req.done(() => {
2278
updateInventory();
2281
inventory_data.FlavourItems.splice(
2282
inventory_data.FlavourItems.findIndex(x => x.ItemType == uniqueName),
2283
1
2284
);
2279
2285
});
2280
2286
});
2281
2287
}
2282
2288
2283
2289
function removeIsNew() {
2284
2290
revalidateAuthz().then(() => {
2285
const req = $.get("/custom/removeIsNew?" + window.authz);
2286
req.done(() => {
2287
updateInventory();
2288
});
2291
$.get("/custom/removeIsNew?" + window.authz);
2289
2292
});
2290
2293
}
2291
2294
@@ -2978,7 +2981,8 @@ function renameGear(category, oid, name) {
2978
2981
name: name
2979
2982
})
2980
2983
}).done(function () {
2981
updateInventory();
2984
inventory_data.KubrowPets.find(x => x.ItemId.$oid == oid).Details.Name = name;
2985
populateInventoryRoute();
2982
2986
});
2983
2987
} else {
2984
2988
$.post({
@@ -2988,7 +2992,8 @@ function renameGear(category, oid, name) {
2988
2992
ItemName: name
2989
2993
})
2990
2994
}).done(function () {
2991
updateInventory();
2995
inventory_data[category].find(x => x.ItemId.$oid == oid).ItemName = name;
2996
populateInventoryRoute();
2992
2997
});
2993
2998
}
2994
2999
});
@@ -3071,7 +3076,7 @@ function unlockLevelCap(category, oid, formas) {
3071
3076
Polarized: formas
3072
3077
})
3073
3078
}).done(function () {
3074
updateInventory();
3079
inventory_data[category].find(x => x.ItemId.$oid == oid).Polarized = formas;
3075
3080
});
3076
3081
});
3077
3082
}
@@ -3086,7 +3091,8 @@ function maturePet(oid, revert) {
3086
3091
revert
3087
3092
})
3088
3093
}).done(function () {
3089
updateInventory();
3094
inventory_data.KubrowPets.find(x => x.ItemId.$oid == oid).Details.IsPuppy = revert;
3095
populateInventoryRoute();
3090
3096
});
3091
3097
});
3092
3098
}
@@ -3146,7 +3152,7 @@ function doAcquireCountItems(category) {
3146
3152
}
3147
3153
}
3148
3154
3149
function removeCountItems(uniqueName, count) {
3155
function removeShipDecoration(uniqueName, count) {
3150
3156
revalidateAuthz().then(() => {
3151
3157
$.post({
3152
3158
url: "/custom/addItems?" + window.authz,
@@ -3158,8 +3164,11 @@ function removeCountItems(uniqueName, count) {
3158
3164
}
3159
3165
])
3160
3166
}).done(function () {
3167
inventory_data.ShipDecorations.splice(
3168
inventory_data.ShipDecorations.findIndex(x => x.ItemType == uniqueName),
3169
1
3170
);
3161
3171
toast(loc("code_succRemoved"));
3162
updateInventory();
3163
3172
});
3164
3173
});
3165
3174
}
@@ -3720,6 +3729,10 @@ single.getRoute("#detailedView-route").on("beforeload", async function () {
3720
3729
document.getElementById("equipmentFeatures-card").classList.add("d-none");
3721
3730
document.getElementById("equipmentFeaturesButtons-card").innerHTML = "";
3722
3731
3732
populateDetailedViewRoute();
3733
});
3734
3735
async function populateDetailedViewRoute() {
3723
3736
const [data, itemMap] = await Promise.all([awaitAuthz().then(getInventoryData), window.itemListPromise]);
3724
3737
3725
3738
const urlParams = new URLSearchParams(window.location.search);
@@ -4050,7 +4063,7 @@ single.getRoute("#detailedView-route").on("beforeload", async function () {
4050
4063
} else {
4051
4064
single.loadRoute("/webui/inventory");
4052
4065
}
4053
});
4066
}
4054
4067
4055
4068
single.getRoute("#guild-route").on("beforeload", function () {
4056
4069
document.getElementById("guildView-loading").classList.remove("d-none");
@@ -4414,9 +4427,12 @@ function doPushArchonCrystalUpgrade() {
4414
4427
revalidateAuthz().then(() => {
4415
4428
$.get(
4416
4429
`/custom/pushArchonCrystalUpgrade?${window.authz}&oid=${urlParams.get("itemId")}&type=${uniqueName}&count=${$("#archon-crystal-add-count").val()}`
4417
).done(function () {
4430
).done(function (updatedSuit) {
4418
4431
$("[list='datalist-archonCrystalUpgrades']").val("");
4419
updateInventory();
4432
4433
const index = inventory_data.Suits.findIndex(x => x.ItemId.$oid == urlParams.get("itemId"));
4434
inventory_data.Suits[index] = updatedSuit;
4435
populateDetailedViewRoute();
4420
4436
});
4421
4437
});
4422
4438
}
@@ -4426,8 +4442,10 @@ function doPopArchonCrystalUpgrade(type) {
4426
4442
revalidateAuthz().then(() => {
4427
4443
$.get(
4428
4444
"/custom/popArchonCrystalUpgrade?" + window.authz + "&oid=" + urlParams.get("itemId") + "&type=" + type
4429
).done(function () {
4430
updateInventory();
4445
).done(function (updatedSuit) {
4446
const index = inventory_data.Suits.findIndex(x => x.ItemId.$oid == urlParams.get("itemId"));
4447
inventory_data.Suits[index] = updatedSuit;
4448
populateDetailedViewRoute();
4431
4449
});
4432
4450
});
4433
4451
}
@@ -4461,7 +4479,7 @@ function doChangeSupportedSyndicate() {
4461
4479
4462
4480
revalidateAuthz().then(() => {
4463
4481
$.get("/api/setSupportedSyndicate.php?" + window.authz + "&syndicate=" + uniqueName).done(function () {
4464
updateInventory();
4482
inventory_data.SupportedSyndicate = uniqueName;
4465
4483
});
4466
4484
});
4467
4485
}
@@ -4481,7 +4499,10 @@ function doAddCurrency(currency) {
4481
4499
.split("|COUNT|")
4482
4500
.join((newValue ?? 0).toLocaleString());
4483
4501
} else {
4484
updateInventory();
4502
inventory_data[currency] = newValue;
4503
document.getElementById(currency + "-owned").textContent = loc("currency_owned")
4504
.split("|COUNT|")
4505
.join((newValue ?? 0).toLocaleString());
4485
4506
}
4486
4507
});
4487
4508
});
@@ -4603,8 +4624,9 @@ function setBooster(ItemType, ExpiryDate) {
4603
4624
ExpiryDate
4604
4625
}
4605
4626
])
4606
}).done(function () {
4607
updateInventory();
4627
}).done(function (newBoosters) {
4628
inventory_data.Boosters = newBoosters;
4629
populateInventoryRoute();
4608
4630
});
4609
4631
});
4610
4632
}
@@ -5155,7 +5177,7 @@ function handleValenceBonusChange(event) {
5155
5177
}
5156
5178
})
5157
5179
}).done(function () {
5158
updateInventory();
5180
inventory_data = undefined; // UI is up-to-date now, but subsequent updates will need to grab new data
5159
5181
});
5160
5182
});
5161
5183
}
@@ -5428,7 +5450,7 @@ function handleModularPartsChange(event) {
5428
5450
})
5429
5451
}).then(function () {
5430
5452
toast(loc("code_succChange"));
5431
updateInventory();
5453
inventory_data = undefined; // UI is up-to-date now, but subsequent updates will need to grab new data
5432
5454
});
5433
5455
});
5434
5456
}
@@ -5458,8 +5480,10 @@ function setInvigoration(data) {
5458
5480
url: "/custom/setInvigoration?" + window.authz,
5459
5481
contentType: "application/json",
5460
5482
data: JSON.stringify({ oid, ...data })
5461
}).done(function () {
5462
updateInventory();
5483
}).done(function (updatedSuit) {
5484
const index = inventory_data.Suits.findIndex(x => x.ItemId.$oid == oid);
5485
inventory_data.Suits[index] = updatedSuit;
5486
populateDetailedViewRoute();
5463
5487
});
5464
5488
}
5465
5489
@@ -5477,8 +5501,10 @@ function setUmbraEchoes(data) {
5477
5501
url: "/custom/setUmbraEchoes?" + window.authz,
5478
5502
contentType: "application/json",
5479
5503
data: JSON.stringify({ oid, ...data })
5480
}).done(function () {
5481
updateInventory();
5504
}).done(function (updatedSuit) {
5505
const index = inventory_data.Suits.findIndex(x => x.ItemId.$oid == oid);
5506
inventory_data.Suits[index] = updatedSuit;
5507
populateDetailedViewRoute();
5482
5508
});
5483
5509
}
5484
5510
@@ -5493,14 +5519,16 @@ function handleAbilityOverride(event, configIndex) {
5493
5519
}
5494
5520
const input = document.getElementById(`abilityOverride-ability-index-config-${configIndex}`);
5495
5521
if (!input.value) return;
5522
const category = urlParams.get("productCategory");
5523
const oid = urlParams.get("itemId");
5496
5524
const Index = input.value - 1;
5497
5525
revalidateAuthz().then(() => {
5498
5526
$.post({
5499
5527
url: "/custom/abilityOverride?" + window.authz,
5500
5528
contentType: "application/json",
5501
5529
data: JSON.stringify({
5502
category: urlParams.get("productCategory"),
5503
oid: urlParams.get("itemId"),
5530
category,
5531
oid,
5504
5532
configIndex,
5505
5533
action,
5506
5534
AbilityOverride: {
@@ -5508,9 +5536,14 @@ function handleAbilityOverride(event, configIndex) {
5508
5536
Index
5509
5537
}
5510
5538
})
5511
}).done(function () {
5539
}).done(function (updatedItem) {
5540
const index = inventory_data[category].findIndex(x => x.ItemId.$oid == oid);
5541
inventory_data[category][index] = updatedItem;
5542
if (action != "set") {
5543
populateDetailedViewRoute();
5544
}
5545
5512
5546
toast(loc("code_succChange"));
5513
updateInventory();
5514
5547
});
5515
5548
});
5516
5549
}