Fix performance of WI editor when adding a new entry

This commit is contained in:
Cohee 2024-06-27 10:04:49 +00:00
parent 4e083ebd4f
commit 79b8dc98eb
1 changed files with 9 additions and 9 deletions

View File

@ -1756,14 +1756,21 @@ function displayWorldEntries(name, data, navigation = navigation_option.none, fl
return entriesArray;
}
const storageKey = 'WI_PerPage';
const perPageDefault = 25;
let startPage = 1;
if (navigation === navigation_option.previous) {
startPage = $('#world_info_pagination').pagination('getCurrentPageNum');
}
const storageKey = 'WI_PerPage';
const perPageDefault = 25;
if (typeof navigation === 'number' && Number(navigation) >= 0) {
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({
dataSource: getDataArray,
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) {
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(() => {
const element = $(selector);