Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve bookmark deletion patterns #3271

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open

Conversation

mallexxx
Copy link
Collaborator

Task/Issue URL: https://app.asana.com/0/1207340338530322/1205306631184883/f

Description:

  • Always display Delete button in Bookmark Manager (disable when no items highlighted)
  • Support item removal on Del press
  • Show ••• menu in Bookmarks Sidebar; For bookmark folders in Bookmark Manager

Steps to test this PR:

  1. Validate Delete button is always shown; disabled when no items selected; Removes all selected items
  2. Validate Forward Delete key deletes selected bookmarks
  3. Validate the ••• menu is displayed and works for the Sidebar folders as well as the Details view in Bookmarks Manager

Definition of Done:


Internal references:

Pull Request Review Checklist
Software Engineering Expectations
Technical Design Template
Pull Request Documentation

Copy link

Warnings
⚠️ PR has more than 500 lines of code changing. Consider splitting into smaller PRs if possible.

Generated by 🚫 dangerJS against 6264934

let favoritesFolders = BookmarkUtils.fetchFavoritesFolders(for: favoritesDisplayMode, in: context)
assert(bookmarkManagedObjects.count == objectMap.count)
bookmarkManagedObjects.forEach { managedObject in
managedObject.cancelDeletion()
Copy link
Collaborator

@ayoy ayoy Sep 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mallexxx this won't work with Sync.

A bookmark that's marked as pending deletion is synced immediately (sync is triggered after context save and Sync Scheduler doesn't introduce any delay at the moment, apart from debouncing by 1s). Upon receivng Sync response, the bookmark is deleted from the database.

As far as I remember, Sync doesn't allow for un-deleting an object, i.e. if a delete is sent to the backend, further updates will be ignored. Hence we can't just cancel deletion here.

iOS supports undo for individual bookmarks and it's done by re-creating a deleted bookmark (with a new UUID), see here: https://github.com/duckduckgo/iOS/blob/main/DuckDuckGo/BookmarksViewController.swift#L1077-L1114.

BookmarkEntity.cancelDeletion() is only used by Sync Engine and we should add documentation there stating that it should not be used elsewhere.

Essentially the requirement is that undo should re-create a bookmark with a new UUID, which you could perhaps do here as well. Just create new managed objects based on BaseBookmarkEntity objects. The problem is only that you'd have to cache deleted items' indexes in parent's children array somehow, to know where to put re-created bookmarks and folders.

Documentation on undo handling for Syncable entitles: https://app.asana.com/0/1201493110486074/1205142204227585/f

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants