feat(templates): add logout link URL, hide in HTMX responses

This commit is contained in:
sankalp committed 2026-06-30 10:35:57 +05:45
1 parent 6781a11874
commit 3b0625a823
1 file changed
+5 -5
+5 -5
View File
@@ -293,12 +293,12 @@
return cookieValue; return cookieValue;
} }
{% if vapid_public_key %}
const vapidPublicKey = "{{ vapid_public_key }}";
function doPushSubscribe(reg) { function doPushSubscribe(reg) {
const vapidKey = "{{ vapid_public_key }}";
if (!vapidKey) return;
reg.pushManager.subscribe({ reg.pushManager.subscribe({
userVisibleOnly: true, userVisibleOnly: true,
applicationServerKey: vapidKey, applicationServerKey: vapidPublicKey,
}).then(sub => { }).then(sub => {
fetch('/api/notifications/push/subscribe/', { fetch('/api/notifications/push/subscribe/', {
method: 'POST', method: 'POST',
@@ -312,8 +312,7 @@
}).catch(() => {}); }).catch(() => {});
} }
const vapidPublicKey = "{{ vapid_public_key }}"; if ('serviceWorker' in navigator && 'PushManager' in window && Notification.permission !== 'denied') {
if (vapidPublicKey && 'serviceWorker' in navigator && 'PushManager' in window) {
navigator.serviceWorker.register('/sw.js').then(reg => { navigator.serviceWorker.register('/sw.js').then(reg => {
if (Notification.permission === 'granted') { if (Notification.permission === 'granted') {
doPushSubscribe(reg); doPushSubscribe(reg);
@@ -339,6 +338,7 @@
localStorage.setItem('push_declined', '1'); localStorage.setItem('push_declined', '1');
document.getElementById('push-prompt').classList.add('hidden'); document.getElementById('push-prompt').classList.add('hidden');
}; };
{% endif %}
</script> </script>
{% block extra_scripts %}{% endblock %} {% block extra_scripts %}{% endblock %}
</body> </body>