Refactor bookmarks with correct async and export
| @@ -6,7 +6,6 @@ import { | ||
| 6 | 6 | this_chid, |
| 7 | 7 | openCharacterChat, |
| 8 | 8 | chat_metadata, |
| 9 | - callPopup, | |
| 10 | 9 | getRequestHeaders, |
| 11 | 10 | getThumbnailUrl, |
| 12 | 11 | getCharacters, |
| @@ -29,15 +28,9 @@ import { Popup } from './popup.js'; | ||
| 29 | 28 | import { createTagMapFromList } from './tags.js'; |
| 30 | 29 | |
| 31 | 30 | import { |
| 32 | - delay, | |
| 33 | 31 | getUniqueName, |
| 34 | 32 | } from './utils.js'; |
| 35 | 33 | |
| 36 | -export { | |
| 37 | - createNewBookmark, | |
| 38 | - showBookmarksButtons, | |
| 39 | -}; | |
| 40 | - | |
| 41 | 34 | const bookmarkNameToken = 'Checkpoint #'; |
| 42 | 35 | |
| 43 | 36 | async function getExistingChatNames() { |
| @@ -95,7 +88,7 @@ function getMainChatName() { | ||
| 95 | 88 | return null; |
| 96 | 89 | } |
| 97 | 90 | |
| 98 | 91 | export function showBookmarksButtons() { |
| 99 | 92 | try { |
| 100 | 93 | if (selected_group) { |
| 101 | 94 | $('#option_convert_to_group').hide(); |
| @@ -130,10 +123,10 @@ async function saveBookmarkMenu() { | ||
| 130 | 123 | return; |
| 131 | 124 | } |
| 132 | 125 | |
| 133 | 126 | return await createNewBookmark(chat.length - 1); |
| 134 | 127 | } |
| 135 | 128 | |
| 136 | 129 | export async function createBranch(mesId) { |
| 137 | 130 | if (!chat.length) { |
| 138 | 131 | toastr.warning('The chat is empty.', 'Branch creation failed'); |
| 139 | 132 | return; |
| @@ -166,7 +159,7 @@ export async function createBranch(mesId) { | ||
| 166 | 159 | return name; |
| 167 | 160 | } |
| 168 | 161 | |
| 169 | 162 | export async function createNewBookmark(mesId) { |
| 170 | 163 | if (this_chid === undefined && !selected_group) { |
| 171 | 164 | toastr.info('No character selected.', 'Checkpoint creation aborted'); |
| 172 | 165 | return; |
| @@ -243,7 +236,7 @@ async function backToMainChat() { | ||
| 243 | 236 | } |
| 244 | 237 | } |
| 245 | 238 | |
| 246 | 239 | export async function convertSoloToGroupChat() { |
| 247 | 240 | if (selected_group) { |
| 248 | 241 | console.log('Already in group. No need for conversion'); |
| 249 | 242 | return; |
| @@ -270,6 +263,7 @@ async function convertSoloToGroupChat() { | ||
| 270 | 263 | const activationStrategy = group_activation_strategy.NATURAL; |
| 271 | 264 | const allowSelfResponses = false; |
| 272 | 265 | const favChecked = character.fav || character.fav == 'true'; |
| 266 | + /** @type {any} */ | |
| 273 | 267 | const metadata = Object.assign({}, chat_metadata); |
| 274 | 268 | delete metadata.main_chat; |
| 275 | 269 | |
| @@ -365,7 +359,7 @@ async function convertSoloToGroupChat() { | ||
| 365 | 359 | * @param {number} mesId Message ID |
| 366 | 360 | * @returns {Promise<string>} Branch file name |
| 367 | 361 | */ |
| 368 | 362 | export async function branchChat(mesId) { |
| 369 | 363 | if (this_chid === undefined && !selected_group) { |
| 370 | 364 | toastr.info('No character selected.', 'Branch creation aborted'); |
| 371 | 365 | return; |
| @@ -392,7 +386,7 @@ jQuery(function () { | ||
| 392 | 386 | // If shift is held down, we are not following the bookmark, but creating a new one |
| 393 | 387 | if (e.shiftKey) { |
| 394 | 388 | var selectedMesId = $(this).closest('.mes').attr('mesid'); |
| 395 | 389 | await createNewBookmark(selectedMesId); |
| 396 | 390 | return; |
| 397 | 391 | } |
| 398 | 392 | |
| @@ -412,7 +406,7 @@ jQuery(function () { | ||
| 412 | 406 | await openCharacterChat(file_name); |
| 413 | 407 | } |
| 414 | 408 | } finally { |
| 415 | 409 | await hideLoader(); |
| 416 | 410 | } |
| 417 | 411 | |
| 418 | 412 | $('#shadow_select_chat_popup').css('display', 'none'); |
| @@ -422,14 +416,14 @@ jQuery(function () { | ||
| 422 | 416 | $(document).on('click', '.mes_create_bookmark', async function () { |
| 423 | 417 | var selected_mes_id = $(this).closest('.mes').attr('mesid'); |
| 424 | 418 | if (selected_mes_id !== undefined) { |
| 425 | 419 | await createNewBookmark(selected_mes_id); |
| 426 | 420 | } |
| 427 | 421 | }); |
| 428 | 422 | |
| 429 | 423 | $(document).on('click', '.mes_create_branch', async function () { |
| 430 | 424 | var selected_mes_id = $(this).closest('.mes').attr('mesid'); |
| 431 | 425 | if (selected_mes_id !== undefined) { |
| 432 | 426 | await branchChat(Number(selected_mes_id)); |
| 433 | 427 | } |
| 434 | 428 | }); |
| 435 | 429 | }); |