Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix notetype name being reverted when going to CardTemplateEditor #17173

Merged
merged 1 commit into from
Oct 3, 2024

Conversation

lukstbit
Copy link
Member

@lukstbit lukstbit commented Oct 1, 2024

Purpose / Description

Due to how CardTemplateEditor accesses the collection it seems it doesn't "see" the renames done in ManageNotetypes so when it saves any changes to the template it also saves the last name it "saw". I just called load() on the collection to initialize again the components, especially Notetypes. This should be ok, I don't think there are other side effects on calling load().

There's a warning for worker method being called on the main thread but I think it's safe as that method just initializes again several objects, it doesn't seem to do anything heavy.

We should probably move CardTemplateEditor to use CollectionManager.

Fixes

How Has This Been Tested?

Ran the tests, manually tried(and failed) to replicate the issue again.

Checklist

  • You have a descriptive commit message with a short title (first line, max 50 chars).
  • You have commented your code, particularly in hard-to-understand areas
  • You have performed a self-review of your own code
  • UI changes: include screenshots of all affected screens (in particular showing any new or changed strings)
  • UI Changes: You have tested your change using the Google Accessibility Scanner

Copy link
Member

@mikehardy mikehardy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our old friend CardTemplateEditor and the problem of doing all the bookkeeping correctly while handling ephemeral data. Good stuff.

This seems like a reasonable solution to me, thanks @lukstbit

@mikehardy mikehardy added Needs Second Approval Has one approval, one more approval to merge and removed Needs Review labels Oct 1, 2024
@mikehardy mikehardy added this to the 2.19 release milestone Oct 1, 2024
Copy link
Member

@david-allison david-allison left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This implies we're not doing things correctly WRT the Rust backend.

This works as a bandaid, but we should add a task to work through the underlying issue

My comment below is untested, and I strongly suspect this fix is correct

A unit test or @NeedsTest here would be useful, but not necessary

@david-allison david-allison added Needs Author Reply Waiting for a reply from the original author Pending Merge Things with approval that are waiting future merge (e.g. targets a future release, CI wait, etc) and removed Needs Second Approval Has one approval, one more approval to merge labels Oct 2, 2024
There's a disconnect between what ManageNoteypes is doing(working with
the collection through CollectionManager) and what CardTemplatedEditor
is doing(using the previous system with getColUnsafe). This seems to
result in CardTemplateEditor "seeing" only the previous name from
ManageNotetypes and reverting the name when any change in the template
is saved. A call to Notetypes.clearCache() was introduced to remove
stale data from Notetypes.
@lukstbit lukstbit removed the Needs Author Reply Waiting for a reply from the original author label Oct 3, 2024
@lukstbit lukstbit added this pull request to the merge queue Oct 3, 2024
Merged via the queue into ankidroid:main with commit 7a83808 Oct 3, 2024
9 checks passed
@github-actions github-actions bot removed the Pending Merge Things with approval that are waiting future merge (e.g. targets a future release, CI wait, etc) label Oct 3, 2024
@lukstbit lukstbit deleted the fix_notetypeRenaming branch October 3, 2024 10:33
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.

[BUG]: Renaming Note Type Doesn't Take Effect
3 participants