forked from lavender/watch-party
		
	make pings send browser notifications
This commit is contained in:
		
							parent
							
								
									2197d2b757
								
							
						
					
					
						commit
						9a2ac1c432
					
				
					 1 changed files with 17 additions and 0 deletions
				
			
		|  | @ -416,6 +416,23 @@ export const logEventToChat = async (event) => { | ||||||
| 
 | 
 | ||||||
|       printChatMessage("ping", event.user, event.colour, messageContent); |       printChatMessage("ping", event.user, event.colour, messageContent); | ||||||
|       beep(); |       beep(); | ||||||
|  |       if ("Notification" in window) { | ||||||
|  |         const title = "watch party :)"; | ||||||
|  |         const options = { | ||||||
|  |           body: event.data | ||||||
|  |             ? `${event.user} pinged saying: ${event.data}` | ||||||
|  |             : `${event.user} pinged`, | ||||||
|  |         }; | ||||||
|  |         if (Notification.permission === "granted") { | ||||||
|  |           new Notification(title, options); | ||||||
|  |         } else if (Notification.permission !== "denied") { | ||||||
|  |           Notification.requestPermission().then(function (permission) { | ||||||
|  |             if (permission === "granted") { | ||||||
|  |               new Notification(title, options); | ||||||
|  |             } | ||||||
|  |           }); | ||||||
|  |         } | ||||||
|  |       } | ||||||
|       break; |       break; | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue