migrated accounts store to ChangeNotifier
This commit is contained in:
parent
28e0ec9bcb
commit
91d8477e85
|
@ -28,9 +28,8 @@ Future<void> main() async {
|
|||
ChangeNotifierProvider.value(
|
||||
value: configStore,
|
||||
),
|
||||
Provider<AccountsStore>(
|
||||
create: (_) => accountsStore,
|
||||
dispose: (_, store) => store.dispose(),
|
||||
ChangeNotifierProvider.value(
|
||||
value: accountsStore,
|
||||
),
|
||||
],
|
||||
child: MyApp(),
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||
import 'package:flutter_mobx/flutter_mobx.dart';
|
||||
|
||||
import '../hooks/stores.dart';
|
||||
import '../util/goto.dart';
|
||||
|
@ -19,107 +18,101 @@ class UserProfileTab extends HookWidget {
|
|||
final theme = Theme.of(context);
|
||||
final accountsStore = useAccountsStore();
|
||||
|
||||
return Observer(
|
||||
builder: (ctx) {
|
||||
if (accountsStore.hasNoAccount) {
|
||||
return Scaffold(
|
||||
body: Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text('No account was added.'),
|
||||
FlatButton.icon(
|
||||
onPressed: () {
|
||||
goTo(context, (_) => AccountsConfigPage());
|
||||
},
|
||||
icon: Icon(Icons.add),
|
||||
label: Text('Add account'),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return Scaffold(
|
||||
extendBodyBehindAppBar: true,
|
||||
// TODO: this is not visible in light mode when the sliver app bar
|
||||
// in UserProfile is folded
|
||||
appBar: AppBar(
|
||||
backgroundColor: Colors.transparent,
|
||||
shadowColor: Colors.transparent,
|
||||
centerTitle: true,
|
||||
title: FlatButton(
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
// TODO: fix overflow issues
|
||||
'@${accountsStore.defaultUsername}',
|
||||
style: theme.primaryTextTheme.headline6,
|
||||
overflow: TextOverflow.fade,
|
||||
),
|
||||
Icon(
|
||||
Icons.expand_more,
|
||||
color: theme.primaryIconTheme.color,
|
||||
),
|
||||
],
|
||||
),
|
||||
onPressed: () {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
backgroundColor: Colors.transparent,
|
||||
builder: (_) {
|
||||
final userTags = <String>[];
|
||||
|
||||
accountsStore.tokens.forEach((instanceUrl, value) {
|
||||
value.forEach((username, _) {
|
||||
userTags.add('$username@$instanceUrl');
|
||||
});
|
||||
});
|
||||
|
||||
return Observer(
|
||||
builder: (ctx) => BottomModal(
|
||||
title: 'account',
|
||||
child: Column(
|
||||
children: [
|
||||
for (final tag in userTags)
|
||||
RadioListTile<String>(
|
||||
value: tag,
|
||||
title: Text(tag),
|
||||
groupValue: '${accountsStore.defaultUsername}'
|
||||
'@${accountsStore.defaultInstanceUrl}',
|
||||
onChanged: (selected) {
|
||||
final userTag = selected.split('@');
|
||||
accountsStore.setDefaultAccount(
|
||||
userTag[1], userTag[0]);
|
||||
Navigator.of(ctx).pop();
|
||||
},
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: Icon(Icons.settings),
|
||||
if (accountsStore.hasNoAccount) {
|
||||
return Scaffold(
|
||||
body: Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text('No account was added.'),
|
||||
FlatButton.icon(
|
||||
onPressed: () {
|
||||
goTo(context, (_) => SettingsPage());
|
||||
goTo(context, (_) => AccountsConfigPage());
|
||||
},
|
||||
icon: Icon(Icons.add),
|
||||
label: Text('Add account'),
|
||||
)
|
||||
],
|
||||
),
|
||||
body: UserProfile(
|
||||
userId: accountsStore.defaultToken.payload.id,
|
||||
instanceUrl: accountsStore.defaultInstanceUrl,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return Scaffold(
|
||||
extendBodyBehindAppBar: true,
|
||||
// TODO: this is not visible in light mode when the sliver app bar
|
||||
// in UserProfile is folded
|
||||
appBar: AppBar(
|
||||
backgroundColor: Colors.transparent,
|
||||
shadowColor: Colors.transparent,
|
||||
centerTitle: true,
|
||||
title: FlatButton(
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
// TODO: fix overflow issues
|
||||
'@${accountsStore.defaultUsername}',
|
||||
style: theme.primaryTextTheme.headline6,
|
||||
overflow: TextOverflow.fade,
|
||||
),
|
||||
Icon(
|
||||
Icons.expand_more,
|
||||
color: theme.primaryIconTheme.color,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
onPressed: () {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
backgroundColor: Colors.transparent,
|
||||
builder: (ctx) {
|
||||
final userTags = <String>[];
|
||||
|
||||
accountsStore.tokens.forEach((instanceUrl, value) {
|
||||
value.forEach((username, _) {
|
||||
userTags.add('$username@$instanceUrl');
|
||||
});
|
||||
});
|
||||
|
||||
return BottomModal(
|
||||
title: 'account',
|
||||
child: Column(
|
||||
children: [
|
||||
for (final tag in userTags)
|
||||
RadioListTile<String>(
|
||||
value: tag,
|
||||
title: Text(tag),
|
||||
groupValue: '${accountsStore.defaultUsername}'
|
||||
'@${accountsStore.defaultInstanceUrl}',
|
||||
onChanged: (selected) {
|
||||
final userTag = selected.split('@');
|
||||
accountsStore.setDefaultAccount(
|
||||
userTag[1], userTag[0]);
|
||||
Navigator.of(ctx).pop();
|
||||
},
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: Icon(Icons.settings),
|
||||
onPressed: () {
|
||||
goTo(context, (_) => SettingsPage());
|
||||
},
|
||||
)
|
||||
],
|
||||
),
|
||||
body: UserProfile(
|
||||
userId: accountsStore.defaultToken.payload.id,
|
||||
instanceUrl: accountsStore.defaultInstanceUrl,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,41 +1,66 @@
|
|||
import 'dart:collection';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:lemmy_api_client/lemmy_api_client.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
part 'accounts_store.g.dart';
|
||||
|
||||
/// Store that manages all accounts
|
||||
class AccountsStore extends _AccountsStore with _$AccountsStore {}
|
||||
class AccountsStore extends ChangeNotifier {
|
||||
/// Map containing JWT tokens of specific users.
|
||||
/// If a token is in this map, the user is considered logged in
|
||||
/// for that account.
|
||||
/// `tokens['instanceUrl']['username']`
|
||||
HashMap<String, HashMap<String, Jwt>> get tokens => _tokens;
|
||||
HashMap<String, HashMap<String, Jwt>> _tokens;
|
||||
|
||||
abstract class _AccountsStore with Store {
|
||||
ReactionDisposer _saveReactionDisposer;
|
||||
ReactionDisposer _pickDefaultsDisposer;
|
||||
/// default account for a given instance
|
||||
/// map where keys are instanceUrls and values are usernames
|
||||
HashMap<String, String> _defaultAccounts;
|
||||
|
||||
_AccountsStore() {
|
||||
// persistently save settings each time they are changed
|
||||
_saveReactionDisposer = reaction(
|
||||
(_) => [
|
||||
tokens.forEach((k, submap) =>
|
||||
MapEntry(k, submap.forEach((k2, v2) => MapEntry(k2, v2)))),
|
||||
_defaultAccount,
|
||||
_defaultAccounts.asObservable(),
|
||||
],
|
||||
(_) => save(),
|
||||
);
|
||||
/// default account for the app
|
||||
/// It is in a form of `username@instanceUrl`
|
||||
String _defaultAccount;
|
||||
|
||||
// automatically set new default accounts when accounts are added/removed
|
||||
_pickDefaultsDisposer = reaction(
|
||||
(_) => [
|
||||
tokens.forEach((k, submap) =>
|
||||
MapEntry(k, submap.forEach((k2, v2) => MapEntry(k2, v2)))),
|
||||
],
|
||||
(_) => _assignDefaultAccounts(),
|
||||
);
|
||||
Future<void> load() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
|
||||
// I barely understand what I did. Long story short it casts a
|
||||
// raw json into a nested ObservableMap
|
||||
nestedMapsCast<T>(T f(Map<String, dynamic> json)) => HashMap.of(
|
||||
(jsonDecode(prefs.getString('tokens') ?? '{}')
|
||||
as Map<String, dynamic>)
|
||||
?.map(
|
||||
(k, e) => MapEntry(
|
||||
k,
|
||||
HashMap.of(
|
||||
(e as Map<String, dynamic>)?.map(
|
||||
(k, e) => MapEntry(
|
||||
k, e == null ? null : f(e as Map<String, dynamic>)),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
// set saved settings or create defaults
|
||||
_tokens = nestedMapsCast((json) => Jwt(json['raw']));
|
||||
_defaultAccount = prefs.getString('defaultAccount');
|
||||
_defaultAccounts = HashMap.of(Map.castFrom(
|
||||
jsonDecode(prefs.getString('defaultAccounts') ?? 'null') ?? {}));
|
||||
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
@action
|
||||
Future<void> save() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
|
||||
await prefs.setString('defaultAccount', _defaultAccount);
|
||||
await prefs.setString('defaultAccounts', jsonEncode(_defaultAccounts));
|
||||
await prefs.setString('tokens', jsonEncode(tokens));
|
||||
}
|
||||
|
||||
/// automatically sets default accounts
|
||||
void _assignDefaultAccounts() {
|
||||
// remove dangling defaults
|
||||
_defaultAccounts.entries.map((dft) {
|
||||
|
@ -80,65 +105,6 @@ abstract class _AccountsStore with Store {
|
|||
}
|
||||
}
|
||||
|
||||
void dispose() {
|
||||
_saveReactionDisposer();
|
||||
_pickDefaultsDisposer();
|
||||
}
|
||||
|
||||
void load() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
|
||||
// I barely understand what I did. Long story short it casts a
|
||||
// raw json into a nested ObservableMap
|
||||
nestedMapsCast<T>(String key, T f(Map<String, dynamic> json)) =>
|
||||
ObservableMap.of(
|
||||
(jsonDecode(prefs.getString(key) ?? '{}') as Map<String, dynamic>)
|
||||
?.map(
|
||||
(k, e) => MapEntry(
|
||||
k,
|
||||
ObservableMap.of(
|
||||
(e as Map<String, dynamic>)?.map(
|
||||
(k, e) => MapEntry(
|
||||
k, e == null ? null : f(e as Map<String, dynamic>)),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
// set saved settings or create defaults
|
||||
tokens = nestedMapsCast('tokens', (json) => Jwt(json['raw']));
|
||||
_defaultAccount = prefs.getString('defaultAccount');
|
||||
_defaultAccounts = ObservableMap.of(Map.castFrom(
|
||||
jsonDecode(prefs.getString('defaultAccounts') ?? 'null') ?? {}));
|
||||
}
|
||||
|
||||
void save() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
|
||||
await prefs.setString('defaultAccount', _defaultAccount);
|
||||
await prefs.setString('defaultAccounts', jsonEncode(_defaultAccounts));
|
||||
await prefs.setString('tokens', jsonEncode(tokens));
|
||||
}
|
||||
|
||||
/// Map containing JWT tokens of specific users.
|
||||
/// If a token is in this map, the user is considered logged in
|
||||
/// for that account.
|
||||
/// `tokens['instanceUrl']['username']`
|
||||
@observable
|
||||
ObservableMap<String, ObservableMap<String, Jwt>> tokens;
|
||||
|
||||
/// default account for a given instance
|
||||
/// map where keys are instanceUrls and values are usernames
|
||||
@observable
|
||||
ObservableMap<String, String> _defaultAccounts;
|
||||
|
||||
/// default account for the app
|
||||
/// It is in a form of `username@instanceUrl`
|
||||
@observable
|
||||
String _defaultAccount;
|
||||
|
||||
@computed
|
||||
String get defaultUsername {
|
||||
if (_defaultAccount == null) {
|
||||
return null;
|
||||
|
@ -147,7 +113,6 @@ abstract class _AccountsStore with Store {
|
|||
return _defaultAccount.split('@')[0];
|
||||
}
|
||||
|
||||
@computed
|
||||
String get defaultInstanceUrl {
|
||||
if (_defaultAccount == null) {
|
||||
return null;
|
||||
|
@ -156,15 +121,14 @@ abstract class _AccountsStore with Store {
|
|||
return _defaultAccount.split('@')[1];
|
||||
}
|
||||
|
||||
String defaultUsernameFor(String instanceUrl) => Computed(() {
|
||||
if (isAnonymousFor(instanceUrl)) {
|
||||
return null;
|
||||
}
|
||||
String defaultUsernameFor(String instanceUrl) {
|
||||
if (isAnonymousFor(instanceUrl)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return _defaultAccounts[instanceUrl];
|
||||
}).value;
|
||||
return _defaultAccounts[instanceUrl];
|
||||
}
|
||||
|
||||
@computed
|
||||
Jwt get defaultToken {
|
||||
if (_defaultAccount == null) {
|
||||
return null;
|
||||
|
@ -174,44 +138,45 @@ abstract class _AccountsStore with Store {
|
|||
return tokens[userTag[1]][userTag[0]];
|
||||
}
|
||||
|
||||
Jwt defaultTokenFor(String instanceUrl) => Computed(() {
|
||||
if (isAnonymousFor(instanceUrl)) {
|
||||
return null;
|
||||
}
|
||||
Jwt defaultTokenFor(String instanceUrl) {
|
||||
if (isAnonymousFor(instanceUrl)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return tokens[instanceUrl][_defaultAccounts[instanceUrl]];
|
||||
}).value;
|
||||
return tokens[instanceUrl][_defaultAccounts[instanceUrl]];
|
||||
}
|
||||
|
||||
/// sets globally default account
|
||||
@action
|
||||
void setDefaultAccount(String instanceUrl, String username) {
|
||||
_defaultAccount = '$username@$instanceUrl';
|
||||
|
||||
notifyListeners();
|
||||
save();
|
||||
}
|
||||
|
||||
/// sets default account for given instance
|
||||
@action
|
||||
void setDefaultAccountFor(String instanceUrl, String username) {
|
||||
_defaultAccounts[instanceUrl] = username;
|
||||
|
||||
notifyListeners();
|
||||
save();
|
||||
}
|
||||
|
||||
/// An instance is considered anonymous if it was not
|
||||
/// added or there are no accounts assigned to it.
|
||||
bool isAnonymousFor(String instanceUrl) => Computed(() {
|
||||
if (!instances.contains(instanceUrl)) {
|
||||
return true;
|
||||
}
|
||||
bool isAnonymousFor(String instanceUrl) {
|
||||
if (!instances.contains(instanceUrl)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return tokens[instanceUrl].isEmpty;
|
||||
}).value;
|
||||
return tokens[instanceUrl].isEmpty;
|
||||
}
|
||||
|
||||
/// `true` if no added instance has an account assigned to it
|
||||
@computed
|
||||
bool get hasNoAccount => loggedInInstances.isEmpty;
|
||||
|
||||
@computed
|
||||
Iterable<String> get instances => tokens.keys;
|
||||
|
||||
@computed
|
||||
Iterable<String> get loggedInInstances =>
|
||||
instances.where((e) => !isAnonymousFor(e));
|
||||
|
||||
|
@ -220,7 +185,6 @@ abstract class _AccountsStore with Store {
|
|||
/// set as default for the app
|
||||
/// if it's the first account for an instance the account is
|
||||
/// set as default for that instance
|
||||
@action
|
||||
Future<void> addAccount(
|
||||
String instanceUrl,
|
||||
String usernameOrEmail,
|
||||
|
@ -240,12 +204,15 @@ abstract class _AccountsStore with Store {
|
|||
await lemmy.getSite(auth: token.raw).then((value) => value.myUser);
|
||||
|
||||
tokens[instanceUrl][userData.name] = token;
|
||||
|
||||
_assignDefaultAccounts();
|
||||
notifyListeners();
|
||||
save();
|
||||
}
|
||||
|
||||
/// adds a new instance with no accounts associated with it.
|
||||
/// Additionally makes a test `GET /site` request to check if the instance exists.
|
||||
/// Check is skipped when [assumeValid] is `true`
|
||||
@action
|
||||
Future<void> addInstance(
|
||||
String instanceUrl, {
|
||||
bool assumeValid = false,
|
||||
|
@ -263,17 +230,27 @@ abstract class _AccountsStore with Store {
|
|||
}
|
||||
}
|
||||
|
||||
tokens[instanceUrl] = ObservableMap();
|
||||
tokens[instanceUrl] = HashMap();
|
||||
|
||||
_assignDefaultAccounts();
|
||||
notifyListeners();
|
||||
save();
|
||||
}
|
||||
|
||||
/// This also removes all accounts assigned to this instance
|
||||
@action
|
||||
void removeInstance(String instanceUrl) {
|
||||
tokens.remove(instanceUrl);
|
||||
|
||||
_assignDefaultAccounts();
|
||||
notifyListeners();
|
||||
save();
|
||||
}
|
||||
|
||||
@action
|
||||
void removeAccount(String instanceUrl, String username) {
|
||||
tokens[instanceUrl].remove(username);
|
||||
|
||||
_assignDefaultAccounts();
|
||||
notifyListeners();
|
||||
save();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,187 +0,0 @@
|
|||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'accounts_store.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// StoreGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// ignore_for_file: non_constant_identifier_names, unnecessary_brace_in_string_interps, unnecessary_lambdas, prefer_expression_function_bodies, lines_longer_than_80_chars, avoid_as, avoid_annotating_with_dynamic
|
||||
|
||||
mixin _$AccountsStore on _AccountsStore, Store {
|
||||
Computed<String> _$defaultUsernameComputed;
|
||||
|
||||
@override
|
||||
String get defaultUsername => (_$defaultUsernameComputed ??= Computed<String>(
|
||||
() => super.defaultUsername,
|
||||
name: '_AccountsStore.defaultUsername'))
|
||||
.value;
|
||||
Computed<String> _$defaultInstanceUrlComputed;
|
||||
|
||||
@override
|
||||
String get defaultInstanceUrl => (_$defaultInstanceUrlComputed ??=
|
||||
Computed<String>(() => super.defaultInstanceUrl,
|
||||
name: '_AccountsStore.defaultInstanceUrl'))
|
||||
.value;
|
||||
Computed<Jwt> _$defaultTokenComputed;
|
||||
|
||||
@override
|
||||
Jwt get defaultToken =>
|
||||
(_$defaultTokenComputed ??= Computed<Jwt>(() => super.defaultToken,
|
||||
name: '_AccountsStore.defaultToken'))
|
||||
.value;
|
||||
Computed<bool> _$hasNoAccountComputed;
|
||||
|
||||
@override
|
||||
bool get hasNoAccount =>
|
||||
(_$hasNoAccountComputed ??= Computed<bool>(() => super.hasNoAccount,
|
||||
name: '_AccountsStore.hasNoAccount'))
|
||||
.value;
|
||||
Computed<Iterable<String>> _$instancesComputed;
|
||||
|
||||
@override
|
||||
Iterable<String> get instances =>
|
||||
(_$instancesComputed ??= Computed<Iterable<String>>(() => super.instances,
|
||||
name: '_AccountsStore.instances'))
|
||||
.value;
|
||||
Computed<Iterable<String>> _$loggedInInstancesComputed;
|
||||
|
||||
@override
|
||||
Iterable<String> get loggedInInstances => (_$loggedInInstancesComputed ??=
|
||||
Computed<Iterable<String>>(() => super.loggedInInstances,
|
||||
name: '_AccountsStore.loggedInInstances'))
|
||||
.value;
|
||||
|
||||
final _$tokensAtom = Atom(name: '_AccountsStore.tokens');
|
||||
|
||||
@override
|
||||
ObservableMap<String, ObservableMap<String, Jwt>> get tokens {
|
||||
_$tokensAtom.reportRead();
|
||||
return super.tokens;
|
||||
}
|
||||
|
||||
@override
|
||||
set tokens(ObservableMap<String, ObservableMap<String, Jwt>> value) {
|
||||
_$tokensAtom.reportWrite(value, super.tokens, () {
|
||||
super.tokens = value;
|
||||
});
|
||||
}
|
||||
|
||||
final _$_defaultAccountsAtom = Atom(name: '_AccountsStore._defaultAccounts');
|
||||
|
||||
@override
|
||||
ObservableMap<String, String> get _defaultAccounts {
|
||||
_$_defaultAccountsAtom.reportRead();
|
||||
return super._defaultAccounts;
|
||||
}
|
||||
|
||||
@override
|
||||
set _defaultAccounts(ObservableMap<String, String> value) {
|
||||
_$_defaultAccountsAtom.reportWrite(value, super._defaultAccounts, () {
|
||||
super._defaultAccounts = value;
|
||||
});
|
||||
}
|
||||
|
||||
final _$_defaultAccountAtom = Atom(name: '_AccountsStore._defaultAccount');
|
||||
|
||||
@override
|
||||
String get _defaultAccount {
|
||||
_$_defaultAccountAtom.reportRead();
|
||||
return super._defaultAccount;
|
||||
}
|
||||
|
||||
@override
|
||||
set _defaultAccount(String value) {
|
||||
_$_defaultAccountAtom.reportWrite(value, super._defaultAccount, () {
|
||||
super._defaultAccount = value;
|
||||
});
|
||||
}
|
||||
|
||||
final _$addAccountAsyncAction = AsyncAction('_AccountsStore.addAccount');
|
||||
|
||||
@override
|
||||
Future<void> addAccount(
|
||||
String instanceUrl, String usernameOrEmail, String password) {
|
||||
return _$addAccountAsyncAction
|
||||
.run(() => super.addAccount(instanceUrl, usernameOrEmail, password));
|
||||
}
|
||||
|
||||
final _$addInstanceAsyncAction = AsyncAction('_AccountsStore.addInstance');
|
||||
|
||||
@override
|
||||
Future<void> addInstance(String instanceUrl, {bool assumeValid = false}) {
|
||||
return _$addInstanceAsyncAction
|
||||
.run(() => super.addInstance(instanceUrl, assumeValid: assumeValid));
|
||||
}
|
||||
|
||||
final _$_AccountsStoreActionController =
|
||||
ActionController(name: '_AccountsStore');
|
||||
|
||||
@override
|
||||
void _assignDefaultAccounts() {
|
||||
final _$actionInfo = _$_AccountsStoreActionController.startAction(
|
||||
name: '_AccountsStore._assignDefaultAccounts');
|
||||
try {
|
||||
return super._assignDefaultAccounts();
|
||||
} finally {
|
||||
_$_AccountsStoreActionController.endAction(_$actionInfo);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void setDefaultAccount(String instanceUrl, String username) {
|
||||
final _$actionInfo = _$_AccountsStoreActionController.startAction(
|
||||
name: '_AccountsStore.setDefaultAccount');
|
||||
try {
|
||||
return super.setDefaultAccount(instanceUrl, username);
|
||||
} finally {
|
||||
_$_AccountsStoreActionController.endAction(_$actionInfo);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void setDefaultAccountFor(String instanceUrl, String username) {
|
||||
final _$actionInfo = _$_AccountsStoreActionController.startAction(
|
||||
name: '_AccountsStore.setDefaultAccountFor');
|
||||
try {
|
||||
return super.setDefaultAccountFor(instanceUrl, username);
|
||||
} finally {
|
||||
_$_AccountsStoreActionController.endAction(_$actionInfo);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void removeInstance(String instanceUrl) {
|
||||
final _$actionInfo = _$_AccountsStoreActionController.startAction(
|
||||
name: '_AccountsStore.removeInstance');
|
||||
try {
|
||||
return super.removeInstance(instanceUrl);
|
||||
} finally {
|
||||
_$_AccountsStoreActionController.endAction(_$actionInfo);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void removeAccount(String instanceUrl, String username) {
|
||||
final _$actionInfo = _$_AccountsStoreActionController.startAction(
|
||||
name: '_AccountsStore.removeAccount');
|
||||
try {
|
||||
return super.removeAccount(instanceUrl, username);
|
||||
} finally {
|
||||
_$_AccountsStoreActionController.endAction(_$actionInfo);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return '''
|
||||
tokens: ${tokens},
|
||||
defaultUsername: ${defaultUsername},
|
||||
defaultInstanceUrl: ${defaultInstanceUrl},
|
||||
defaultToken: ${defaultToken},
|
||||
hasNoAccount: ${hasNoAccount},
|
||||
instances: ${instances},
|
||||
loggedInInstances: ${loggedInInstances}
|
||||
''';
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue