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

Fixes #13312: Delegate onConfigurationChanged to the ViewModel #13313

Conversation

dautovicharis
Copy link
Contributor

@dautovicharis dautovicharis commented Dec 8, 2023

Contributor checklist

  • Redmi Note 10 Pro, Android 13, MUI 14
  • My contribution is fully baked and ready to be merged as is
  • I ensure that all the open issues my contribution fixes are mentioned in the commit message of my first commit using the Fixes #1234 syntax

Issue

Fixes: #13312

Description

In the beginning, I thought the problem had to do with the layout, but it turns out it's more about threads.

To make the layout hierarchy better, I tried taking out LinearLayout from onboarding_megaphone.xml. Unfortunately, this change didn't fix the issue.

After digging deeper, I found that the onConfigurationChanged method inside ConversationListFragment was incorrectly calling onMegaphoneChanged directly. It should go through lifecycleDisposable.

I tried to emit the current megaphone object using the following approach, but it didn't work because of the use of distinctUntilChanged():

fun onConfigurationChanged() {
    store.update { it.copy(megaphone = megaphone) }
}

Instead, I fetched the next megaphone object from the repository and updated the state.

fun onConfigurationChanged() {
    megaphoneRepository.getNextMegaphone { next ->
        store.update { it.copy(megaphone = next ?: Megaphone.NONE) }
    }
}

Final solution:
Moved onConfigurationChanged handling from ConversationListFragment to the ViewModel, ensuring consistency in UI updates via lifecycleDisposable and maintaining the guarantee of UI observations on the main thread.

Videos

fix.mov

Tested

Device Android Version Signal Version
Redmi Note 10 Pro Screenshot 2023-12-08 at 15 44 34 6.42.0

Copy link

stale bot commented Feb 9, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Feb 9, 2024
Copy link

stale bot commented Feb 16, 2024

This issue has been closed due to inactivity.

@stale stale bot closed this Feb 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

'Get started' view layout issues after onConfigurationChanged
1 participant