mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Fix performance of WI editor when adding a new entry
This commit is contained in:
@@ -1756,14 +1756,21 @@ function displayWorldEntries(name, data, navigation = navigation_option.none, fl
|
|||||||
return entriesArray;
|
return entriesArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const storageKey = 'WI_PerPage';
|
||||||
|
const perPageDefault = 25;
|
||||||
let startPage = 1;
|
let startPage = 1;
|
||||||
|
|
||||||
if (navigation === navigation_option.previous) {
|
if (navigation === navigation_option.previous) {
|
||||||
startPage = $('#world_info_pagination').pagination('getCurrentPageNum');
|
startPage = $('#world_info_pagination').pagination('getCurrentPageNum');
|
||||||
}
|
}
|
||||||
|
|
||||||
const storageKey = 'WI_PerPage';
|
if (typeof navigation === 'number' && Number(navigation) >= 0) {
|
||||||
const perPageDefault = 25;
|
const data = getDataArray();
|
||||||
|
const uidIndex = data.findIndex(x => x.uid === navigation);
|
||||||
|
const perPage = Number(localStorage.getItem(storageKey)) || perPageDefault;
|
||||||
|
startPage = Math.floor(uidIndex / perPage) + 1;
|
||||||
|
}
|
||||||
|
|
||||||
$('#world_info_pagination').pagination({
|
$('#world_info_pagination').pagination({
|
||||||
dataSource: getDataArray,
|
dataSource: getDataArray,
|
||||||
pageSize: Number(localStorage.getItem(storageKey)) || perPageDefault,
|
pageSize: Number(localStorage.getItem(storageKey)) || perPageDefault,
|
||||||
@@ -1824,15 +1831,8 @@ function displayWorldEntries(name, data, navigation = navigation_option.none, fl
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (typeof navigation === 'number' && Number(navigation) >= 0) {
|
if (typeof navigation === 'number' && Number(navigation) >= 0) {
|
||||||
const selector = `#world_popup_entries_list [uid="${navigation}"]`;
|
const selector = `#world_popup_entries_list [uid="${navigation}"]`;
|
||||||
const data = getDataArray();
|
|
||||||
const uidIndex = data.findIndex(x => x.uid === navigation);
|
|
||||||
const perPage = Number(localStorage.getItem(storageKey)) || perPageDefault;
|
|
||||||
const page = Math.floor(uidIndex / perPage) + 1;
|
|
||||||
$('#world_info_pagination').pagination('go', page);
|
|
||||||
waitUntilCondition(() => document.querySelector(selector) !== null).finally(() => {
|
waitUntilCondition(() => document.querySelector(selector) !== null).finally(() => {
|
||||||
const element = $(selector);
|
const element = $(selector);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user