mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-05-06 14:46:04 +02:00
use immutable array operations for game log table data to ensure reactivity
This commit is contained in:
+16
-12
@@ -173,26 +173,30 @@ export const useGameLogStore = defineStore('GameLog', () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function insertGameLogSorted(entry) {
|
function insertGameLogSorted(entry) {
|
||||||
const data = gameLogTableData;
|
const arr = gameLogTableData.value;
|
||||||
if (data.value.length === 0) {
|
if (arr.length === 0) {
|
||||||
data.value.push(entry);
|
gameLogTableData.value = [entry];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (compareGameLogRows(entry, data.value[0]) < 0) {
|
if (compareGameLogRows(entry, arr[0]) < 0) {
|
||||||
data.value.unshift(entry);
|
gameLogTableData.value = [entry, ...arr];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (compareGameLogRows(entry, data[data.value.length - 1]) > 0) {
|
if (compareGameLogRows(entry, arr[arr.length - 1]) > 0) {
|
||||||
data.value.push(entry);
|
gameLogTableData.value = [...arr, entry];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (let i = 1; i < data.value.length; i++) {
|
for (let i = 1; i < arr.length; i++) {
|
||||||
if (compareGameLogRows(entry, data[i]) < 0) {
|
if (compareGameLogRows(entry, arr[i]) < 0) {
|
||||||
data.value.splice(i, 0, entry);
|
gameLogTableData.value = [
|
||||||
|
...arr.slice(0, i),
|
||||||
|
entry,
|
||||||
|
...arr.slice(i)
|
||||||
|
];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
data.value.push(entry);
|
gameLogTableData.value = [...arr, entry];
|
||||||
}
|
}
|
||||||
|
|
||||||
function clearNowPlaying() {
|
function clearNowPlaying() {
|
||||||
@@ -549,7 +553,7 @@ export const useGameLogStore = defineStore('GameLog', () => {
|
|||||||
function sweepGameLog() {
|
function sweepGameLog() {
|
||||||
const j = gameLogTableData.value.length;
|
const j = gameLogTableData.value.length;
|
||||||
if (j > vrcxStore.maxTableSize + 50) {
|
if (j > vrcxStore.maxTableSize + 50) {
|
||||||
gameLogTableData.value.splice(-50, 50);
|
gameLogTableData.value = gameLogTableData.value.slice(0, -50);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user