gearheads
/
mastodon
Archived
2
0
Fork 0

Fix notification permissions being requested immediately after login (#26472)

gh/dev^2
Claire 2023-09-12 18:27:01 +02:00 committed by GitHub
parent 287520453c
commit 520b570474
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View File

@ -18,6 +18,7 @@ import {
importFetchedStatuses,
} from './importer';
import { submitMarkers } from './markers';
import { register as registerPushNotifications } from './push_notifications';
import { saveSettings } from './settings';
export const NOTIFICATIONS_UPDATE = 'NOTIFICATIONS_UPDATE';
@ -293,6 +294,10 @@ export function requestBrowserPermission(callback = noOp) {
requestNotificationPermission((permission) => {
dispatch(setBrowserPermission(permission));
callback(permission);
if (permission === 'granted') {
dispatch(registerPushNotifications());
}
});
};
}

View File

@ -33,7 +33,7 @@ function main() {
console.error(err);
}
if (registration) {
if (registration && 'Notification' in window && Notification.permission === 'granted') {
const registerPushNotifications = await import('mastodon/actions/push_notifications');
store.dispatch(registerPushNotifications.register());