Handle deletion of active account
This commit is contained in:
parent
3933ef021a
commit
e104c5427d
|
@ -28,6 +28,12 @@ class AccountManagerState extends State<AccountManagerPage> {
|
|||
showAboutOnce(this.context);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
active.updateAccount();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
|
|
|
@ -110,10 +110,9 @@ abstract class _AccountManager2 with Store {
|
|||
class ActiveAccount = _ActiveAccount with _$ActiveAccount;
|
||||
|
||||
abstract class _ActiveAccount with Store {
|
||||
@observable
|
||||
int dataEpoch = 0;
|
||||
@observable int dataEpoch = 0;
|
||||
|
||||
int coin = 0;
|
||||
@observable int coin = 0;
|
||||
int id = 0;
|
||||
|
||||
Account account = emptyAccount;
|
||||
|
@ -158,6 +157,7 @@ abstract class _ActiveAccount with Store {
|
|||
|
||||
@action
|
||||
Future<void> setActiveAccount(int _coin, int _id) async {
|
||||
print("setActiveAccount $_coin $_id");
|
||||
coin = _coin;
|
||||
id = _id;
|
||||
accounts.saveActive(coin, id);
|
||||
|
@ -189,6 +189,13 @@ abstract class _ActiveAccount with Store {
|
|||
await priceStore.updateChart();
|
||||
}
|
||||
|
||||
@action
|
||||
Future<void> updateAccount() async {
|
||||
final a = accounts.get(coin, id);
|
||||
if (a.id != active.id)
|
||||
await setActiveAccount(a.coin, a.id);
|
||||
}
|
||||
|
||||
@action
|
||||
void toggleShowTAddr() {
|
||||
showTAddr = !showTAddr;
|
||||
|
|
|
@ -9,6 +9,7 @@ import 'package:warp_api/warp_api.dart';
|
|||
import 'about.dart';
|
||||
import 'account.dart';
|
||||
import 'account_manager.dart';
|
||||
import 'accounts.dart';
|
||||
import 'budget.dart';
|
||||
import 'contact.dart';
|
||||
import 'history.dart';
|
||||
|
@ -65,6 +66,7 @@ class HomeState extends State<HomePage> {
|
|||
@override
|
||||
Widget build(BuildContext context) => Observer(builder: (context) {
|
||||
final _simpleMode = settings.simpleMode;
|
||||
final _dataEpoch = active.dataEpoch;
|
||||
final key = UniqueKey();
|
||||
return HomeInnerPage(key: key);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue