Skip to content

Commit

Permalink
fix: performance optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
Vivomo committed Jan 21, 2024
1 parent 89b6178 commit 0ed6613
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/client/src/pages/game/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,19 +124,19 @@ const Game = () => {
}).sort((a, b) => b.oreBalance - a.oreBalance);
});

// const lootCache = useRef({});
const lootCache = useRef({});
const PlayersData = useStore((state: any) => {
const records = Object.values(state.getRecords(tables.Player));
return records.map((e:any) => {
let playerItem = Object.assign(e.value, {addr: e.key.addr})
//LootList1Data
let loot = LootList1Data.find((loot: any) => loot.addr == e.key.addr) || {};
if (!playerItem.equip) {
if (!lootCache.current[loot.addr]) {
// playerItem.equip = lootCache.current[loot.addr]
let clothes = loot?.chest?.replace(/"(.*?)"/, '').split(' of')[0].replace(/^\s+|\s+$/g,"")
let handheld = loot?.weapon?.replace(/"(.*?)"/, '').split(' of')[0].replace(/^\s+|\s+$/g,"")
let head = loot?.head?.replace(/"(.*?)"/, '').split(' of')[0].replace(/^\s+|\s+$/g,"")
playerItem.equip = {
lootCache.current[loot.addr] = playerItem.equip = {
clothes,
handheld,
head,
Expand Down

0 comments on commit 0ed6613

Please sign in to comment.