2022-11-20 11:43:10 -06:00
|
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
2025-12-02 13:10:35 -06:00
|
|
|
import 'package:immich_mobile/models/auth/oauth_login_data.model.dart';
|
2024-05-02 15:59:14 -05:00
|
|
|
import 'package:immich_mobile/providers/api.provider.dart';
|
2025-12-02 13:10:35 -06:00
|
|
|
import 'package:immich_mobile/services/oauth.service.dart';
|
|
|
|
|
import 'package:openapi/api.dart';
|
|
|
|
|
|
|
|
|
|
export 'package:immich_mobile/models/auth/oauth_login_data.model.dart';
|
2022-11-20 11:43:10 -06:00
|
|
|
|
2025-07-25 08:07:22 +05:30
|
|
|
final oAuthServiceProvider = Provider((ref) => OAuthService(ref.watch(apiServiceProvider)));
|
2025-12-02 13:10:35 -06:00
|
|
|
|
|
|
|
|
final oAuthProvider = StateNotifierProvider<OAuthNotifier, AsyncValue<void>>(
|
|
|
|
|
(ref) => OAuthNotifier(ref.watch(oAuthServiceProvider)),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
class OAuthNotifier extends StateNotifier<AsyncValue<void>> {
|
|
|
|
|
final OAuthService _oAuthService;
|
|
|
|
|
|
|
|
|
|
OAuthNotifier(this._oAuthService) : super(const AsyncValue.data(null));
|
|
|
|
|
|
|
|
|
|
Future<OAuthLoginData?> getOAuthLoginData(String serverUrl) {
|
|
|
|
|
return _oAuthService.getOAuthLoginData(serverUrl);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<LoginResponseDto?> completeOAuthLogin(OAuthLoginData oAuthData) {
|
|
|
|
|
return _oAuthService.completeOAuthLogin(oAuthData);
|
|
|
|
|
}
|
|
|
|
|
}
|