(memory)
| 552 | }, |
| 553 | |
| 554 | async deleteMemory(memory) { |
| 555 | try { |
| 556 | // Check if this is the memory currently being viewed in detail modal |
| 557 | const isViewingThisMemory = |
| 558 | this.detailMemory && this.detailMemory.id === memory.id; |
| 559 | |
| 560 | const response = await API.callJsonApi(MEMORY_DASHBOARD_API, { |
| 561 | action: "delete", |
| 562 | memory_subdir: this.selectedMemorySubdir, |
| 563 | memory_id: memory.id, |
| 564 | }); |
| 565 | |
| 566 | if (response.success) { |
| 567 | justToast("Memory deleted successfully", "success"); |
| 568 | |
| 569 | // If we were viewing this memory in detail modal, close it |
| 570 | if (isViewingThisMemory) { |
| 571 | this.detailMemory = null; |
| 572 | closeModal(); // Close the detail modal |
| 573 | } |
| 574 | |
| 575 | // Let polling refresh the data instead of manual manipulation |
| 576 | // Trigger an immediate refresh to get updated state from backend |
| 577 | await this.searchMemories(true); // silent refresh |
| 578 | } else { |
| 579 | justToast(`Failed to delete memory: ${response.error}`, "error"); |
| 580 | } |
| 581 | } catch (error) { |
| 582 | console.error("Memory deletion error:", error); |
| 583 | justToast("Failed to delete memory", "error"); |
| 584 | } |
| 585 | }, |
| 586 | |
| 587 | exportMemories() { |
| 588 | if (this.memories.length === 0) { |
nothing calls this directly
no test coverage detected