Skip to content

fix(client/android): clear all favorites when other settings are reset#6707

Merged
ReactorScram merged 15 commits into
mainfrom
fix/android-reset-favorites
Sep 17, 2024
Merged

fix(client/android): clear all favorites when other settings are reset#6707
ReactorScram merged 15 commits into
mainfrom
fix/android-reset-favorites

Conversation

@ReactorScram
Copy link
Copy Markdown
Contributor

@ReactorScram ReactorScram commented Sep 16, 2024

This required some refactoring since we want to move away from LiveData and towards StateFlow

Closes #6293

@ReactorScram ReactorScram self-assigned this Sep 16, 2024
@vercel
Copy link
Copy Markdown

vercel Bot commented Sep 16, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
firezone ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 17, 2024 8:08pm

@ApplicationContext context: Context,
): Bundle = (context.getSystemService(Context.RESTRICTIONS_SERVICE) as android.content.RestrictionsManager).applicationRestrictions

@Singleton
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Without this line, Hilt was creating 2 Repository instances, one for each ViewModel. I have no clue how Hilt works internally so I'm not sure why it did that.

Comment thread kotlin/android/app/src/main/java/dev/firezone/android/core/data/Repository.kt Outdated
Copy link
Copy Markdown
Member

@thomaseizinger thomaseizinger left a comment

Choose a reason for hiding this comment

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

Nice! Thanks for knocking this one out.


fun addFavoriteResource(id: String) {
favorites.value.inner.add(id)
saveFavoritesSync()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Instead of repeating this, can we now subscribe to changes to the MutableStateFlow and save them on every change?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Alternatively, we could make it directly a DataStore perhaps? Not sure how difficult that would be.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It might be hard to get rid of because we're also manually triggering the flow to emit in saveFavoritesSync. Maybe in a future PR

@ReactorScram ReactorScram added this pull request to the merge queue Sep 17, 2024
Merged via the queue into main with commit 7c55859 Sep 17, 2024
@ReactorScram ReactorScram deleted the fix/android-reset-favorites branch September 17, 2024 20:39
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(android): make sure something can reset the favorites

2 participants