Task DownloadTransactions(TransactionDownloadEvent <Transaction> downloadEvent) { AddIndexBefore = false; AddIndex = GetRow("Notes"); var rows = GetHeaderSectionRows("Notes"); IsBusy = false; foreach (var item in downloadEvent.Items) { if (!item.Result.Ok) { UIApp.Toast(Tr.Get("TransactionDownloadResult.DownloadFailed", item.ServiceNode.GetName())); } } var transactions = downloadEvent.GetSortedTransactions(TransactionSortMode.TimestampDescening); if (transactions.Count > 0 && _listView != null) { RemoveView(GetRow("Info")); RemoveView(GetRow("Add")); if (!UIAppSettings.AppReady) { UIAppSettings.AppReady = true; UIApp.Current.SaveSettings(); } _listView.Update(transactions); UIApp.Run(UpdateNotes); if (downloadEvent.HasMore) { if (_more == null) { _more = AddButtonRow("MoreButton", More); } } else { RemoveView(_more); _more = null; } } else { if (ServiceNodeManager.Current.HadUnlockedServiceNode && UIAppSettings.AppReady) { Toast("NoNotes"); } } return(Task.CompletedTask); }
Task AccountTransactionsDownloaded(TransactionDownloadEvent <Transaction> downloadedEvent) { AddIndexBefore = false; AddIndex = GetRow("RecentTransactions"); var rows = GetHeaderSectionRows("RecentTransactions"); var transactions = downloadedEvent.GetSortedTransactions(TransactionSortMode.TimestampDescening); if (transactions.Count > 0) { for (var i = 0; i < transactions.Count; i++) { var transaction = transactions[i]; var endpoint = transaction.Tag as ServiceNode; if (i < rows.Count && rows[i] is ButtonViewRow <VerifyTransactionView> button) { button.View.Update(transaction.Transaction as AttachementDataTransaction); button.RowLayout.SetAccentColor(endpoint.AccentColor); } else { button = AddButtonViewRow(new VerifyTransactionView(transaction.Transaction as AttachementDataTransaction), Select); button.RowLayout.SetAccentColor(endpoint.AccentColor); } button.Tag = transaction; AddIndex = button; } if (downloadedEvent.HasMore) { if (_more == null) { _more = AddButtonRow("MoreButton", More); } } else { RemoveView(_more); _more = null; } } else { Toast("NoTransactions"); } IsBusy = false; return(Task.CompletedTask); }
Task AccountTransactionsDownloaded(TransactionDownloadEvent <CoreOperation> downloadedEvent) { var section = GetRow <HeaderRow>("RecentTransactions"); if (section != null) { // Todo: Make it smarter and add transactions at the top / bottom ClearHeaderSection(section); AddIndex = section; if (downloadedEvent.Items.Count == 1 && downloadedEvent.Items[0].Download.Transactions.Count > 0) { var transactions = downloadedEvent.Items[0].Download.Transactions; var reversedKeys = transactions.Keys.Reverse(); foreach (var key in reversedKeys) { var t = transactions[key].Transaction; AddIndex = AddViewRow(new CoreOperationView(t, downloadedEvent.Items[0].Download.Id)); } if (downloadedEvent.Items[0].Result.More) { AddButtonRow("MoreButton", More); } } else { Toast("NoTransactions"); } } IsBusy = false; UpdateSuspendedLayout(); return(Task.CompletedTask); }
// TODO: Maybe add a timer to prevent refresh spamming public static async Task DownloadCoreAccountTransaction(bool queryOlder = false) { if (!HasCoreAccount) { return; } if (_busy) { return; } _busy = true; try { await _serviceNode.Client.SetTargetChain(Protocol.CoreChainId); if (_transactionDownload == null || _transactionDownload.AccountId != CurrentAccountId) { _transactionDownload = new CoreTransactionsDownload(CurrentAccountId, _serviceNode.GetTransactionDownloadManager(0)); } _transactionDownload.QueryOlder = queryOlder; var result = await _transactionDownload.DownloadTransactions(); var evt = new TransactionDownloadEvent <CoreOperation>(); evt.AddResult(result, _transactionDownload, null); await UIApp.PubSub.PublishAsync(evt); } catch (Exception ex) { Log.HandleException(ex); } _busy = false; }