Fix import dialog showing 0 notes/media for subdeck-only decks#255
Conversation
a8e316a to
8b50f8f
Compare
Convert the deck from JSON before showing the import dialog so the dialog can use Deck.get_note_count() and a new Deck.get_media_file_count() to display counts recursively across subdecks. Closes Stvad#190
8b50f8f to
0825778
Compare
|
Thanks very much for this! (And thanks for patiently rebasing over master, multiple times...) I'm sorry for the horrible delay replying and also for the multiple issues with our actions! One slight issue is that it seems that if the same media files are present in multiple sub-decks (e.g. re-using the same media in multiple notes or having shared ( Otherwise, this looks great! |
The same media file (re-used media or shared `_xxx` media) can appear in multiple decks. Count unique filenames via a set instead of summing per-deck counts, so shared/duplicated media is no longer overcounted.
|
Thanks for the feedback. Can you please take a look if the newest changes fulfill your questions? |
|
Thanks very much! |
Summary
Fixes #190. The import dialog's "Notes:" and "Media Files:" counts were read directly from the top-level JSON arrays, so decks whose notes/media live only in subdecks displayed
0.This matches the approach proposed in the issue: do the JSON→
Deckconversion once, before showing the dialog, and let the dialog ask theDeckfor the counts. This removes a coupling between the dialog and the on-disk JSON layout.Changes
Deck: newget_media_file_count()parallel to the existingget_note_count(), plus amedia_filesfield.deck_initializer.from_json: populatedeck.media_filesfrom the JSON beforepost_import_filterstrips the key.anki_importer.load_deck: build theDeckup front and pass it to the dialog instead of the raw JSON.ImportDialog: takes aDeck; note models are read fromdeck.metadata.models; counts come from the twoget_*_count()methods.Tests
test/representation/deck_spec.py(new) — unit tests for both count methods (flat, nested, subdeck-only).test/representation/deck_initializer_spec.py— added an integration test verifyingfrom_jsonpopulatesmedia_filesrecursively.Manual verification
Tested locally in Anki by importing a deck whose notes live only in a subdeck — the dialog now reports the correct counts instead of
0.