status update
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// pushSettingsUI.js - UI handling for push notification settings
|
||||
import { setupPushNotifications, forceCredentialsPrompt } from '../services/serviceWorkerManager.js';
|
||||
import { setupPushNotifications } from '../services/serviceWorkerManager.js';
|
||||
import { FLIC_BUTTON_ID } from '../config.js';
|
||||
|
||||
// --- DOM Elements ---
|
||||
@@ -265,7 +265,7 @@ async function unsubscribeFromPush() {
|
||||
}
|
||||
}
|
||||
|
||||
// Force subscription to push notifications
|
||||
// Subscribe to push notifications
|
||||
async function resubscribeToPush() {
|
||||
try {
|
||||
let username = elements.pushUsername.value.trim();
|
||||
@@ -291,8 +291,20 @@ async function resubscribeToPush() {
|
||||
}
|
||||
}
|
||||
|
||||
// Check if we have credentials, show alert if missing
|
||||
if (!username || !password) {
|
||||
console.log('No credentials available. Showing alert.');
|
||||
alert('Please enter your username and password to subscribe.');
|
||||
return;
|
||||
}
|
||||
|
||||
// Save the credentials to localStorage
|
||||
const credentials = { username, password };
|
||||
localStorage.setItem('basicAuthCredentials', JSON.stringify(credentials));
|
||||
console.log('Saved credentials to localStorage');
|
||||
|
||||
// Use the credentials to subscribe
|
||||
await forceCredentialsPrompt();
|
||||
await setupPushNotifications();
|
||||
|
||||
// Wait a moment for the subscription to complete
|
||||
await new Promise(resolve => setTimeout(resolve, 500));
|
||||
@@ -324,8 +336,6 @@ async function resubscribeToPush() {
|
||||
}
|
||||
// Fall back to the standard update function
|
||||
await updateSubscriptionStatus();
|
||||
|
||||
alert('Subscription failed. Please check your credentials and try again.');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error subscribing:', error);
|
||||
|
||||
Reference in New Issue
Block a user