Skip to content
Snippets Groups Projects
Commit 647933c2 authored by vjrj's avatar vjrj
Browse files

Notifications with comments

parent efffa545
No related branches found
No related tags found
No related merge requests found
...@@ -158,11 +158,6 @@ class MultiWalletTransactionCubit ...@@ -158,11 +158,6 @@ class MultiWalletTransactionCubit
appCubit.setUd(newParsedState.currentUd!); appCubit.setUd(newParsedState.currentUd!);
} }
logger(
'Last received notification: ${newParsedState.latestReceivedNotification.toIso8601String()})}');
logger(
'Last sent notification: ${newParsedState.latestSentNotification.toIso8601String()})}');
// Check pending transactions // Check pending transactions
final TransactionState newState = final TransactionState newState =
_checkPendingTx(cursor, newParsedState, pubKey, node); _checkPendingTx(cursor, newParsedState, pubKey, node);
...@@ -170,6 +165,11 @@ class MultiWalletTransactionCubit ...@@ -170,6 +165,11 @@ class MultiWalletTransactionCubit
TransactionState currentModifiedState = newState; TransactionState currentModifiedState = newState;
logger(
'Last received notification: ${currentModifiedState.latestReceivedNotification.toIso8601String()})}');
logger(
'Last sent notification: ${currentModifiedState.latestSentNotification.toIso8601String()})}');
for (final Transaction tx in currentModifiedState.transactions.reversed) { for (final Transaction tx in currentModifiedState.transactions.reversed) {
bool stateModified = false; bool stateModified = false;
...@@ -181,6 +181,7 @@ class MultiWalletTransactionCubit ...@@ -181,6 +181,7 @@ class MultiWalletTransactionCubit
tx.time.millisecondsSinceEpoch.toString(), tx.time.millisecondsSinceEpoch.toString(),
amount: tx.amount, amount: tx.amount,
currentUd: appCubit.currentUd, currentUd: appCubit.currentUd,
comment: tx.comment,
from: from.title, from: from.title,
isG1: isG1); isG1: isG1);
currentModifiedState = currentModifiedState.copyWith( currentModifiedState = currentModifiedState.copyWith(
...@@ -196,6 +197,7 @@ class MultiWalletTransactionCubit ...@@ -196,6 +197,7 @@ class MultiWalletTransactionCubit
tx.time.millisecondsSinceEpoch.toString(), tx.time.millisecondsSinceEpoch.toString(),
amount: -tx.amount, amount: -tx.amount,
currentUd: appCubit.currentUd, currentUd: appCubit.currentUd,
comment: tx.comment,
to: to.title, to: to.title,
isG1: isG1); isG1: isG1);
currentModifiedState = currentModifiedState =
......
...@@ -144,31 +144,19 @@ class NotificationController { ...@@ -144,31 +144,19 @@ class NotificationController {
{required double amount, {required double amount,
String? to, String? to,
String? from, String? from,
String? description = '', String? comment = '',
required bool isG1, required bool isG1,
required double currentUd}) async { required double currentUd}) async {
final String title = from != null final String title = buildTxNotifTitle(from);
? tr('notification_new_payment_title') final String desc = buildTxNotifDescription(
: tr('notification_new_sent_title'); from: from,
final String desc = from != null to: to,
? '${tr('notification_new_payment_desc', namedArgs: <String, String>{ comment: comment,
'amount': formatKAmountInViewWithLocale( localeLanguageCode: locale.languageCode,
locale: locale.languageCode, amount: amount,
amount: amount, isG1: isG1,
isG1: isG1, currentUd: currentUd,
currentUd: currentUd, );
useSymbol: true),
'from': from,
})} ($description)'
: '${tr('notification_new_sent_desc', namedArgs: <String, String>{
'amount': formatKAmountInViewWithLocale(
locale: locale.languageCode,
amount: amount,
isG1: isG1,
currentUd: currentUd,
useSymbol: true),
'to': to!,
})} ($description)';
await notify(title: title, desc: desc, id: id); await notify(title: title, desc: desc, id: id);
} }
......
...@@ -97,29 +97,17 @@ class NotificationController { ...@@ -97,29 +97,17 @@ class NotificationController {
String? description = '', String? description = '',
required double currentUd, required double currentUd,
required bool isG1}) async { required bool isG1}) async {
// FIXME: DUP CODE!! final String title = buildTxNotifTitle(from);
final String title = from != null final String desc = buildTxNotifDescription(
? tr('notification_new_payment_title') from: from,
: tr('notification_new_sent_title'); to: to,
final String desc = from != null comment: description,
? '${tr('notification_new_payment_desc', namedArgs: <String, String>{ localeLanguageCode: locale.languageCode,
'amount': formatKAmountInViewWithLocale( amount: amount,
locale: locale.languageCode, isG1: isG1,
amount: amount, currentUd: currentUd,
isG1: isG1, );
currentUd: currentUd,
useSymbol: true),
'from': from,
})} ($description)'
: '${tr('notification_new_sent_desc', namedArgs: <String, String>{
'amount': formatKAmountInViewWithLocale(
locale: locale.languageCode,
amount: amount,
isG1: isG1,
currentUd: currentUd,
useSymbol: true),
'to': to!
})} ($description)';
await notify(title: title, desc: desc, id: ''); await notify(title: title, desc: desc, id: '');
} }
......
...@@ -655,3 +655,37 @@ Future<void> hydratedInit() async { ...@@ -655,3 +655,37 @@ Future<void> hydratedInit() async {
await HydratedStorage.build(storageDirectory: tmpDir); await HydratedStorage.build(storageDirectory: tmpDir);
} }
} }
String buildTxNotifTitle(String? from) {
final String title = from != null
? tr('notification_new_payment_title')
: tr('notification_new_sent_title');
return title;
}
String buildTxNotifDescription({
required String? from,
required String? to,
required String? comment,
required String localeLanguageCode,
required double amount,
required bool isG1,
required double currentUd,
}) {
final String formattedAmount = formatKAmountInViewWithLocale(
locale: localeLanguageCode,
amount: amount,
isG1: isG1,
currentUd: currentUd,
useSymbol: true,
);
final String desc = from != null
? tr('notification_new_payment_desc', namedArgs: <String, String>{
'amount': formattedAmount,
'from': from,
})
: tr('notification_new_sent_desc',
namedArgs: <String, String>{'amount': formattedAmount, 'to': to!});
return comment != null && comment.isNotEmpty ? '$desc ($comment)' : desc;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment