Mute button
This commit is contained in:
		
							parent
							
								
									d3462d2905
								
							
						
					
					
						commit
						60980df26b
					
				
					 4 changed files with 35 additions and 21 deletions
				
			
		|  | @ -22,7 +22,7 @@ class Notifier { | |||
|         if (notification.click) { | ||||
|             n.onclick = (e) => openUrl(notification.click); | ||||
|         } else { | ||||
|             n.onclick = onClickFallback; | ||||
|             n.onclick = () => onClickFallback(subscription); | ||||
|         } | ||||
| 
 | ||||
|         // Play sound
 | ||||
|  | @ -51,6 +51,9 @@ class Notifier { | |||
|     } | ||||
| 
 | ||||
|     async shouldNotify(subscription, notification) { | ||||
|         if (subscription.mutedUntil === 1) { | ||||
|             return false; | ||||
|         } | ||||
|         const priority = (notification.priority) ? notification.priority : 3; | ||||
|         const minPriority = await prefs.minPriority(); | ||||
|         if (priority < minPriority) { | ||||
|  |  | |||
|  | @ -23,6 +23,7 @@ class SubscriptionManager { | |||
|             baseUrl: baseUrl, | ||||
|             topic: topic, | ||||
|             ephemeral: ephemeral, | ||||
|             mutedUntil: 0, | ||||
|             last: null | ||||
|         }; | ||||
|         await db.subscriptions.put(subscription); | ||||
|  | @ -108,6 +109,12 @@ class SubscriptionManager { | |||
|             .modify({new: 0}); | ||||
|     } | ||||
| 
 | ||||
|     async setMutedUntil(subscriptionId, mutedUntil) { | ||||
|         await db.subscriptions.update(subscriptionId, { | ||||
|             mutedUntil: mutedUntil | ||||
|         }); | ||||
|     } | ||||
| 
 | ||||
|     async pruneNotifications(thresholdTimestamp) { | ||||
|         await db.notifications | ||||
|             .where("time").below(thresholdTimestamp) | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue