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

View File

@@ -28,8 +28,8 @@
</el-table-column>
<el-table-column :label="t('table.gameLog.icon')" prop="isFriend" width="70" align="center">
<template #default="scope">
<template v-if="gameLogIsFriend(scope.row)">
<TooltipWrapper v-if="gameLogIsFavorite(scope.row)" side="top" content="Favorite">
<template v-if="scope.row?.isFriend">
<TooltipWrapper v-if="scope.row?.isFavorite" side="top" content="Favorite">
<span></span>
</TooltipWrapper>
<TooltipWrapper v-else side="top" content="Friend">
@@ -146,6 +146,8 @@
const array = [];
for (const entry of Array.from(data.values())) {
entry.timer = timeToText(entry.time);
entry.isFriend = gameLogIsFriend(entry);
entry.isFavorite = gameLogIsFavorite(entry);
array.push(entry);
}
array.sort(compareByCreatedAt);

View File

@@ -94,7 +94,10 @@ export const useGameLogStore = defineStore('GameLog', () => {
gameLogTable.value.data.length = 0;
gameLogSessionTable.value = [];
if (isLoggedIn) {
initGameLogTable();
// wait for friends to load, silly but works
setTimeout(() => {
initGameLogTable();
}, 800);
}
},
{ flush: 'sync' }
@@ -342,11 +345,18 @@ export const useGameLogStore = defineStore('GameLog', () => {
gameLogTable.value.filter,
vipList
);
for (const row of rows) {
row.isFriend = gameLogIsFriend(row);
row.isFavorite = gameLogIsFavorite(row);
}
gameLogTable.value.data = shallowReactive(rows);
gameLogTable.value.loading = false;
}
function addGameLog(entry) {
entry.isFriend = gameLogIsFriend(entry);
entry.isFavorite = gameLogIsFavorite(entry);
gameLogSessionTable.value.push(entry);
sweepGameLogSessionTable();
sharedFeedStore.updateSharedFeed(false);
@@ -386,10 +396,7 @@ export const useGameLogStore = defineStore('GameLog', () => {
if (!gameLogSearch(entry)) {
return;
}
gameLogTable.value.data.push({
...entry,
uid: crypto.randomUUID()
});
gameLogTable.value.data.push(entry);
sweepGameLog();
uiStore.notifyMenu('game-log');
}
@@ -1428,6 +1435,10 @@ export const useGameLogStore = defineStore('GameLog', () => {
gameLogTable.value.search,
gameLogTable.value.filter
);
for (const row of rows) {
row.isFriend = gameLogIsFriend(row);
row.isFavorite = gameLogIsFavorite(row);
}
gameLogTable.value.data = shallowReactive(rows);
}

View File

@@ -116,6 +116,8 @@ export const createColumns = ({ getCreatedAt, onDelete, onDeletePrompt }) => {
header: () => t('table.gameLog.user'),
cell: ({ row }) => {
const original = row.original;
const isFriend = original.isFriend;
const isFavorite = original.isFavorite;
return (
<span>
{original.displayName ? (
@@ -126,10 +128,8 @@ export const createColumns = ({ getCreatedAt, onDelete, onDeletePrompt }) => {
{original.displayName}
</span>
) : null}
{gameLogIsFriend(original) ? (
<span>
{gameLogIsFavorite(original) ? '⭐' : '💚'}
</span>
{isFriend ? (
<span>{isFavorite ? '⭐' : '💚'}</span>
) : null}
</span>
);
@@ -139,9 +139,9 @@ export const createColumns = ({ getCreatedAt, onDelete, onDeletePrompt }) => {
id: 'detail',
header: () => t('table.gameLog.detail'),
enableSorting: false,
meta: {
class: 'min-w-[240px] overflow-hidden'
},
meta: {
class: 'min-w-[240px] overflow-hidden'
},
cell: ({ row }) => {
const original = row.original;
if (original.type === 'Location') {