Web app: Show "notifications not supported" alert on HTTP
This commit is contained in:
		
							parent
							
								
									cf0f002bfa
								
							
						
					
					
						commit
						feef15c485
					
				
					 4 changed files with 48 additions and 6 deletions
				
			
		| 
						 | 
				
			
			@ -74,8 +74,22 @@ class Notifier {
 | 
			
		|||
    }
 | 
			
		||||
 | 
			
		||||
    supported() {
 | 
			
		||||
        return this.browserSupported() && this.contextSupported();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    browserSupported() {
 | 
			
		||||
        return 'Notification' in window;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Returns true if this is a HTTPS site, or served over localhost. Otherwise the Notification API
 | 
			
		||||
     * is not supported, see https://developer.mozilla.org/en-US/docs/Web/API/notification
 | 
			
		||||
     */
 | 
			
		||||
    contextSupported() {
 | 
			
		||||
        return location.protocol === 'https:'
 | 
			
		||||
            || location.hostname.match('^127.')
 | 
			
		||||
            || location.hostname === 'localhost';
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const notifier = new Notifier();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue