|
|
@ -7,7 +7,6 @@ import 'package:neon/src/blocs/user_details.dart'; |
|
|
|
import 'package:neon/src/blocs/user_status.dart'; |
|
|
|
import 'package:neon/src/blocs/user_status.dart'; |
|
|
|
import 'package:neon/src/models/account.dart'; |
|
|
|
import 'package:neon/src/models/account.dart'; |
|
|
|
import 'package:neon/src/neon.dart'; |
|
|
|
import 'package:neon/src/neon.dart'; |
|
|
|
import 'package:package_info_plus/package_info_plus.dart'; |
|
|
|
|
|
|
|
import 'package:rxdart/rxdart.dart'; |
|
|
|
import 'package:rxdart/rxdart.dart'; |
|
|
|
import 'package:shared_preferences/shared_preferences.dart'; |
|
|
|
import 'package:shared_preferences/shared_preferences.dart'; |
|
|
|
|
|
|
|
|
|
|
@ -30,7 +29,6 @@ class AccountsBloc extends Bloc implements AccountsBlocEvents, AccountsBlocState |
|
|
|
this._storage, |
|
|
|
this._storage, |
|
|
|
this._sharedPreferences, |
|
|
|
this._sharedPreferences, |
|
|
|
this._globalOptions, |
|
|
|
this._globalOptions, |
|
|
|
this._packageInfo, |
|
|
|
|
|
|
|
this._allAppImplementations, |
|
|
|
this._allAppImplementations, |
|
|
|
) { |
|
|
|
) { |
|
|
|
accounts.listen((final as) async { |
|
|
|
accounts.listen((final as) async { |
|
|
@ -42,7 +40,7 @@ class AccountsBloc extends Bloc implements AccountsBlocEvents, AccountsBlocState |
|
|
|
accounts.add( |
|
|
|
accounts.add( |
|
|
|
_storage |
|
|
|
_storage |
|
|
|
.getStringList(_keyAccounts)! |
|
|
|
.getStringList(_keyAccounts)! |
|
|
|
.map((final a) => (Account.fromJson(json.decode(a) as Map<String, dynamic>))..setupClient(_packageInfo)) |
|
|
|
.map((final a) => Account.fromJson(json.decode(a) as Map<String, dynamic>)) |
|
|
|
.toList(), |
|
|
|
.toList(), |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
@ -69,7 +67,6 @@ class AccountsBloc extends Bloc implements AccountsBlocEvents, AccountsBlocState |
|
|
|
final SharedPreferences _sharedPreferences; |
|
|
|
final SharedPreferences _sharedPreferences; |
|
|
|
final GlobalOptions _globalOptions; |
|
|
|
final GlobalOptions _globalOptions; |
|
|
|
final List<AppImplementation> _allAppImplementations; |
|
|
|
final List<AppImplementation> _allAppImplementations; |
|
|
|
final PackageInfo _packageInfo; |
|
|
|
|
|
|
|
final _keyAccounts = 'accounts'; |
|
|
|
final _keyAccounts = 'accounts'; |
|
|
|
final _keyLastUsedAccount = 'last-used-account'; |
|
|
|
final _keyLastUsedAccount = 'last-used-account'; |
|
|
|
|
|
|
|
|
|
|
@ -102,7 +99,6 @@ class AccountsBloc extends Bloc implements AccountsBlocEvents, AccountsBlocState |
|
|
|
|
|
|
|
|
|
|
|
@override |
|
|
|
@override |
|
|
|
void addAccount(final Account account) { |
|
|
|
void addAccount(final Account account) { |
|
|
|
account.setupClient(_packageInfo); |
|
|
|
|
|
|
|
if (activeAccount.valueOrNull == null) { |
|
|
|
if (activeAccount.valueOrNull == null) { |
|
|
|
setActiveAccount(account); |
|
|
|
setActiveAccount(account); |
|
|
|
} |
|
|
|
} |
|
|
@ -140,7 +136,6 @@ class AccountsBloc extends Bloc implements AccountsBlocEvents, AccountsBlocState |
|
|
|
|
|
|
|
|
|
|
|
@override |
|
|
|
@override |
|
|
|
void updateAccount(final Account account) { |
|
|
|
void updateAccount(final Account account) { |
|
|
|
account.setupClient(_packageInfo); |
|
|
|
|
|
|
|
final as = accounts.value; |
|
|
|
final as = accounts.value; |
|
|
|
final index = as.indexWhere((final a) => a.id == account.id); |
|
|
|
final index = as.indexWhere((final a) => a.id == account.id); |
|
|
|
if (index == -1) { |
|
|
|
if (index == -1) { |
|
|
|