Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@Arthur-Milchior
Copy link
Contributor

@Arthur-Milchior Arthur-Milchior commented Apr 12, 2025

This PR initially offered to solve an already solved issue that I missed.

The first two commits were some clean-up that I believe are still improving the codebase, so I keep this PR open but removed the last commit.

Here is the original description:

Introduce get_non_empty_card_indexes

This method takes a note type id and the content of fields. It returns
the order of the cards that would be non-empty according to this note.

To be more specific, for cloze type, it return any cloze
number (except 0), even if it does not appear in a cloze field, in
order to be consistent with the way anki generates note.

For normal type, for each template, it returns whether the card would
be generated, and also whether the template has an error.

The goal here is to allow ankidroid to display in the note editor's
previewer which card will be generated. Which is done currently by
checking whether the "empty card" message appear in the previewer,
which is not ideal.

Please let me know whether you'd accept this service. In which case I'll add a few tests with the default note type. I preferred not to spend more time adding tests until I know whether it'd be useful or not

@Arthur-Milchior Arthur-Milchior changed the title Empty cards service to state which card would be generated given note type id and field content Apr 12, 2025
@user1823
Copy link
Contributor

Wasn't this issue already solved by #3890?

@Arthur-Milchior
Copy link
Contributor Author

It seems so. I looked for this march 16 when I opened the bug in ankidroid. I had no idea that somebody solved it in the meantime. Wonderful.

I needed to know because {{c1 generate card 0 for example. And storing
the card ordinal would have been another consistent choice.
@Arthur-Milchior Arthur-Milchior changed the title service to state which card would be generated given note type id and field content Some documentation and reduce copy/paste Apr 21, 2025
@Arthur-Milchior
Copy link
Contributor Author

Also, we'll need to check. But given that we have always a small cost to pay to send request to the back-end, a method that returns all data may be better than having to send one request by template, especially as long as it does not provide a way to send multiple request as a batch.

But i'll see whether it makes sense when we can actually test the feature

This slightly reduce code duplication.
@dae
Copy link
Member

dae commented Apr 24, 2025

a method that returns all data may be better than having to send one request by template

If it proves necessary in the future, we can always add it then.

@dae dae merged commit 7bebcad into ankitects:main Apr 24, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants