Move VAPID public key config to backend for easier config
Also enables the frontend not asking for notiffication permission if it doesn't need them. Should also help if it ever needs to be changed to circumvent cache.
This commit is contained in:
		
							
								
								
									
										14
									
								
								web/main.js
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								web/main.js
									
									
									
									
									
								
							@ -1,5 +1,3 @@
 | 
			
		||||
var pushServerPublicKey = 'BBwBPYxhogHLU3B1FpxfQNzO3q7qZpmD1n1KaaL8WJbcVmJSHhi1uB-VmvsVjjUHWYCeqKyLT7w-1LBfpIcbbcg'
 | 
			
		||||
 | 
			
		||||
var spage = document.getElementById('startpage')
 | 
			
		||||
var mform = document.getElementById('mainform')
 | 
			
		||||
 | 
			
		||||
@ -226,6 +224,18 @@ function initPush(name) {
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	fetch('/pushinfo').then(function(res) {
 | 
			
		||||
		if (res.ok)
 | 
			
		||||
			res.json().then(function(push) {
 | 
			
		||||
				if (push.enabled)
 | 
			
		||||
					registerPush(name, push.publickey);
 | 
			
		||||
			});
 | 
			
		||||
	});
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function registerPush(name, pushServerPublicKey) {
 | 
			
		||||
 | 
			
		||||
	// Register service worker
 | 
			
		||||
	navigator.serviceWorker.register("/sw.js").then(function(swRegistration) {
 | 
			
		||||
		console.log("ServiceWorker registered:", swRegistration)
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user