fix: optimize authenticatedApi provider to not rebuild unnecessarily

This commit is contained in:
Dr.Blank 2025-04-19 14:49:12 +05:30
parent e21977b894
commit 69a7dc4b1d
No known key found for this signature in database
GPG key ID: BA5F87FF0560C57B
2 changed files with 2 additions and 3 deletions

View file

@ -49,8 +49,7 @@ AudiobookshelfApi audiobookshelfApi(Ref ref, Uri? baseUrl) {
/// if the user is not authenticated throw an error
@Riverpod(keepAlive: true)
AudiobookshelfApi authenticatedApi(Ref ref) {
final apiSettings = ref.watch(apiSettingsProvider);
final user = apiSettings.activeUser;
final user = ref.watch(apiSettingsProvider.select((s) => s.activeUser));
if (user == null) {
_logger.severe('No active user can not provide authenticated api');
throw StateError('No active user');

View file

@ -170,7 +170,7 @@ class _AudiobookshelfApiProviderElement
Uri? get baseUrl => (origin as AudiobookshelfApiProvider).baseUrl;
}
String _$authenticatedApiHash() => r'5cf3329fe3074e3a09e266b4bae78b53e9c01220';
String _$authenticatedApiHash() => r'284be2c39823c20fb70035a136c430862c28fa27';
/// get the api instance for the authenticated user
///