Merge pull request #2788 from SillyTavern/charlistgrid-load Less horrible charListGrid load
Signed| @@ -8879,9 +8879,8 @@ const isPwaMode = window.navigator.standalone; | |||
| 8879 | if (isPwaMode) { $('body').addClass('PWA'); } | 8879 | if (isPwaMode) { $('body').addClass('PWA'); } |
| 8880 | 8880 | ||
| 8881 | function doCharListDisplaySwitch() { | 8881 | function doCharListDisplaySwitch() { |
| 8882 | console.debug('toggling body charListGrid state'); | 8882 | power_user.charListGrid = !power_user.charListGrid; |
| 8883 | $('body').toggleClass('charListGrid'); | 8883 | document.body.classList.toggle('charListGrid', power_user.charListGrid); |
| 8884 | power_user.charListGrid = $('body').hasClass('charListGrid') ? true : false; | ||
| 8885 | saveSettingsDebounced(); | 8884 | saveSettingsDebounced(); |
| 8886 | } | 8885 | } |
| 8887 | 8886 | ||
| @@ -106,6 +106,7 @@ export const persona_description_positions = { | |||
| 106 | }; | 106 | }; |
| 107 | 107 | ||
| 108 | let power_user = { | 108 | let power_user = { |
| 109 | charListGrid: false, | ||
| 109 | tokenizer: tokenizers.BEST_MATCH, | 110 | tokenizer: tokenizers.BEST_MATCH, |
| 110 | token_padding: 64, | 111 | token_padding: 64, |
| 111 | collapse_newlines: false, | 112 | collapse_newlines: false, |
| @@ -1602,18 +1603,8 @@ async function loadPowerUserSettings(settings, data) { | |||
| 1602 | loadCharListState(); | 1603 | loadCharListState(); |
| 1603 | } | 1604 | } |
| 1604 | 1605 | ||
| 1605 | async function loadCharListState() { | 1606 | function loadCharListState() { |
| 1606 | if (document.querySelector('.character_select') !== null) { | 1607 | document.body.classList.toggle('charListGrid', power_user.charListGrid); |
| 1607 | console.debug('setting charlist state to...'); | ||
| 1608 | if (power_user.charListGrid === true) { | ||
| 1609 | console.debug('..to grid'); | ||
| 1610 | $('#charListGridToggle').trigger('click'); | ||
| 1611 | } else { console.debug('..to list'); } | ||
| 1612 | } else { | ||
| 1613 | console.debug('charlist not ready yet'); | ||
| 1614 | await delay(100); | ||
| 1615 | loadCharListState(); | ||
| 1616 | } | ||
| 1617 | } | 1608 | } |
| 1618 | 1609 | ||
| 1619 | function loadMovingUIState() { | 1610 | function loadMovingUIState() { |