(fallbackSnippet?: SnippetsResponse[0])
| 524 | } |
| 525 | |
| 526 | async function deleteSelectedSnippets(fallbackSnippet?: SnippetsResponse[0]) { |
| 527 | const { confirm } = useDialog() |
| 528 | const targetIds = getActionTargetIds(fallbackSnippet?.id) |
| 529 | |
| 530 | if (!targetIds.length) { |
| 531 | return |
| 532 | } |
| 533 | |
| 534 | const targetSnippets = getActionTargetSnippets(targetIds, fallbackSnippet) |
| 535 | |
| 536 | if (targetIds.length > 1) { |
| 537 | const isAllSoftDeleted |
| 538 | = targetSnippets.length === targetIds.length |
| 539 | && targetSnippets.every(snippet => snippet.isDeleted) |
| 540 | |
| 541 | if (isAllSoftDeleted) { |
| 542 | const isConfirmed = await confirm({ |
| 543 | title: i18n.t('messages:confirm.deleteConfirmMultipleSnippets', { |
| 544 | count: targetIds.length, |
| 545 | }), |
| 546 | content: i18n.t('messages:warning.noUndo'), |
| 547 | }) |
| 548 | |
| 549 | if (isConfirmed) { |
| 550 | await deleteSnippets(targetIds) |
| 551 | selectFirstSnippet() |
| 552 | } |
| 553 | } |
| 554 | else { |
| 555 | const snippetsData = targetIds.map(() => ({ |
| 556 | folderId: null, |
| 557 | isDeleted: 1, |
| 558 | })) |
| 559 | |
| 560 | await updateSnippets(targetIds, snippetsData) |
| 561 | selectFirstSnippet() |
| 562 | } |
| 563 | |
| 564 | return |
| 565 | } |
| 566 | |
| 567 | const targetSnippet = targetSnippets[0] |
| 568 | |
| 569 | if (!targetSnippet) { |
| 570 | return |
| 571 | } |
| 572 | |
| 573 | if (!targetSnippet.isDeleted) { |
| 574 | await updateSnippet(targetSnippet.id, { |
| 575 | folderId: null, |
| 576 | isDeleted: 1, |
| 577 | }) |
| 578 | |
| 579 | if (state.snippetId === targetSnippet.id) { |
| 580 | selectFirstSnippet() |
| 581 | } |
| 582 | |
| 583 | return |
nothing calls this directly
no test coverage detected