Exclude notes in flight

This commit is contained in:
Hanh 2021-08-14 16:02:30 +08:00
parent 2824650f14
commit 8c897ca1a8
3 changed files with 16 additions and 11 deletions

View File

@ -27,8 +27,8 @@ if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
//def appTitle = System.getenv('APP_TITLE')
def appTitle = "YWallet"
def appTitle = System.getenv('APP_TITLE')
//def appTitle = "YWallet"
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'

View File

@ -572,6 +572,11 @@ class NotesDataSource extends DataTableSource {
final confsOrHeight = settings.showConfirmations
? syncStatus.latestHeight - note.height + 1
: note.height;
var style = _confirmed(note.height) ? theme.textTheme.bodyText2 : theme.textTheme.overline;
if (note.spent)
style = style.merge(TextStyle(decoration: TextDecoration.lineThrough));
return DataRow.byIndex(
index: index,
selected: note.excluded,
@ -581,11 +586,9 @@ class NotesDataSource extends DataTableSource {
: theme.backgroundColor),
cells: [
DataCell(Text("$confsOrHeight",
style: !_confirmed(note.height)
? Theme.of(this.context).textTheme.overline
: null)),
DataCell(Text("${note.timestamp}")),
DataCell(Text("${note.value.toStringAsFixed(8)}")),
style: style)),
DataCell(Text("${note.timestamp}", style: style)),
DataCell(Text("${note.value.toStringAsFixed(8)}", style: style)),
],
onSelectChanged: (selected) => _noteSelected(note, selected),
);

View File

@ -332,7 +332,7 @@ abstract class _AccountManager with Store {
Future<int> getBalanceSpendable(int height) async {
final List<Map> res = await db.rawQuery(
"SELECT SUM(value) AS value FROM received_notes WHERE account = ?1 AND (spent IS NULL OR spent = 0) "
"SELECT SUM(value) AS value FROM received_notes WHERE account = ?1 AND spent IS NULL "
"AND height <= ?2 AND (excluded IS NULL OR NOT excluded)",
[active.id, height]);
if (res.isEmpty) return 0;
@ -417,7 +417,7 @@ abstract class _AccountManager with Store {
Future<void> _fetchNotesAndHistory(int accountId) async {
await _updateBalance(accountId);
final List<Map> res = await db.rawQuery(
"SELECT n.id_note, n.height, n.value, t.timestamp, n.excluded FROM received_notes n, transactions t "
"SELECT n.id_note, n.height, n.value, t.timestamp, n.excluded, n.spent FROM received_notes n, transactions t "
"WHERE n.account = ?1 AND (n.spent IS NULL OR n.spent = 0) "
"AND n.tx = t.id_tx",
[accountId]);
@ -427,7 +427,8 @@ abstract class _AccountManager with Store {
final timestamp = noteDateFormat
.format(DateTime.fromMillisecondsSinceEpoch(row['timestamp'] * 1000));
final excluded = (row['excluded'] ?? 0) != 0;
return Note(id, height, timestamp, row['value'] / ZECUNIT, excluded);
final spent = row['spent'] == 0;
return Note(id, height, timestamp, row['value'] / ZECUNIT, excluded, spent);
}).toList();
_sortNoteAmount(noteSortOrder);
@ -682,8 +683,9 @@ class Note {
String timestamp;
double value;
bool excluded;
bool spent;
Note(this.id, this.height, this.timestamp, this.value, this.excluded);
Note(this.id, this.height, this.timestamp, this.value, this.excluded, this.spent);
}
class Tx {