mirror of
https://github.com/immich-app/immich.git
synced 2026-04-16 23:51:55 -04:00
* refactor: yank old timeline # Conflicts: # mobile/lib/presentation/pages/editing/drift_edit.page.dart # mobile/lib/providers/websocket.provider.dart # mobile/lib/routing/router.dart * more cleanup * remove native code * chore: bump sqlite-data version * remove old background tasks from BGTaskSchedulerPermittedIdentifiers * rebase --------- Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
33 lines
949 B
Dart
33 lines
949 B
Dart
import 'dart:async';
|
|
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|
import 'package:immich_mobile/domain/models/user.model.dart';
|
|
import 'package:immich_mobile/domain/services/user.service.dart';
|
|
import 'package:immich_mobile/providers/infrastructure/user.provider.dart';
|
|
|
|
class CurrentUserProvider extends StateNotifier<UserDto?> {
|
|
CurrentUserProvider(this._userService) : super(null) {
|
|
state = _userService.tryGetMyUser();
|
|
streamSub = _userService.watchMyUser().listen((user) => state = user ?? state);
|
|
}
|
|
|
|
final UserService _userService;
|
|
late final StreamSubscription<UserDto?> streamSub;
|
|
|
|
refresh() async {
|
|
try {
|
|
await _userService.refreshMyUser();
|
|
} catch (_) {}
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
streamSub.cancel();
|
|
super.dispose();
|
|
}
|
|
}
|
|
|
|
final currentUserProvider = StateNotifierProvider<CurrentUserProvider, UserDto?>((ref) {
|
|
return CurrentUserProvider(ref.watch(userServiceProvider));
|
|
});
|