improve gamelog and prev info performance

This commit is contained in:
pa
2026-01-09 22:28:26 +09:00
committed by Natsumi
parent 97a0cddf68
commit 937294ebf7
3 changed files with 27 additions and 14 deletions
@@ -28,8 +28,8 @@
</el-table-column> </el-table-column>
<el-table-column :label="t('table.gameLog.icon')" prop="isFriend" width="70" align="center"> <el-table-column :label="t('table.gameLog.icon')" prop="isFriend" width="70" align="center">
<template #default="scope"> <template #default="scope">
<template v-if="gameLogIsFriend(scope.row)"> <template v-if="scope.row?.isFriend">
<TooltipWrapper v-if="gameLogIsFavorite(scope.row)" side="top" content="Favorite"> <TooltipWrapper v-if="scope.row?.isFavorite" side="top" content="Favorite">
<span></span> <span></span>
</TooltipWrapper> </TooltipWrapper>
<TooltipWrapper v-else side="top" content="Friend"> <TooltipWrapper v-else side="top" content="Friend">
@@ -146,6 +146,8 @@
const array = []; const array = [];
for (const entry of Array.from(data.values())) { for (const entry of Array.from(data.values())) {
entry.timer = timeToText(entry.time); entry.timer = timeToText(entry.time);
entry.isFriend = gameLogIsFriend(entry);
entry.isFavorite = gameLogIsFavorite(entry);
array.push(entry); array.push(entry);
} }
array.sort(compareByCreatedAt); array.sort(compareByCreatedAt);
+16 -5
View File
@@ -94,7 +94,10 @@ export const useGameLogStore = defineStore('GameLog', () => {
gameLogTable.value.data.length = 0; gameLogTable.value.data.length = 0;
gameLogSessionTable.value = []; gameLogSessionTable.value = [];
if (isLoggedIn) { if (isLoggedIn) {
initGameLogTable(); // wait for friends to load, silly but works
setTimeout(() => {
initGameLogTable();
}, 800);
} }
}, },
{ flush: 'sync' } { flush: 'sync' }
@@ -342,11 +345,18 @@ export const useGameLogStore = defineStore('GameLog', () => {
gameLogTable.value.filter, gameLogTable.value.filter,
vipList vipList
); );
for (const row of rows) {
row.isFriend = gameLogIsFriend(row);
row.isFavorite = gameLogIsFavorite(row);
}
gameLogTable.value.data = shallowReactive(rows); gameLogTable.value.data = shallowReactive(rows);
gameLogTable.value.loading = false; gameLogTable.value.loading = false;
} }
function addGameLog(entry) { function addGameLog(entry) {
entry.isFriend = gameLogIsFriend(entry);
entry.isFavorite = gameLogIsFavorite(entry);
gameLogSessionTable.value.push(entry); gameLogSessionTable.value.push(entry);
sweepGameLogSessionTable(); sweepGameLogSessionTable();
sharedFeedStore.updateSharedFeed(false); sharedFeedStore.updateSharedFeed(false);
@@ -386,10 +396,7 @@ export const useGameLogStore = defineStore('GameLog', () => {
if (!gameLogSearch(entry)) { if (!gameLogSearch(entry)) {
return; return;
} }
gameLogTable.value.data.push({ gameLogTable.value.data.push(entry);
...entry,
uid: crypto.randomUUID()
});
sweepGameLog(); sweepGameLog();
uiStore.notifyMenu('game-log'); uiStore.notifyMenu('game-log');
} }
@@ -1428,6 +1435,10 @@ export const useGameLogStore = defineStore('GameLog', () => {
gameLogTable.value.search, gameLogTable.value.search,
gameLogTable.value.filter gameLogTable.value.filter
); );
for (const row of rows) {
row.isFriend = gameLogIsFriend(row);
row.isFavorite = gameLogIsFavorite(row);
}
gameLogTable.value.data = shallowReactive(rows); gameLogTable.value.data = shallowReactive(rows);
} }
+7 -7
View File
@@ -116,6 +116,8 @@ export const createColumns = ({ getCreatedAt, onDelete, onDeletePrompt }) => {
header: () => t('table.gameLog.user'), header: () => t('table.gameLog.user'),
cell: ({ row }) => { cell: ({ row }) => {
const original = row.original; const original = row.original;
const isFriend = original.isFriend;
const isFavorite = original.isFavorite;
return ( return (
<span> <span>
{original.displayName ? ( {original.displayName ? (
@@ -126,10 +128,8 @@ export const createColumns = ({ getCreatedAt, onDelete, onDeletePrompt }) => {
{original.displayName} {original.displayName}
</span> </span>
) : null} ) : null}
{gameLogIsFriend(original) ? ( {isFriend ? (
<span> <span>{isFavorite ? '⭐' : '💚'}</span>
{gameLogIsFavorite(original) ? '⭐' : '💚'}
</span>
) : null} ) : null}
</span> </span>
); );
@@ -139,9 +139,9 @@ export const createColumns = ({ getCreatedAt, onDelete, onDeletePrompt }) => {
id: 'detail', id: 'detail',
header: () => t('table.gameLog.detail'), header: () => t('table.gameLog.detail'),
enableSorting: false, enableSorting: false,
meta: { meta: {
class: 'min-w-[240px] overflow-hidden' class: 'min-w-[240px] overflow-hidden'
}, },
cell: ({ row }) => { cell: ({ row }) => {
const original = row.original; const original = row.original;
if (original.type === 'Location') { if (original.type === 'Location') {