-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
feat(mobile): Background app refresh status #1839
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Ignored Deployment
|
} | ||
|
||
final iOSBackgroundSettingsProvider = StateProvider<IOSBackgroundSettingsState>( | ||
(ref) => IOSBackgroundSettingsState(ref.read(backgroundServiceProvider)), |
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.
I think we should use ref.watch
here? is there any reason you are choosing to use ref.read
?
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.
Not really sure. I guess watch will update this provider when it changes? This only barely depends on the backgroundServiceProvider
at all; it just had all the method channel communication functions in it, so I piggybacked there.
I'm still not super familiar with RiverPod and there's likely something I'm not doing correct here. But I made the change and it still seems happily working here.
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.
Riverpod suggests using ref.watch
as much as possible I believe. Only using ref.read
in button pressing context.
Here is some good info
https://riverpod.dev/docs/concepts/reading#using-ref-to-interact-with-providers
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.
Thanks! I gave it a read and it's becoming clearer to me.
In any event, I changed it to ref.watch
and looked through the code to find other ref.read
statements. In this case, the other ref.read
statements are justified as they are just one-off refreshes (app resume and page load).
|
||
} | ||
|
||
final iOSBackgroundSettingsProvider = StateProvider<IOSBackgroundSettingsState>( |
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.
If you are using StateNotifier
I believe you have to use StateNotifierProvider
here instead of StateProvider
. Is using StateProvider
do what you are expecting?
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.
Forgot to say I resolved this.
Adds a message that App Refresh is currently disabled and a settings button to navigate to app settings.
Unfortunately, the Go To Settings takes you to Settings > Immich instead of Settings > General > Background App Refresh.