🐛 linux/userinfo.dart: guard Firebase calls if Firebase is uninitialized
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:developer';
|
||||
import 'dart:io' show Platform;
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
@@ -28,7 +29,10 @@ class UserInfoNotifier extends StateNotifier<AsyncValue<SnAccount?>> {
|
||||
final response = await client.get('/id/accounts/me');
|
||||
final user = SnAccount.fromJson(response.data);
|
||||
state = AsyncValue.data(user);
|
||||
|
||||
if (kIsWeb || !Platform.isLinux) {
|
||||
FirebaseAnalytics.instance.setUserId(id: user.id);
|
||||
}
|
||||
} catch (error, stackTrace) {
|
||||
if (!kIsWeb) {
|
||||
if (error is DioException) {
|
||||
@@ -83,9 +87,11 @@ class UserInfoNotifier extends StateNotifier<AsyncValue<SnAccount?>> {
|
||||
final prefs = _ref.read(sharedPreferencesProvider);
|
||||
await prefs.remove(kTokenPairStoreKey);
|
||||
_ref.invalidate(tokenProvider);
|
||||
if (kIsWeb || !Platform.isLinux) {
|
||||
FirebaseAnalytics.instance.setUserId(id: null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final userInfoProvider =
|
||||
StateNotifierProvider<UserInfoNotifier, AsyncValue<SnAccount?>>(
|
||||
|
Reference in New Issue
Block a user