nest NoteWithEmptyCards

This commit is contained in:
Damien Elmes 2021-02-08 19:11:16 +10:00
parent aa82bb172d
commit b9635ce936
4 changed files with 13 additions and 13 deletions

View File

@ -47,7 +47,6 @@ SearchTerm = _pb.SearchTerm
Progress = _pb.Progress
Config = _pb.Config
EmptyCardsReport = _pb.EmptyCardsReport
NoteWithEmptyCards = _pb.NoteWithEmptyCards
GraphPreferences = _pb.GraphPreferences
BuiltinSort = _pb.SortOrder.Builtin
Preferences = _pb.Preferences

View File

@ -8,7 +8,7 @@ from concurrent.futures import Future
from typing import Any
import aqt
from anki.collection import EmptyCardsReport, NoteWithEmptyCards
from anki.collection import EmptyCardsReport
from aqt import gui_hooks
from aqt.qt import QDialog, QDialogButtonBox, qconnect
from aqt.utils import TR, disable_help_button, restoreGeom, saveGeom, tooltip, tr
@ -89,7 +89,7 @@ class EmptyCardsDialog(QDialog):
def _delete_cards(self, keep_notes: bool) -> int:
to_delete = []
note: NoteWithEmptyCards
note: EmptyCardsReport.NoteWithEmptyCards
for note in self.report.notes:
if keep_notes and note.will_delete_note:
# leave first card

View File

@ -912,16 +912,15 @@ message AddNoteIn {
}
message EmptyCardsReport {
message NoteWithEmptyCards {
int64 note_id = 1;
repeated int64 card_ids = 2;
bool will_delete_note = 3;
}
string report = 1;
repeated NoteWithEmptyCards notes = 2;
}
message NoteWithEmptyCards {
int64 note_id = 1;
repeated int64 card_ids = 2;
bool will_delete_note = 3;
}
message DeckNames {
repeated DeckNameID entries = 1;
}

View File

@ -438,10 +438,12 @@ impl BackendService for Backend {
let mut outnotes = vec![];
for (_ntid, notes) in empty {
outnotes.extend(notes.into_iter().map(|e| pb::NoteWithEmptyCards {
note_id: e.nid.0,
will_delete_note: e.empty.len() == e.current_count,
card_ids: e.empty.into_iter().map(|(_ord, id)| id.0).collect(),
outnotes.extend(notes.into_iter().map(|e| {
pb::empty_cards_report::NoteWithEmptyCards {
note_id: e.nid.0,
will_delete_note: e.empty.len() == e.current_count,
card_ids: e.empty.into_iter().map(|(_ord, id)| id.0).collect(),
}
}))
}
Ok(pb::EmptyCardsReport {