mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-21 18:24:41 +00:00
only one notification
This commit is contained in:
parent
699e8e3c8f
commit
f4f2678f1e
1 changed files with 36 additions and 20 deletions
|
@ -31,7 +31,7 @@ const initialNotificationTitle = 'Cake Background Sync';
|
||||||
const standbyMessage = 'On standby - app is in the foreground';
|
const standbyMessage = 'On standby - app is in the foreground';
|
||||||
const readyMessage = 'Ready to sync - waiting until the app has been in the background for a while';
|
const readyMessage = 'Ready to sync - waiting until the app has been in the background for a while';
|
||||||
const startMessage = 'Starting sync - app is in the background';
|
const startMessage = 'Starting sync - app is in the background';
|
||||||
|
const allWalletsSyncedMessage = 'All wallets synced - waiting for next queue refresh';
|
||||||
const notificationId = 888;
|
const notificationId = 888;
|
||||||
const notificationChannelId = 'cake_service';
|
const notificationChannelId = 'cake_service';
|
||||||
const notificationChannelName = 'CAKE BACKGROUND SERVICE';
|
const notificationChannelName = 'CAKE BACKGROUND SERVICE';
|
||||||
|
@ -93,6 +93,15 @@ void setNotificationStarting(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setNotificationWalletsSynced(FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin) async {
|
||||||
|
flutterLocalNotificationsPlugin.cancelAll();
|
||||||
|
setMainNotification(
|
||||||
|
flutterLocalNotificationsPlugin,
|
||||||
|
title: initialNotificationTitle,
|
||||||
|
content: allWalletsSyncedMessage,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
void setWalletNotification(FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin,
|
void setWalletNotification(FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin,
|
||||||
{required String title, required String content, required int walletNum}) async {
|
{required String title, required String content, required int walletNum}) async {
|
||||||
flutterLocalNotificationsPlugin.show(
|
flutterLocalNotificationsPlugin.show(
|
||||||
|
@ -274,6 +283,11 @@ Future<void> onStart(ServiceInstance service) async {
|
||||||
// pop the first wallet from the list
|
// pop the first wallet from the list
|
||||||
standbyWallets.add(syncingWallets.removeAt(i));
|
standbyWallets.add(syncingWallets.removeAt(i));
|
||||||
flutterLocalNotificationsPlugin.cancelAll();
|
flutterLocalNotificationsPlugin.cancelAll();
|
||||||
|
|
||||||
|
// if all wallets are synced, show a one time notification saying so:
|
||||||
|
if (syncingWallets.isEmpty) {
|
||||||
|
setNotificationWalletsSynced(flutterLocalNotificationsPlugin);
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -312,8 +326,9 @@ Future<void> onStart(ServiceInstance service) async {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
content += " - ${DateFormat("hh:mm:ss").format(DateTime.now())}";
|
// content += " - ${DateFormat("hh:mm:ss").format(DateTime.now())}";
|
||||||
|
|
||||||
|
if (i == 0) {
|
||||||
setWalletNotification(
|
setWalletNotification(
|
||||||
flutterLocalNotificationsPlugin,
|
flutterLocalNotificationsPlugin,
|
||||||
title: title,
|
title: title,
|
||||||
|
@ -321,20 +336,21 @@ Future<void> onStart(ServiceInstance service) async {
|
||||||
walletNum: i,
|
walletNum: i,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < standbyWallets.length; i++) {
|
|
||||||
int notificationIndex = syncingWallets.length + i + 1;
|
|
||||||
final wallet = standbyWallets[i];
|
|
||||||
final title = "${walletTypeToCryptoCurrency(wallet.type).title} - ${wallet.name}";
|
|
||||||
String content = "Synced - on standby until next queue refresh";
|
|
||||||
|
|
||||||
setWalletNotification(
|
|
||||||
flutterLocalNotificationsPlugin,
|
|
||||||
title: title,
|
|
||||||
content: content,
|
|
||||||
walletNum: notificationIndex,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// for (int i = 0; i < standbyWallets.length; i++) {
|
||||||
|
// int notificationIndex = syncingWallets.length + i + 1;
|
||||||
|
// final wallet = standbyWallets[i];
|
||||||
|
// final title = "${walletTypeToCryptoCurrency(wallet.type).title} - ${wallet.name}";
|
||||||
|
// String content = "Synced - on standby until next queue refresh";
|
||||||
|
|
||||||
|
// setWalletNotification(
|
||||||
|
// flutterLocalNotificationsPlugin,
|
||||||
|
// title: title,
|
||||||
|
// content: content,
|
||||||
|
// walletNum: notificationIndex,
|
||||||
|
// );
|
||||||
|
// }
|
||||||
});
|
});
|
||||||
|
|
||||||
_queueTimer?.cancel();
|
_queueTimer?.cancel();
|
||||||
|
|
Loading…
Reference in a new issue