fix charlist state on character deletion

This commit is contained in:
RossAscends
2023-07-14 04:15:31 +09:00
parent 057ae5ce14
commit 4bf8e2c49f
2 changed files with 35 additions and 24 deletions

View File

@@ -916,6 +916,7 @@ async function printCharacters() {
sortCharactersList();
favsToHotswap();
await delay(300);
doCharListDisplaySwitch();
updateVisibleDivs('#rm_print_characters_block', true);
displayOverrideWarnings();
@@ -6797,6 +6798,35 @@ async function doImpersonate() {
const isPwaMode = window.navigator.standalone;
if (isPwaMode) { $("body").addClass('PWA') }
function doCharListDisplaySwitch(flipSwitch) {
if (!flipSwitch) {
console.debug('toggling body charListGrid state')
$("body").toggleClass('charListGrid')
power_user.charListGrid = $("body").hasClass("charListGrid") ? true : false;
saveSettingsDebounced()
}
//(wide100p alignitemsflexstart) removed, the rest added
if (power_user.charListGrid === true && $("body").hasClass('charListGrid')
|| power_user.charListGrid === false && !$("body").hasClass('charListGrid')) {
$("#rm_print_characters_block").toggleClass('flexFlowColumn flex-container')
$("#rm_print_characters_block .character_select").toggleClass('wide100p alignitemsflexstart heightMinContent flexFlowColumn wide30p overflowHidden wideMax100px')
$("#rm_print_characters_block .character_select .ch_name").toggleClass('wide100p wideMax100px')
$("#rm_print_characters_block .character_select .ch_name").parent().toggleClass('wide100p')
$("#rm_print_characters_block .character_select .ch_name").parent().parent().toggleClass('wide100pLess70px justifyCenter wideMax100px')
$("#rm_print_characters_block .group_select").toggleClass('wide100p alignitemsflexstart heightMinContent alignitemscenter flexFlowColumn wide30p overflowHidden wideMax100px')
$("#rm_print_characters_block .group_select .ch_name").toggleClass('wide100p wideMax100px')
$("#rm_print_characters_block .group_select .ch_name").parent().toggleClass('wide100pLess70px')
$(".character_select .ch_description").toggle()
$("#rm_print_characters_block .tags_inline").toggle()
select_rm_characters()
}
}
$(document).ready(function () {
if (isMobile() === true) {
@@ -8622,30 +8652,8 @@ $(document).ready(function () {
}
$("#charListGridToggle").on('click', async () => {
doCharListDisplaySwitch()
doCharListDisplaySwitch(true)
})
function doCharListDisplaySwitch() {
$("body").toggleClass('charListGrid')
//(wide100p alignitemsflexstart) removed, the rest added
$("#rm_print_characters_block").toggleClass('flexFlowColumn flex-container')
$("#rm_print_characters_block .character_select").toggleClass('wide100p alignitemsflexstart heightMinContent flexFlowColumn wide30p overflowHidden wideMax100px')
$("#rm_print_characters_block .character_select .ch_name").toggleClass('wide100p wideMax100px')
$("#rm_print_characters_block .character_select .ch_name").parent().toggleClass('wide100p')
$("#rm_print_characters_block .character_select .ch_name").parent().parent().toggleClass('wide100pLess70px justifyCenter wideMax100px')
$("#rm_print_characters_block .group_select").toggleClass('wide100p alignitemsflexstart heightMinContent alignitemscenter flexFlowColumn wide30p overflowHidden wideMax100px')
$("#rm_print_characters_block .group_select .ch_name").toggleClass('wide100p wideMax100px')
$("#rm_print_characters_block .group_select .ch_name").parent().toggleClass('wide100pLess70px')
$(".character_select .ch_description").toggle()
$("#rm_print_characters_block .tags_inline").toggle()
power_user.charListGrid = $("body").hasClass("charListGrid") ? true : false;
saveSettingsDebounced()
select_rm_characters()
}
})

View File

@@ -750,10 +750,13 @@ function loadPowerUserSettings(settings, data) {
async function loadCharListState() {
if (document.getElementById('CharID0') !== null) {
console.debug('setting charlist state to...')
if (power_user.charListGrid === true) {
console.debug('..to grid')
$("#charListGridToggle").trigger('click')
}
} else { console.debug('..to list') }
} else {
console.debug('charlist not ready yet')
await delay(100)
loadCharListState();
}