mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-05-06 14:46:04 +02:00
add searchTableSize limit
This commit is contained in:
+3
-2
@@ -1,4 +1,4 @@
|
||||
import { ref, shallowReactive, shallowRef, watch } from 'vue';
|
||||
import { ref, shallowRef, watch } from 'vue';
|
||||
import { defineStore } from 'pinia';
|
||||
|
||||
import { database } from '../service/database';
|
||||
@@ -149,7 +149,8 @@ export const useFeedStore = defineStore('Feed', () => {
|
||||
? await database.searchFeedDatabase(
|
||||
search,
|
||||
feedTable.value.filter,
|
||||
vipList
|
||||
vipList,
|
||||
vrcxStore.searchLimit
|
||||
)
|
||||
: await database.lookupFeedDatabase(
|
||||
feedTable.value.filter,
|
||||
|
||||
@@ -407,7 +407,8 @@ export const useGameLogStore = defineStore('GameLog', () => {
|
||||
rows = await database.searchGameLogDatabase(
|
||||
search,
|
||||
gameLogTable.value.filter,
|
||||
vipList
|
||||
vipList,
|
||||
vrcxStore.searchLimit
|
||||
);
|
||||
} else {
|
||||
rows = await database.lookupGameLogDatabase(
|
||||
|
||||
@@ -3,6 +3,15 @@ import { defineStore } from 'pinia';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRouter } from 'vue-router';
|
||||
|
||||
import {
|
||||
APP_FONT_DEFAULT_KEY,
|
||||
APP_FONT_FAMILIES,
|
||||
SEARCH_LIMIT_MAX,
|
||||
SEARCH_LIMIT_MIN,
|
||||
TABLE_MAX_SIZE_MAX,
|
||||
TABLE_MAX_SIZE_MIN,
|
||||
THEME_CONFIG
|
||||
} from '../../shared/constants';
|
||||
import {
|
||||
HueToHex,
|
||||
applyAppFontFamily,
|
||||
@@ -11,18 +20,12 @@ import {
|
||||
getThemeMode,
|
||||
updateTrustColorClasses
|
||||
} from '../../shared/utils/base/ui';
|
||||
import {
|
||||
APP_FONT_DEFAULT_KEY,
|
||||
APP_FONT_FAMILIES,
|
||||
THEME_CONFIG
|
||||
} from '../../shared/constants';
|
||||
import { database } from '../../service/database';
|
||||
import { getNameColour } from '../../shared/utils';
|
||||
import { languageCodes } from '../../localization';
|
||||
import { loadLocalizedStrings } from '../../plugin';
|
||||
import { useFeedStore } from '../feed';
|
||||
import { useGameLogStore } from '../gameLog';
|
||||
import { useModalStore } from '../modal';
|
||||
import { useUiStore } from '../ui';
|
||||
import { useUserStore } from '../user';
|
||||
import { useVrStore } from '../vr';
|
||||
@@ -42,9 +45,7 @@ export const useAppearanceSettingsStore = defineStore(
|
||||
const userStore = useUserStore();
|
||||
const router = useRouter();
|
||||
const uiStore = useUiStore();
|
||||
const modalStore = useModalStore();
|
||||
|
||||
const { t, locale } = useI18n();
|
||||
const { locale } = useI18n();
|
||||
|
||||
const MAX_TABLE_PAGE_SIZE = 1000;
|
||||
const DEFAULT_TABLE_PAGE_SIZES = [10, 15, 20, 25, 50, 100];
|
||||
@@ -106,6 +107,11 @@ export const useAppearanceSettingsStore = defineStore(
|
||||
|
||||
const isDataTableStriped = ref(false);
|
||||
const showPointerOnHover = ref(false);
|
||||
const tableLimitsDialog = ref({
|
||||
visible: false,
|
||||
maxTableSize: 500,
|
||||
searchLimit: 5000
|
||||
});
|
||||
|
||||
const clampInt = (value, min, max) => {
|
||||
const n = parseInt(value, 10);
|
||||
@@ -864,36 +870,67 @@ export const useAppearanceSettingsStore = defineStore(
|
||||
}
|
||||
}
|
||||
|
||||
function promptMaxTableSizeDialog() {
|
||||
modalStore
|
||||
.prompt({
|
||||
title: t('prompt.change_table_size.header'),
|
||||
description: t('prompt.change_table_size.description'),
|
||||
confirmText: t('prompt.change_table_size.save'),
|
||||
cancelText: t('prompt.change_table_size.cancel'),
|
||||
inputValue: vrcxStore.maxTableSize.toString(),
|
||||
pattern: /\d+$/,
|
||||
errorMessage: t('prompt.change_table_size.input_error')
|
||||
})
|
||||
.then(async ({ ok, value }) => {
|
||||
if (!ok) return;
|
||||
if (value) {
|
||||
// TODO
|
||||
let processedValue = Number(value);
|
||||
if (processedValue > 10000) {
|
||||
processedValue = 10000;
|
||||
}
|
||||
vrcxStore.maxTableSize = processedValue;
|
||||
await configRepository.setString(
|
||||
'VRCX_maxTableSize',
|
||||
vrcxStore.maxTableSize.toString()
|
||||
);
|
||||
database.setMaxTableSize(vrcxStore.maxTableSize);
|
||||
feedStore.feedTableLookup();
|
||||
gameLogStore.gameLogTableLookup();
|
||||
}
|
||||
})
|
||||
.catch(() => {});
|
||||
const clampLimit = (value, min, max) => {
|
||||
const n = Number.parseInt(value, 10);
|
||||
if (!Number.isFinite(n)) {
|
||||
return null;
|
||||
}
|
||||
if (n < min || n > max) {
|
||||
return null;
|
||||
}
|
||||
return n;
|
||||
};
|
||||
|
||||
function showTableLimitsDialog() {
|
||||
tableLimitsDialog.value.maxTableSize = Number(
|
||||
vrcxStore.maxTableSize ?? 500
|
||||
);
|
||||
tableLimitsDialog.value.searchLimit = Number(
|
||||
vrcxStore.searchLimit ?? 5000
|
||||
);
|
||||
tableLimitsDialog.value.visible = true;
|
||||
}
|
||||
|
||||
function closeTableLimitsDialog() {
|
||||
tableLimitsDialog.value.visible = false;
|
||||
}
|
||||
|
||||
async function saveTableLimitsDialog() {
|
||||
const nextMaxTableSize = clampLimit(
|
||||
tableLimitsDialog.value.maxTableSize,
|
||||
TABLE_MAX_SIZE_MIN,
|
||||
TABLE_MAX_SIZE_MAX
|
||||
);
|
||||
if (nextMaxTableSize === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
const nextSearchLimit = clampLimit(
|
||||
tableLimitsDialog.value.searchLimit,
|
||||
SEARCH_LIMIT_MIN,
|
||||
SEARCH_LIMIT_MAX
|
||||
);
|
||||
if (nextSearchLimit === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
vrcxStore.maxTableSize = nextMaxTableSize;
|
||||
await configRepository.setString(
|
||||
'VRCX_maxTableSize',
|
||||
vrcxStore.maxTableSize.toString()
|
||||
);
|
||||
database.setMaxTableSize(vrcxStore.maxTableSize);
|
||||
|
||||
vrcxStore.searchLimit = nextSearchLimit;
|
||||
await configRepository.setInt(
|
||||
'VRCX_searchLimit',
|
||||
vrcxStore.searchLimit
|
||||
);
|
||||
database.setSearchTableSize(vrcxStore.searchLimit);
|
||||
|
||||
feedStore.feedTableLookup();
|
||||
gameLogStore.gameLogTableLookup();
|
||||
tableLimitsDialog.value.visible = false;
|
||||
}
|
||||
|
||||
async function tryInitUserColours() {
|
||||
@@ -952,6 +989,11 @@ export const useAppearanceSettingsStore = defineStore(
|
||||
isNavCollapsed,
|
||||
isDataTableStriped,
|
||||
showPointerOnHover,
|
||||
tableLimitsDialog,
|
||||
TABLE_MAX_SIZE_MIN,
|
||||
TABLE_MAX_SIZE_MAX,
|
||||
SEARCH_LIMIT_MIN,
|
||||
SEARCH_LIMIT_MAX,
|
||||
|
||||
setAppLanguage,
|
||||
setDisplayVRCPlusIconsAsAvatar,
|
||||
@@ -986,7 +1028,9 @@ export const useAppearanceSettingsStore = defineStore(
|
||||
userColourInit,
|
||||
applyUserTrustLevel,
|
||||
changeAppLanguage,
|
||||
promptMaxTableSizeDialog,
|
||||
showTableLimitsDialog,
|
||||
closeTableLimitsDialog,
|
||||
saveTableLimitsDialog,
|
||||
setNotificationIconDot,
|
||||
applyTableDensity,
|
||||
setNavCollapsed,
|
||||
|
||||
+45
-4
@@ -5,6 +5,14 @@ import { useI18n } from 'vue-i18n';
|
||||
|
||||
import Noty from 'noty';
|
||||
|
||||
import {
|
||||
DEFAULT_MAX_TABLE_SIZE,
|
||||
DEFAULT_SEARCH_LIMIT,
|
||||
LEGACY_MAX_TABLE_SIZE_DEFAULT,
|
||||
SEARCH_LIMIT_MAX,
|
||||
SEARCH_LIMIT_MIN,
|
||||
TABLE_MAX_SIZE_MAX
|
||||
} from '../shared/constants';
|
||||
import {
|
||||
clearPiniaActionTrail,
|
||||
getPiniaActionTrail
|
||||
@@ -74,7 +82,8 @@ export const useVrcxStore = defineStore('Vrcx', () => {
|
||||
const isRegistryBackupDialogVisible = ref(false);
|
||||
const ipcEnabled = ref(false);
|
||||
const clearVRCXCacheFrequency = ref(172800);
|
||||
const maxTableSize = ref(1000);
|
||||
const maxTableSize = ref(DEFAULT_MAX_TABLE_SIZE);
|
||||
const searchLimit = ref(DEFAULT_SEARCH_LIMIT);
|
||||
const proxyServer = ref('');
|
||||
|
||||
async function init() {
|
||||
@@ -148,13 +157,44 @@ export const useVrcxStore = defineStore('Vrcx', () => {
|
||||
|
||||
maxTableSize.value = await configRepository.getInt(
|
||||
'VRCX_maxTableSize',
|
||||
1000
|
||||
LEGACY_MAX_TABLE_SIZE_DEFAULT
|
||||
);
|
||||
if (maxTableSize.value > 10000) {
|
||||
maxTableSize.value = 1000;
|
||||
if (maxTableSize.value > TABLE_MAX_SIZE_MAX) {
|
||||
maxTableSize.value = TABLE_MAX_SIZE_MAX;
|
||||
}
|
||||
const maxTableSizeMigrated = await configRepository.getBool(
|
||||
'VRCX_maxTableSizeMigrated500',
|
||||
false
|
||||
);
|
||||
// Migrate old default table size (1000) to new default (500)
|
||||
if (
|
||||
maxTableSize.value === LEGACY_MAX_TABLE_SIZE_DEFAULT &&
|
||||
!maxTableSizeMigrated
|
||||
) {
|
||||
maxTableSize.value = DEFAULT_MAX_TABLE_SIZE;
|
||||
await configRepository.setInt(
|
||||
'VRCX_maxTableSize',
|
||||
maxTableSize.value
|
||||
);
|
||||
await configRepository.setBool(
|
||||
'VRCX_maxTableSizeMigrated500',
|
||||
true
|
||||
);
|
||||
}
|
||||
database.setMaxTableSize(maxTableSize.value);
|
||||
|
||||
searchLimit.value = await configRepository.getInt(
|
||||
'VRCX_searchLimit',
|
||||
DEFAULT_SEARCH_LIMIT
|
||||
);
|
||||
if (searchLimit.value < SEARCH_LIMIT_MIN) {
|
||||
searchLimit.value = SEARCH_LIMIT_MIN;
|
||||
}
|
||||
if (searchLimit.value > SEARCH_LIMIT_MAX) {
|
||||
searchLimit.value = SEARCH_LIMIT_MAX;
|
||||
}
|
||||
database.setSearchTableSize(searchLimit.value);
|
||||
|
||||
refreshCustomScript();
|
||||
}
|
||||
|
||||
@@ -787,6 +827,7 @@ export const useVrcxStore = defineStore('Vrcx', () => {
|
||||
ipcEnabled,
|
||||
clearVRCXCacheFrequency,
|
||||
maxTableSize,
|
||||
searchLimit,
|
||||
clearVRCXCache,
|
||||
eventVrcxMessage,
|
||||
eventLaunchCommand,
|
||||
|
||||
Reference in New Issue
Block a user