mirror of
https://github.com/ankitects/anki.git
synced 2025-09-25 09:16:38 -04:00
Move the solution to the Rust layer
This commit is contained in:
parent
83d0f5dae9
commit
01e22a2794
2 changed files with 17 additions and 7 deletions
|
@ -35,9 +35,8 @@ def reparent_decks(
|
|||
return CollectionOp(
|
||||
parent, lambda col: col.decks.reparent(deck_ids=deck_ids, new_parent=new_parent)
|
||||
).success(
|
||||
lambda out: tooltip(
|
||||
tr.browsing_reparented_decks(count=out.count), parent=parent
|
||||
)
|
||||
lambda out: out.count > 0
|
||||
and tooltip(tr.browsing_reparented_decks(count=out.count), parent=parent)
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -20,22 +20,33 @@ impl Collection {
|
|||
new_parent: Option<DeckId>,
|
||||
) -> Result<usize> {
|
||||
let usn = self.usn()?;
|
||||
let target_deck;
|
||||
let mut target_deck = None;
|
||||
let mut target_name = None;
|
||||
if let Some(target) = new_parent {
|
||||
if let Some(target) = self.storage.get_deck(target)? {
|
||||
if target.is_filtered() {
|
||||
return Err(FilteredDeckError::MustBeLeafNode.into());
|
||||
}
|
||||
target_deck = target;
|
||||
target_name = Some(&target_deck.name);
|
||||
target_deck = Some(target);
|
||||
target_name = Some(target_deck.as_ref().unwrap().name.clone());
|
||||
}
|
||||
}
|
||||
|
||||
let mut count = 0;
|
||||
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 let Some(new_name) = deck.name.reparented_name(target_name.as_ref()) {
|
||||
|
||||
let parent_decks = self.storage.parent_decks(&deck).unwrap();
|
||||
match target_deck {
|
||||
Some(ref target) => if parent_decks.contains(&target) {
|
||||
continue;
|
||||
}
|
||||
None => if parent_decks.is_empty() {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
count += 1;
|
||||
let orig = deck.clone();
|
||||
|
||||
|
|
Loading…
Reference in a new issue