server: use "dateFinished" for more accurate download completion notification

This commit is contained in:
Jesse Chan
2021-05-17 21:24:11 +08:00
parent 4e6d4136cb
commit 5f3144416d
2 changed files with 12 additions and 8 deletions
+2 -2
View File
@@ -58,14 +58,14 @@ class NotificationService extends BaseService<NotificationServiceEvents> {
* @param {Array<Notification>} notifications - Notifications to add
* @return {Promise<void>} - Rejects with error.
*/
async addNotification(notifications: Array<Pick<Notification, 'id' | 'data'>>): Promise<void> {
async addNotification(notifications: Array<Pick<Notification, 'id' | 'data'>>, ts = Date.now()): Promise<void> {
this.count.total += notifications.length;
this.count.unread += notifications.length;
await this.db
.insert(
notifications.map((notification) => ({
ts: Date.now(),
ts,
data: notification.data,
id: notification.id,
read: false,