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: Card browser list contents not shown just after language change #17823

Conversation

Siddheshjondhale
Copy link
Contributor

@Siddheshjondhale Siddheshjondhale commented Jan 15, 2025

Purpose / Description

Fixes the issue where the card browser list contents were not shown just after a language change. The fix ensures the columns and data are properly reinitialized and displayed after the language is switched.

Fixes

Approach

This change reinitializes the browser columns using a lifecycleScope to ensure proper display of list content when returning to the screen after a language change.

How Has This Been Tested?

The issue was tested by switching between different languages and verifying that the card browser's list contents.
Physical Device (Samsung Galaxy A6+)

Screen_Recording_20250116-025053_AnkiDroid.1.1.mp4

Checklist

Please, go through these checks before submitting the PR.

  • 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

@Siddheshjondhale Siddheshjondhale changed the title Fix: Card list browser contents not shown just after language change Fix: Card browser list contents not shown just after language change Jan 15, 2025
Copy link
Member

@BrayanDSO BrayanDSO left a comment

Choose a reason for hiding this comment

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

I feel that this isn't the ideal fix. It adds a lot of extra computation every time that the activity calls onResume, which is relatively frequent, and 99% of the times it will be wasted, since changing languages isn't frequent + it is fixable by closing/reopening the browser + the language need to be changed while the browser is in the backstack

I guess that it is a problem with the activity initialization, or with how the backend is reset after changing a language. Only way to tell is to actually investigate and try to solve it

@david-allison will definitely have a better guess than me here.

@BrayanDSO BrayanDSO added Needs Author Reply Waiting for a reply from the original author Needs reviewer reply Waiting for a reply from another reviewer labels Jan 16, 2025
@Siddheshjondhale
Copy link
Contributor Author

I feel that this isn't the ideal fix. It adds a lot of extra computation every time that the activity calls onResume, which is relatively frequent, and 99% of the times it will be wasted, since changing languages isn't frequent + it is fixable by closing/reopening the browser + the language need to be changed while the browser is in the backstack

I guess that it is a problem with the activity initialization, or with how the backend is reset after changing a language. Only way to tell is to actually investigate and try to solve it

@david-allison will definitely have a better guess than me here.

That makes sense.

One approach came to my mind and I tested moving the lifecycleScope block into onCreate() and it works fine. Since onCreate() gets called again after a language change, it reinitializes the columns only when needed, which avoids the extra computation in onResume()

@david-allison @BrayanDSO let me know what you think

@david-allison
Copy link
Member

See 1a8fb3e

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Author Reply Waiting for a reply from the original author Needs reviewer reply Waiting for a reply from another reviewer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Card browser list contents are not shown just after language change
3 participants