mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
Fix superfluous message when a deck is dragged to its parent (#3859)
* Move the solution to the Rust layer
* CONTRIBUTORS fix (1)
* CONTRIBUTORS fix (2)
* Fix CI issues
* Simplify reparenting solution
* Fix reparenting message with tags
* Revert "Fix reparenting message with tags"
This reverts commit 199958c1c5
.
* tags: Return None in reparented_name when the name is unchanged
This commit is contained in:
parent
86ed715458
commit
52781aaab8
2 changed files with 15 additions and 2 deletions
|
@ -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();
|
||||
|
||||
|
|
|
@ -109,11 +109,21 @@ fn reparented_name(existing_name: &str, new_parent: Option<&str>) -> Option<Stri
|
|||
None
|
||||
} else {
|
||||
// foo::bar onto baz -> baz::bar
|
||||
Some(format!("{}::{}", new_parent, existing_base))
|
||||
let new_name = format!("{}::{}", new_parent, existing_base);
|
||||
if new_name != existing_name {
|
||||
Some(new_name)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// foo::bar onto top level -> bar
|
||||
Some(existing_base.into())
|
||||
let new_name = existing_base.into();
|
||||
if new_name != existing_name {
|
||||
Some(new_name)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue