Skip to content

Conversation

@Manhhao
Copy link
Contributor

@Manhhao Manhhao commented Oct 28, 2025

This was mainly made to address the issue mentioned #87, but there are also a few additional changes. This probably broke when Yomitan added support for more than two card formats yomidevs/yomitan#1930.

By default Yomitan sets up three Anki card formats. If one of the formats is not configured, it will still get queried into Ankiconnect with an empty deck name, model name and fields array. This works fine on Ankiconnect desktop, as it will only validate the input and throw an Exception after canAddNote calls createNote, but did not work in Ankiconnect Android, because it parses the note first, and accesses the fields array without checking whether this has any entries.

field and value now default to null and are only updated when the fields array is not empty.

The previous implementation of canAddNotes from #60 assumed that note options and model are the same for all notes Yomitan which is not the case anymore. This PR addresses this, and also implements the remaining error messages for canAddNotesWithError.

@Manhhao
Copy link
Contributor Author

Manhhao commented Oct 28, 2025

After using this for a while, this seems to affect performance quite a bit, so this might need some optimization.

@Manhhao
Copy link
Contributor Author

Manhhao commented Oct 28, 2025

This should match the performance of the old build now. The biggest bottleneck is probably isNoteInDeck, but I am not sure if this is optimizable, because there seems to be no way to access the cards table directly. This is unlikely to cause any issues with normal usecases anyway.

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.

1 participant