-
Notifications
You must be signed in to change notification settings - Fork 200
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 blink favorite icon #945
Conversation
core/data/src/commonMain/kotlin/io/github/droidkaigi/confsched/data/user/UserDataStore.kt
Outdated
Show resolved
Hide resolved
.../commonMain/kotlin/io/github/droidkaigi/confsched/data/sessions/DefaultSessionsRepository.kt
Outdated
Show resolved
Hide resolved
Thank you for your insights on the code. I think this PR introduces several changes. What do you think is the cause? If we use memory cache, is rememberRetained fine? It is a little difficult to manage if we add a source of information. |
Thank you for your comment.
I did some further investigation. The probable causes are:
The problem seems to be that the value during the transition to another screen cannot be reflected, so it doesn’t seem that rememberRetained can solve the issue.
I agree with that. How about changing getFavoriteSessionStream to return a StateFlow instead of exposing the memory cache, and using collectAsState so that the latest value is always reflected when returning to the original screen? I believe there may be some issues with this approach as well, so once I push the code, I’d appreciate it if you could review it. |
This reverts commit d55402c.
To return the same instance of StateFlow
Updated the source code and the overview 😄 |
Detekt check failed. Please run |
|
||
public class UserDataStore(private val dataStore: DataStore<Preferences>) { | ||
|
||
private val mutableIdToken = MutableStateFlow<String?>(null) | ||
public val idToken: StateFlow<String?> = mutableIdToken | ||
|
||
public fun getFavoriteSessionStream(): Flow<PersistentSet<TimetableItemId>> { | ||
return dataStore.data | ||
private val singletonCoroutineScope: CoroutineScope = CoroutineScope(Job()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be an unmanaged dispatcher in tests, which could result in flaky tests. I think we need to pass a dispatcher for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your comment.
I modified it so that testDispatcher can be used during testing.
Does this fix seem okay to you?
move coroutineScope field to constructor parameter
Add TestUserDataStoreModule
I'm not sure, but the tests don't show all the favorite sessions. 👀 |
Thank you. I also share your concern about having a CoroutineScope in DataStore, so I will try exploring alternative approaches, though it may be quite challenging. If I can’t resolve it, I may give up and close this pull request, so would it be possible to assign someone else? |
I apologize. I tried various things, but I couldn't resolve the issue successfully. I will continue to investigate, but I would like to unassign myself and close this pull request for now. |
Issue
Overview (Required)
The probable causes are:
The value of collectAsRetainedState is not collected while navigating to another screen.
When returning to the original screen, the value is collected
but the update of the value likely occurs based on the execution timing of LaunchedEffect, so until the value is updated, the displayed value is not the latest.
Movie (Optional)
before_Screen_recording_20240904_002135.mp4
after_Screen_recording_20240906_002004.mp4