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