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' flutterVersionName = '1.0'
} }
//def appTitle = System.getenv('APP_TITLE') def appTitle = System.getenv('APP_TITLE')
def appTitle = "YWallet" //def appTitle = "YWallet"
apply plugin: 'com.android.application' apply plugin: 'com.android.application'
apply plugin: 'kotlin-android' apply plugin: 'kotlin-android'

View File

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

View File

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