Optimize data refresh

This commit is contained in:
Hanh 2022-03-29 14:54:32 +08:00
parent e104c5427d
commit 58dc77aab6
6 changed files with 8 additions and 7 deletions

View File

@ -157,7 +157,6 @@ 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);
@ -228,6 +227,7 @@ abstract class _ActiveAccount with Store {
@computed
List<Note> get sortedNotes {
final _1 = syncStatus.syncedHeight;
var notes2 = [...notes];
switch (noteSortConfig.field) {
case "time":
@ -240,6 +240,7 @@ abstract class _ActiveAccount with Store {
@computed
List<Tx> get sortedTxs {
final _1 = syncStatus.syncedHeight;
var txs2 = [...txs];
switch (txSortConfig.field) {
case "time":

View File

@ -25,6 +25,7 @@ class HistoryState extends State<HistoryWidget>
padding: EdgeInsets.all(4),
scrollDirection: Axis.vertical,
child: Observer(builder: (context) {
final _1 = active.sortedTxs;
return PaginatedDataTable(
header: Text(S.of(context).tapTransactionForDetails, style: Theme.of(context).textTheme.bodyText2),
actions: [

View File

@ -66,7 +66,6 @@ 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);
});

View File

@ -25,7 +25,7 @@ class _NoteState extends State<NoteWidget> with AutomaticKeepAliveClientMixin {
padding: EdgeInsets.all(8),
scrollDirection: Axis.vertical,
child: Observer(builder: (context) {
active.sortedNotes;
final _1 = active.sortedNotes;
return PaginatedDataTable(
columns: [
DataColumn(

View File

@ -460,7 +460,8 @@ abstract class _SyncStatus with Store {
@action
setSyncHeight(int? height) {
syncedHeight = height;
if (height == null || syncedHeight != height)
syncedHeight = height;
}
@action
@ -480,8 +481,7 @@ abstract class _SyncStatus with Store {
latestHeight = await WarpApi.getLatestHeight(active.coin);
final _syncedHeight = await getDbSyncedHeight();
// if syncedHeight = 0, we just started sync therefore don't set it back to null
if (syncedHeight != 0 || _syncedHeight != null) setSyncHeight(
_syncedHeight);
if (syncedHeight != 0 || _syncedHeight != null) setSyncHeight(_syncedHeight);
return latestHeight > 0 && syncedHeight == latestHeight;
}

View File

@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.2.1+207
version: 1.2.1+208
environment:
sdk: ">=2.12.0 <3.0.0"