diff --git a/src/components/dialogs/PreviousInstancesDialog/PreviousInstancesInfoDialog.vue b/src/components/dialogs/PreviousInstancesDialog/PreviousInstancesInfoDialog.vue index 3edc357a..256e1c56 100644 --- a/src/components/dialogs/PreviousInstancesDialog/PreviousInstancesInfoDialog.vue +++ b/src/components/dialogs/PreviousInstancesDialog/PreviousInstancesInfoDialog.vue @@ -127,7 +127,7 @@ const totalItems = computed(() => { const length = table.getFilteredRowModel().rows.length; const max = vrcxStore.maxTableSize; - return length > max && length < max + 51 ? max : length; + return length > max ? max : length; }); const handlePageSizeChange = (size) => { diff --git a/src/components/dialogs/PreviousInstancesDialog/PreviousInstancesListDialog.vue b/src/components/dialogs/PreviousInstancesDialog/PreviousInstancesListDialog.vue index 65d38d59..f0e17213 100644 --- a/src/components/dialogs/PreviousInstancesDialog/PreviousInstancesListDialog.vue +++ b/src/components/dialogs/PreviousInstancesDialog/PreviousInstancesListDialog.vue @@ -225,7 +225,7 @@ const totalItems = computed(() => { const length = table.getFilteredRowModel().rows.length; const max = vrcxStore.maxTableSize; - return length > max && length < max + 51 ? max : length; + return length > max ? max : length; }); const handlePageSizeChange = (size) => { diff --git a/src/components/dialogs/TableLimitsDialog.vue b/src/components/dialogs/TableLimitsDialog.vue new file mode 100644 index 00000000..d2a7bfd3 --- /dev/null +++ b/src/components/dialogs/TableLimitsDialog.vue @@ -0,0 +1,121 @@ + + + + + diff --git a/src/localization/cs.json b/src/localization/cs.json index 9ea37e32..d73b1814 100644 --- a/src/localization/cs.json +++ b/src/localization/cs.json @@ -288,7 +288,6 @@ "sort_instance_users_by": "Řadit uživatele v instanci podle", "sort_instance_users_by_time": "času", "sort_instance_users_by_alphabet": "abecedně", - "table_max_size": "Magimální velikost tabulky", "page_size": "Velikost stránky:" }, "timedate": { @@ -1681,7 +1680,8 @@ }, "change_table_size": { "header": "Max Table Size", - "description": "Limit amount of entries loaded from database to UI pages, larger table sizes will impact RAM usage and performance (default: 1000, max: 10000)", + "description": "Limit amount of entries loaded from database to UI pages, larger table sizes will impact RAM usage and performance", + "table_max_size": "Magimální velikost tabulky", "cancel": "Cancel", "save": "Save", "input_error": "Valid number is required" diff --git a/src/localization/en.json b/src/localization/en.json index 4cba1c16..cf574f22 100644 --- a/src/localization/en.json +++ b/src/localization/en.json @@ -2319,7 +2319,12 @@ }, "change_table_size": { "header": "Max Table Size", - "description": "Limit amount of entries loaded from database to UI pages, larger table sizes will impact RAM usage and performance (default: 1000, max: 10000)", + "description": "Limit amount of entries loaded from database to UI pages, larger table sizes will impact RAM usage and performance", + "table_max_size": "Table Max Size", + "table_max_size_error": "Enter a number between {min} and {max}.", + "search_limit": "Search limit", + "search_limit_error": "Enter a number between {min} and {max}.", + "search_limit_warning": "Too large values can freeze the app.", "cancel": "Cancel", "save": "Save", "input_error": "Valid number is required" diff --git a/src/localization/es.json b/src/localization/es.json index c9647431..7d32adac 100644 --- a/src/localization/es.json +++ b/src/localization/es.json @@ -382,7 +382,6 @@ "sort_instance_users_by": "Ordenar Usuarios de Instancia por", "sort_instance_users_by_time": "tiempo", "sort_instance_users_by_alphabet": "alfabético", - "table_max_size": "Tamaño Máximo de Tabla", "page_size": "Tamaño de Página:" }, "timedate": { @@ -1798,7 +1797,8 @@ }, "change_table_size": { "header": "Tamaño Máximo de Tabla", - "description": "Limitar la cantidad de entradas cargadas desde la base de datos a las páginas de la interfaz de usuario, tamaños de tabla más grandes impactarán el uso de RAM y el rendimiento (predeterminado: 1000, máximo: 10000)", + "description": "Limitar la cantidad de entradas cargadas desde la base de datos a las páginas de la interfaz de usuario, tamaños de tabla más grandes impactarán el uso de RAM y el rendimiento", + "table_max_size": "Tamaño Máximo de Tabla", "cancel": "Cancelar", "save": "Guardar", "input_error": "Se requiere un número válido" diff --git a/src/localization/fr.json b/src/localization/fr.json index d913f46e..84cdf8dc 100644 --- a/src/localization/fr.json +++ b/src/localization/fr.json @@ -354,7 +354,6 @@ "sort_instance_users_by": "Trier les utilisateurs dans les instances par", "sort_instance_users_by_time": "temps", "sort_instance_users_by_alphabet": "alphabétique", - "table_max_size": "Taille maximale du tableau", "page_size": "Longueur d'une page :" }, "timedate": { @@ -1687,7 +1686,8 @@ }, "change_table_size": { "header": "Taille maximale du tableau", - "description": "Limite le nombre d'entrées chargées depuis la base de données. Des tableaux plus grands auront un impact sur l'utilisation de la RAM et sur les performances (par défaut : 1000, max : 10000).", + "description": "Limite le nombre d'entrées chargées depuis la base de données. Des tableaux plus grands auront un impact sur l'utilisation de la RAM et sur les performances.", + "table_max_size": "Taille maximale du tableau", "cancel": "Annuler", "save": "Sauvegarder", "input_error": "Un numéro valide est nécessaire" diff --git a/src/localization/hu.json b/src/localization/hu.json index 89794b69..a4495c25 100644 --- a/src/localization/hu.json +++ b/src/localization/hu.json @@ -275,7 +275,6 @@ "sort_instance_users_by": "Sort Instance Users by", "sort_instance_users_by_time": "idő", "sort_instance_users_by_alphabet": "betűrend", - "table_max_size": "Maximális táblázatméret", "page_size": "Lapméret:" }, "timedate": { @@ -1559,7 +1558,8 @@ }, "change_table_size": { "header": "Max Table Size", - "description": "Limit amount of entries loaded from database to UI pages, larger table sizes will impact RAM usage and performance (default: 1000, max: 10000)", + "description": "Limit amount of entries loaded from database to UI pages, larger table sizes will impact RAM usage and performance", + "table_max_size": "Maximális táblázatméret", "cancel": "Mégse", "save": "Save", "input_error": "Valid number is required" diff --git a/src/localization/ja.json b/src/localization/ja.json index 629213df..e83fb9c0 100644 --- a/src/localization/ja.json +++ b/src/localization/ja.json @@ -617,9 +617,6 @@ "sort_instance_users_by": "インスタンス人数を並び替え:", "sort_instance_users_by_time": "時間順", "sort_instance_users_by_alphabet": "アルファベット順", - "table_max_size": "読み込むエントリの最大数", - "table_page_sizes": "テーブルのページごとの表示件数:", - "table_page_sizes_error": "ページサイズは1から1000の間の数字にしてください。", "show_notification_icon_dot": "トレイ通知ドットを表示", "striped_data_table_mode": "テーブルの行に交互に色を付ける", "toggle_pointer_on_hover": "ホバー時にポインターを切り替え", @@ -2319,7 +2316,10 @@ }, "change_table_size": { "header": "テーブルの最大数", - "description": "データベースからUIページに読み込まれるエントリの量を制限します。テーブル数が多いとRAM使用量とパフォーマンスに影響を及ぼす可能性があります。 (デフォルト:1000, 最高値: 10000)", + "description": "データベースからUIページに読み込まれるエントリの量を制限します。テーブル数が多いとRAM使用量とパフォーマンスに影響を及ぼす可能性があります。", + "table_max_size": "読み込むエントリの最大数", + "table_page_sizes": "テーブルのページごとの表示件数:", + "table_page_sizes_error": "ページサイズは1から1000の間の数字にしてください。", "cancel": "キャンセル", "save": "保存", "input_error": "有効な数字を入力してください。" diff --git a/src/localization/ko.json b/src/localization/ko.json index a19f9749..d9d6b087 100644 --- a/src/localization/ko.json +++ b/src/localization/ko.json @@ -289,7 +289,6 @@ "sort_instance_users_by": "인스턴스 유저 순서", "sort_instance_users_by_time": "시간순", "sort_instance_users_by_alphabet": "이름순", - "table_max_size": "최대 테이블 크기", "page_size": "페이지 당 건수:" }, "timedate": { @@ -1573,7 +1572,8 @@ }, "change_table_size": { "header": "최대 테이블 크기", - "description": "테이블이 커질수록 메모리 사용량과 성능에 영향을 줍니다 (기본: 1000)", + "description": "테이블이 커질수록 메모리 사용량과 성능에 영향을 줍니다", + "table_max_size": "최대 테이블 크기", "cancel": "취소", "save": "저장", "input_error": "숫자만 입력 가능" diff --git a/src/localization/pl.json b/src/localization/pl.json index af01425c..6d25c798 100644 --- a/src/localization/pl.json +++ b/src/localization/pl.json @@ -534,7 +534,6 @@ "sort_instance_users_by": "Sortuj użytkowników instancji wg", "sort_instance_users_by_time": "czas", "sort_instance_users_by_alphabet": "alfabetycznie", - "table_max_size": "Maks. wyników w tabeli", "show_notification_icon_dot": "Pokaż kropkę powiadomień w zasobniku" }, "timedate": { @@ -2114,7 +2113,8 @@ }, "change_table_size": { "header": "Maksymalny rozmiar tabeli", - "description": "Ogranicz liczbę wpisów wyświetlanych z bazy danych, większe tabele wpłyną na zużycie RAM (domyślnie: 1000, maks.: 10000)", + "description": "Ogranicz liczbę wpisów wyświetlanych z bazy danych, większe tabele wpłyną na zużycie RAM", + "table_max_size": "Maks. wyników w tabeli", "cancel": "Anuluj", "save": "Zapisz", "input_error": "Wymagana jest prawidłowa liczba" @@ -2388,4 +2388,4 @@ } } } -} \ No newline at end of file +} diff --git a/src/localization/pt.json b/src/localization/pt.json index e91c5686..fa83d873 100644 --- a/src/localization/pt.json +++ b/src/localization/pt.json @@ -275,7 +275,6 @@ "sort_instance_users_by": "Ordenar Instâncias de Usuários por", "sort_instance_users_by_time": "tempo", "sort_instance_users_by_alphabet": "alfabético", - "table_max_size": "Tamanho Máximo da Tabela", "page_size": "Tamanho da Página:" }, "timedate": { @@ -1559,7 +1558,8 @@ }, "change_table_size": { "header": "Max Table Size", - "description": "Limitar quantidade de entradas carregadas do banco de dados para páginas da interface, tamanhos maiores de tabela terão impacto no uso e desempenho da memória RAM (padrão: 1000, max: 10000)", + "description": "Limitar quantidade de entradas carregadas do banco de dados para páginas da interface, tamanhos maiores de tabela terão impacto no uso e desempenho da memória RAM", + "table_max_size": "Tamanho Máximo da Tabela", "cancel": "Cancelar", "save": "Salvar", "input_error": "Validação do número é obrigatório" diff --git a/src/localization/ru.json b/src/localization/ru.json index 025f6de7..a7155ef5 100644 --- a/src/localization/ru.json +++ b/src/localization/ru.json @@ -431,7 +431,6 @@ "sort_instance_users_by": "Сортировать игроков по", "sort_instance_users_by_time": "времени", "sort_instance_users_by_alphabet": "алфавиту", - "table_max_size": "Максимальный размер таблицы", "page_size": "Размер страницы:" }, "timedate": { @@ -1958,7 +1957,8 @@ }, "change_table_size": { "header": "Максимальный размер таблицы", - "description": "Ограничение количества записей, загружаемых из базы данных в пользовательский интерфейс. Большие размеры таблиц повлияют на использование и производительность ОЗУ (по умолчанию: 1000, макс: 10000)", + "description": "Ограничение количества записей, загружаемых из базы данных в пользовательский интерфейс. Большие размеры таблиц повлияют на использование и производительность ОЗУ", + "table_max_size": "Максимальный размер таблицы", "cancel": "Отмена", "save": "Сохранить", "input_error": "Требуется корректное число" diff --git a/src/localization/th.json b/src/localization/th.json index bc1eec02..ccd2426c 100644 --- a/src/localization/th.json +++ b/src/localization/th.json @@ -387,7 +387,6 @@ "sort_instance_users_by": "เรียงผู้ใช้ในอินสแตนซ์ตาม", "sort_instance_users_by_time": "เวลา", "sort_instance_users_by_alphabet": "ตัวอักษร", - "table_max_size": "ขนาดตารางสูงสุด", "page_size": "ขนาดหน้า:" }, "timedate": { @@ -1862,7 +1861,8 @@ }, "change_table_size": { "header": "ขนาดตารางสูงสุด", - "description": "จำกัดจำนวนรายการที่โหลดจากฐานข้อมูลไปยังหน้า UI, ขนาดตารางที่ใหญ่ขึ้นจะส่งผลต่อการใช้ RAM และประสิทธิภาพ (ค่าเริ่มต้น: 1000, สูงสุด: 10000)", + "description": "จำกัดจำนวนรายการที่โหลดจากฐานข้อมูลไปยังหน้า UI, ขนาดตารางที่ใหญ่ขึ้นจะส่งผลต่อการใช้ RAM และประสิทธิภาพ", + "table_max_size": "ขนาดตารางสูงสุด", "cancel": "ยกเลิก", "save": "บันทึก", "input_error": "ต้องระบุตัวเลขที่ถูกต้อง" diff --git a/src/localization/vi.json b/src/localization/vi.json index 9c716057..caf5be62 100644 --- a/src/localization/vi.json +++ b/src/localization/vi.json @@ -275,7 +275,6 @@ "sort_instance_users_by": "Sắp xếp người dùng trong world instance theo", "sort_instance_users_by_time": "Thời gian", "sort_instance_users_by_alphabet": "Bảng chữ cái", - "table_max_size": "Kích thước bảng tối đa", "page_size": "Kích thước trang" }, "timedate": { @@ -1559,7 +1558,8 @@ }, "change_table_size": { "header": "Kích thước bảng tối đa", - "description": "Giới hạn số lượng thông tin trên bảng UI, bảng lớn sẽ sử dụng RAM và hiệu năng nhiều hơn (mặc định: 1000, tối đa: 10000)", + "description": "Giới hạn số lượng thông tin trên bảng UI, bảng lớn sẽ sử dụng RAM và hiệu năng nhiều hơn", + "table_max_size": "Kích thước bảng tối đa", "cancel": "Hủy", "save": "Lưu", "input_error": "Yêu cầu số hợp lệ" diff --git a/src/localization/zh-CN.json b/src/localization/zh-CN.json index acb809dc..99a821f2 100644 --- a/src/localization/zh-CN.json +++ b/src/localization/zh-CN.json @@ -612,9 +612,6 @@ "sort_instance_users_by": "房间玩家排序规则", "sort_instance_users_by_time": "时间", "sort_instance_users_by_alphabet": "字母顺序", - "table_max_size": "最大显示行数", - "table_page_sizes": "每页显示行数", - "table_page_sizes_error": "行数必须是 1 到 1000 之间的数字", "show_notification_icon_dot": "显示托盘通知", "striped_data_table_mode": "斑马纹表格模式", "toggle_pointer_on_hover": "悬停时强制显示指针", @@ -2307,7 +2304,10 @@ }, "change_table_size": { "header": "最大读取记录数", - "description": "限制从数据库读取记录到界面接口的数量,较大的数据表大小可能会影响内存用量和程序性能(默认值:1000)", + "description": "限制从数据库读取记录到界面接口的数量,较大的数据表大小可能会影响内存用量和程序性能", + "table_max_size": "最大显示行数", + "table_page_sizes": "每页显示行数", + "table_page_sizes_error": "行数必须是 1 到 1000 之间的数字", "cancel": "取消", "save": "保存", "input_error": "请输入有效的数量" diff --git a/src/localization/zh-TW.json b/src/localization/zh-TW.json index 7048f157..f19c1934 100644 --- a/src/localization/zh-TW.json +++ b/src/localization/zh-TW.json @@ -570,9 +570,6 @@ "sort_instance_users_by": "房間用戶排序依據", "sort_instance_users_by_time": "時間", "sort_instance_users_by_alphabet": "字母順序", - "table_max_size": "表格大小", - "table_page_sizes": "表格每頁筆數", - "table_page_sizes_error": "每頁筆數必須是 1 到 1000 之間的數字", "show_notification_icon_dot": "顯示通知圖示提示點" }, "timedate": { @@ -2163,7 +2160,10 @@ }, "change_table_size": { "header": "最大表格大小", - "description": "限制從資料庫讀取紀錄到介面的數量,較大的資料表大小可能會影響記憶體用量和效能 (預設:1000)", + "description": "限制從資料庫讀取紀錄到介面的數量,較大的資料表大小可能會影響記憶體用量和效能", + "table_max_size": "表格大小", + "table_page_sizes": "表格每頁筆數", + "table_page_sizes_error": "每頁筆數必須是 1 到 1000 之間的數字", "cancel": "取消", "save": "儲存", "input_error": "請輸入有效的行數" diff --git a/src/service/database.js b/src/service/database.js index 9c8cda3f..0d7cd815 100644 --- a/src/service/database.js +++ b/src/service/database.js @@ -17,7 +17,8 @@ import sqliteService from './sqlite.js'; const dbVars = { userId: '', userPrefix: '', - maxTableSize: 1000 + maxTableSize: 500, + searchTableSize: 5000 }; const database = { @@ -39,6 +40,10 @@ const database = { dbVars.maxTableSize = limit; }, + setSearchTableSize(limit) { + dbVars.searchTableSize = limit; + }, + async initUserTables(userId) { dbVars.userId = userId; dbVars.userPrefix = userId.replaceAll('-', '').replaceAll('_', ''); diff --git a/src/service/database/feed.js b/src/service/database/feed.js index 6716f43f..870e2b92 100644 --- a/src/service/database/feed.js +++ b/src/service/database/feed.js @@ -87,7 +87,7 @@ const feed = { search, filters, vipList, - maxEntries = dbVars.maxTableSize + maxEntries = dbVars.searchTableSize ) { if (search.startsWith('wrld_') || search.startsWith('grp_')) { return this.getFeedByInstanceId(search, filters, vipList); @@ -488,7 +488,7 @@ const feed = { groupName: dbRow[8] }; feedDatabase.push(row); - }, `SELECT * FROM ${dbVars.userPrefix}_feed_gps WHERE location LIKE '%${instanceId}%' ${vipQuery} ORDER BY id DESC LIMIT ${dbVars.maxTableSize}`); + }, `SELECT * FROM ${dbVars.userPrefix}_feed_gps WHERE location LIKE '%${instanceId}%' ${vipQuery} ORDER BY id DESC LIMIT ${dbVars.searchTableSize}`); } if (online || offline) { let query = ''; @@ -512,7 +512,7 @@ const feed = { groupName: dbRow[8] }; feedDatabase.push(row); - }, `SELECT * FROM ${dbVars.userPrefix}_feed_online_offline WHERE (location LIKE '%${instanceId}%' ${query}) ${vipQuery} ORDER BY id DESC LIMIT ${dbVars.maxTableSize}`); + }, `SELECT * FROM ${dbVars.userPrefix}_feed_online_offline WHERE (location LIKE '%${instanceId}%' ${query}) ${vipQuery} ORDER BY id DESC LIMIT ${dbVars.searchTableSize}`); } const compareByCreatedAt = function (a, b) { const A = a.created_at; @@ -526,8 +526,11 @@ const feed = { return 0; }; feedDatabase.sort(compareByCreatedAt); - if (feedDatabase.length > dbVars.maxTableSize) { - feedDatabase.splice(0, feedDatabase.length - dbVars.maxTableSize); + if (feedDatabase.length > dbVars.searchTableSize) { + feedDatabase.splice( + 0, + feedDatabase.length - dbVars.searchTableSize + ); } return feedDatabase; } diff --git a/src/service/database/gameLog.js b/src/service/database/gameLog.js index 962bbe68..379b2e80 100644 --- a/src/service/database/gameLog.js +++ b/src/service/database/gameLog.js @@ -572,7 +572,7 @@ const gameLog = { groupName: dbRow[6] }; gamelogDatabase.push(row); - }, `SELECT * FROM gamelog_location WHERE location LIKE '%${instanceId}%' ORDER BY id DESC LIMIT ${dbVars.maxTableSize}`); + }, `SELECT * FROM gamelog_location WHERE location LIKE '%${instanceId}%' ORDER BY id DESC LIMIT ${dbVars.searchTableSize}`); } if (onplayerjoined || onplayerleft) { var query = ''; @@ -594,7 +594,7 @@ const gameLog = { time: dbRow[6] }; gamelogDatabase.push(row); - }, `SELECT * FROM gamelog_join_leave WHERE (location LIKE '%${instanceId}%' AND user_id != '${dbVars.userId}') ${query} ORDER BY id DESC LIMIT ${dbVars.maxTableSize}`); + }, `SELECT * FROM gamelog_join_leave WHERE (location LIKE '%${instanceId}%' AND user_id != '${dbVars.userId}') ${query} ORDER BY id DESC LIMIT ${dbVars.searchTableSize}`); } if (portalspawn) { await sqliteService.execute((dbRow) => { @@ -609,7 +609,7 @@ const gameLog = { worldName: dbRow[6] }; gamelogDatabase.push(row); - }, `SELECT * FROM gamelog_portal_spawn WHERE location LIKE '%${instanceId}%' ORDER BY id DESC LIMIT ${dbVars.maxTableSize}`); + }, `SELECT * FROM gamelog_portal_spawn WHERE location LIKE '%${instanceId}%' ORDER BY id DESC LIMIT ${dbVars.searchTableSize}`); } if (videoplay) { await sqliteService.execute((dbRow) => { @@ -625,7 +625,7 @@ const gameLog = { userId: dbRow[7] }; gamelogDatabase.push(row); - }, `SELECT * FROM gamelog_video_play WHERE location LIKE '%${instanceId}%' ORDER BY id DESC LIMIT ${dbVars.maxTableSize}`); + }, `SELECT * FROM gamelog_video_play WHERE location LIKE '%${instanceId}%' ORDER BY id DESC LIMIT ${dbVars.searchTableSize}`); } if (resourceload_string || resourceload_image) { var checkString = ''; @@ -645,7 +645,7 @@ const gameLog = { location: dbRow[4] }; gamelogDatabase.push(row); - }, `SELECT * FROM gamelog_resource_load WHERE location LIKE '%${instanceId}%' ${checkString} ${checkImage} ORDER BY id DESC LIMIT ${dbVars.maxTableSize}`); + }, `SELECT * FROM gamelog_resource_load WHERE location LIKE '%${instanceId}%' ${checkString} ${checkImage} ORDER BY id DESC LIMIT ${dbVars.searchTableSize}`); } var compareByCreatedAt = function (a, b) { var A = a.created_at; @@ -659,7 +659,10 @@ const gameLog = { return 0; }; gamelogDatabase.sort(compareByCreatedAt); - gamelogDatabase.splice(0, gamelogDatabase.length - dbVars.maxTableSize); + gamelogDatabase.splice( + 0, + gamelogDatabase.length - dbVars.searchTableSize + ); return gamelogDatabase; }, @@ -882,7 +885,7 @@ const gameLog = { search, filters, vipList, - maxEntries = dbVars.maxTableSize + maxEntries = dbVars.searchTableSize ) { if (search.startsWith('wrld_') || search.startsWith('grp_')) { return this.getGameLogByLocation(search, filters); diff --git a/src/shared/constants/settings.js b/src/shared/constants/settings.js index 3c2cbf97..b84bbf5a 100644 --- a/src/shared/constants/settings.js +++ b/src/shared/constants/settings.js @@ -32,4 +32,23 @@ const branches = { // } }; -export { VRChatScreenshotResolutions, VRChatCameraResolutions, branches }; +const TABLE_MAX_SIZE_MIN = 100; +const TABLE_MAX_SIZE_MAX = 10000; +const SEARCH_LIMIT_MIN = 1000; +const SEARCH_LIMIT_MAX = 100000; +const DEFAULT_MAX_TABLE_SIZE = 500; +const DEFAULT_SEARCH_LIMIT = 10000; +const LEGACY_MAX_TABLE_SIZE_DEFAULT = 1000; + +export { + VRChatScreenshotResolutions, + VRChatCameraResolutions, + branches, + TABLE_MAX_SIZE_MIN, + TABLE_MAX_SIZE_MAX, + SEARCH_LIMIT_MIN, + SEARCH_LIMIT_MAX, + DEFAULT_MAX_TABLE_SIZE, + DEFAULT_SEARCH_LIMIT, + LEGACY_MAX_TABLE_SIZE_DEFAULT +}; diff --git a/src/stores/feed.js b/src/stores/feed.js index 7a7d210f..7372b067 100644 --- a/src/stores/feed.js +++ b/src/stores/feed.js @@ -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, diff --git a/src/stores/gameLog.js b/src/stores/gameLog.js index 01999ed7..b727cc41 100644 --- a/src/stores/gameLog.js +++ b/src/stores/gameLog.js @@ -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( diff --git a/src/stores/settings/appearance.js b/src/stores/settings/appearance.js index bb4df98a..89e872ca 100644 --- a/src/stores/settings/appearance.js +++ b/src/stores/settings/appearance.js @@ -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, diff --git a/src/stores/vrcx.js b/src/stores/vrcx.js index 5111f828..f6306a5f 100644 --- a/src/stores/vrcx.js +++ b/src/stores/vrcx.js @@ -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, diff --git a/src/views/FriendList/FriendList.vue b/src/views/FriendList/FriendList.vue index 712f6b7e..cb0a5a16 100644 --- a/src/views/FriendList/FriendList.vue +++ b/src/views/FriendList/FriendList.vue @@ -208,7 +208,7 @@ const totalItems = computed(() => { const length = table.getFilteredRowModel().rows.length; const max = vrcxStore.maxTableSize; - return length > max && length < max + 51 ? max : length; + return length > max ? max : length; }); const handlePageSizeChange = (size) => { diff --git a/src/views/FriendLog/FriendLog.vue b/src/views/FriendLog/FriendLog.vue index 0ae4aa96..4ae0776b 100644 --- a/src/views/FriendLog/FriendLog.vue +++ b/src/views/FriendLog/FriendLog.vue @@ -189,8 +189,7 @@ const totalItems = computed(() => { const length = table.getFilteredRowModel().rows.length; - const max = vrcxStore.maxTableSize; - return length > max && length < max + 51 ? max : length; + return length; }); const handlePageSizeChange = (size) => { diff --git a/src/views/Settings/components/Tabs/AppearanceTab.vue b/src/views/Settings/components/Tabs/AppearanceTab.vue index 6789bb88..24f59bc4 100644 --- a/src/views/Settings/components/Tabs/AppearanceTab.vue +++ b/src/views/Settings/components/Tabs/AppearanceTab.vue @@ -190,11 +190,12 @@
+