mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-01-19 04:50:12 +01:00
Fix imported char flashing with pagination
This commit is contained in:
parent
2685bf95fe
commit
0d8a83e6b6
@ -320,6 +320,7 @@ let safetychat = [
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
let chatSaveTimeout;
|
let chatSaveTimeout;
|
||||||
|
let importFlashTimeout;
|
||||||
export let isChatSaving = false;
|
export let isChatSaving = false;
|
||||||
let chat_create_date = 0;
|
let chat_create_date = 0;
|
||||||
let firstRun = false;
|
let firstRun = false;
|
||||||
@ -5708,19 +5709,39 @@ function select_rm_info(type, charId, previousCharId = null) {
|
|||||||
|
|
||||||
selectRightMenuWithAnimation('rm_characters_block');
|
selectRightMenuWithAnimation('rm_characters_block');
|
||||||
|
|
||||||
setTimeout(function () {
|
// Set a timeout so multiple flashes don't overlap
|
||||||
|
clearTimeout(importFlashTimeout);
|
||||||
|
importFlashTimeout = setTimeout(function () {
|
||||||
if (type === 'char_import' || type === 'char_create') {
|
if (type === 'char_import' || type === 'char_create') {
|
||||||
const element = $(`#rm_characters_block [title="${charId}"]`).parent().get(0);
|
// Find the page at which the character is located
|
||||||
console.log(element);
|
const charData = getEntitiesList({ doFilter: true });
|
||||||
element.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
const charIndex = charData.findIndex((x) => x?.item?.avatar?.startsWith(charId));
|
||||||
|
|
||||||
|
if (charIndex === -1) {
|
||||||
|
console.log(`Could not find character ${charId} in the list`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (element !== undefined || element !== null) {
|
const perPage = Number(localStorage.getItem('Characters_PerPage'));
|
||||||
|
const page = Math.floor(charIndex / perPage) + 1;
|
||||||
|
const selector = `#rm_print_characters_block [title^="${charId}"]`;
|
||||||
|
$('#rm_print_characters_pagination').pagination('go', page);
|
||||||
|
|
||||||
|
waitUntilCondition(() => document.querySelector(selector) !== null).then(() => {
|
||||||
|
const element = $(selector).parent().get(0);
|
||||||
|
|
||||||
|
if (!element) {
|
||||||
|
console.log(`Could not find element for character ${charId}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
element.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
||||||
$(element).addClass('flash animated');
|
$(element).addClass('flash animated');
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
$(element).removeClass('flash animated');
|
$(element).removeClass('flash animated');
|
||||||
}, 5000);
|
}, 5000);
|
||||||
} else { console.log('didnt find the element'); }
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
}
|
}
|
||||||
@ -5741,7 +5762,7 @@ function select_rm_info(type, charId, previousCharId = null) {
|
|||||||
console.error(e);
|
console.error(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 100);
|
}, 250);
|
||||||
|
|
||||||
if (previousCharId) {
|
if (previousCharId) {
|
||||||
const newId = characters.findIndex((x) => x.avatar == previousCharId);
|
const newId = characters.findIndex((x) => x.avatar == previousCharId);
|
||||||
|
Loading…
Reference in New Issue
Block a user