-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Fix superfluous message when a deck is dragged to its parent #3859
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
Fix superfluous message when a deck is dragged to its parent #3859
Conversation
The correct way to fix this would be to have reparent_decks() in the Rust layer not include such decks in the returned change count. |
3e1dfa2
to
fd3cbd2
Compare
fd3cbd2
to
01e22a2
Compare
Alright, I've implemented that solution. |
I'm afraid I think this is still needlessly complicated. I suspect all that is required is diff --git a/rslib/src/decks/reparent.rs b/rslib/src/decks/reparent.rs
index a9fcd318f..bfb3fee05 100644
--- a/rslib/src/decks/reparent.rs
+++ b/rslib/src/decks/reparent.rs
@@ -36,6 +36,9 @@ impl Collection {
for deck in deck_ids {
if let Some(mut deck) = self.storage.get_deck(*deck)? {
if let Some(new_name) = deck.name.reparented_name(target_name) {
+ if new_name == deck.name {
+ continue;
+ }
count += 1;
let orig = deck.clone(); Also, I'm not sure we should be hiding the message in that case. The user has performed an action - wouldn't it be better to show them '0 decks changed' (i.e. "I received your request, but it doesn't make sense"), rather than not showing anything, which leaves the user wondering whether Anki received the user's request or not. |
Tags probably need similar treatment as well. |
Yeah, I suppose that's fair. |
@dae I implemented your solution. What needs to be changed wrt tags? It seems that I can't reparent them in the first place. |
Thanks, looks good so far. Tags can be reparented in the same way is decks in the browser, by switching the sidebar to select mode, then dragging. |
…/anki into fix-duplicate-deck-drag-drop
Same concept implemented for tags now. |
Sorry to drag this out, but I think this could be done a bit more efficiently by adjusting reparented_name() to return None if the old and new names match. Then the map doesn't need to be iterated again, and the changes are minimized. |
Thanks, I didn't realize we were filtering out the |
Currently, decks can be drag-and-dropped to their parent, which does nothing (from the user's perspective), but claims to rename the deck. This fixes that behavior.