Skip to content

feat(library): F9 — Trash (soft delete, restore, auto-purge) #2

@lalithaar

Description

@lalithaar

Overview

All item deletes become soft-deletes. A Trash collection appears in the sidebar. Items can be restored or permanently deleted. Trash older than 30 days is purged on app startup.

Scope

Rust (src-tauri/src/library.rs)

  • Add rash table: item_id INTEGER PRIMARY KEY, deleted_at INTEGER (created in init_db)
  • Change delete_library_item to soft-delete: INSERT into rash, keep row in items
  • Update get_library_items and search_library_items to exclude trashed items (WHERE i.id NOT IN (SELECT item_id FROM trash))
  • Add get_trash_items() -> Vec — returns trashed items with deleted_at attached (use �dded_at field or add a rashedAt field to LibraryItem)
  • Add
    estore_library_item(id) — DELETE from trash
  • Add purge_trash_item(id) — DELETE from items (cascades)
  • Add empty_trash() — DELETE all from items WHERE id IN trash
  • On app startup (init_db or a new startup_cleanup): DELETE from items WHERE id IN (SELECT item_id FROM trash WHERE deleted_at < now - 30days)

Frontend (src/composables/useLibrary.ts)

  • Add getTrashedItems(),
    estoreItem(id), purgeTrashItem(id), emptyTrash() functions

Frontend (src/components/CollectionsSidebar.vue)

  • Add a Trash row at the bottom of the sidebar (trash icon, item count)
  • Clicking Trash sets a showingTrash flag on the parent

Frontend (src/views/LibraryView.vue)

  • When showingTrash is true: show trashed items table with 'Deleted X ago' column, Restore and Delete Permanently buttons per row, and an 'Empty Trash' button in the toolbar
  • Delete button in normal view now calls soft-delete (no confirmation needed — item is recoverable)
  • Permanent delete in trash view shows a confirmation prompt

Verification

  • Delete an entry → it disappears from main list
  • Open Trash sidebar → see deleted entry with timestamp
  • Restore → entry reappears in main list
  • Empty Trash → all gone permanently
  • Restart app after seeding trash with items older than 30 days → they are auto-purged

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions