Compare commits
	
		
			3 Commits
		
	
	
		
			64f0da662b
			...
			2cdb601706
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 2cdb601706 | |||
| e84441e7f1 | |||
| 7ad67a80f5 | 
| @ -1,5 +1,5 @@ | ||||
| [tool.bumpversion] | ||||
| current_version = "1.3.52" | ||||
| current_version = "1.3.53" | ||||
| commit = true | ||||
| tag = true | ||||
| tag_name = "{new_version}" | ||||
|  | ||||
| @ -49,18 +49,35 @@ | ||||
|         <p>Version: <a href="#" id="version-link">{{ version }}</a></p> | ||||
|     </footer> | ||||
| 
 | ||||
|     <input type="hidden" id="is-logged-in" value="{{ 'true' if session.get('logged_in') else 'false' }}"> | ||||
|     <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script> | ||||
|     <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js"></script> | ||||
|     <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script> | ||||
|     {% block scripts %}{% endblock %} | ||||
|     <script> | ||||
|         if ('serviceWorker' in navigator && 'PushManager' in window) { | ||||
|             const isLoggedIn = document.getElementById('is-logged-in').value === 'true'; | ||||
|             navigator.serviceWorker.register('{{ url_for("static", filename="service-worker.js") }}').then(function(registration) { | ||||
|                 console.log('ServiceWorker registration successful with scope: ', registration.scope); | ||||
|                 // Check for the 'loggedin' query parameter to trigger the prompt | ||||
|                 const urlParams = new URLSearchParams(window.location.search); | ||||
|                 if (urlParams.has('loggedin')) { | ||||
|                 const enableNotificationsBtn = document.getElementById('enable-notifications-btn'); | ||||
| 
 | ||||
|                 function setupNotificationButton() { | ||||
|                     registration.pushManager.getSubscription().then(function(subscription) { | ||||
|                         if (enableNotificationsBtn) { | ||||
|                             if (subscription) { | ||||
|                                 enableNotificationsBtn.style.display = 'none'; | ||||
|                             } else { | ||||
|                                 enableNotificationsBtn.style.display = 'block'; | ||||
|                                 enableNotificationsBtn.addEventListener('click', function() { | ||||
|                                     askPermission(registration); | ||||
|                                 }); | ||||
|                             } | ||||
|                         } | ||||
|                     }); | ||||
|                 } | ||||
| 
 | ||||
|                 if (enableNotificationsBtn) { | ||||
|                     setupNotificationButton(); | ||||
|                 } | ||||
|             }, function(err) { | ||||
|                 console.log('ServiceWorker registration failed: ', err); | ||||
| @ -141,6 +158,10 @@ | ||||
|             .then(response => { | ||||
|                 if (response.ok) { | ||||
|                     console.log('Subscription saved successfully.'); | ||||
|                     const enableNotificationsBtn = document.getElementById('enable-notifications-btn'); | ||||
|                     if (enableNotificationsBtn) { | ||||
|                         enableNotificationsBtn.style.display = 'none'; | ||||
|                     } | ||||
|                     return response.json(); | ||||
|                 } else { | ||||
|                     console.error('Failed to save subscription. Status:', response.status); | ||||
|  | ||||
| @ -5,6 +5,9 @@ | ||||
| {% block content %} | ||||
|     <h1>Welcome {{ username }}!</h1> | ||||
|     <br> | ||||
|     <button id="enable-notifications-btn" class="btn btn-primary">Enable Notifications</button> | ||||
|     <br> | ||||
|     <br> | ||||
|     <h2>You have {{ accounts }} active accounts</h2> | ||||
|     <br> | ||||
|      | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user