Fix notification permissions being requested immediately after login (#26472)
This commit is contained in:
		
							parent
							
								
									287520453c
								
							
						
					
					
						commit
						520b570474
					
				@ -18,6 +18,7 @@ import {
 | 
				
			|||||||
  importFetchedStatuses,
 | 
					  importFetchedStatuses,
 | 
				
			||||||
} from './importer';
 | 
					} from './importer';
 | 
				
			||||||
import { submitMarkers } from './markers';
 | 
					import { submitMarkers } from './markers';
 | 
				
			||||||
 | 
					import { register as registerPushNotifications } from './push_notifications';
 | 
				
			||||||
import { saveSettings } from './settings';
 | 
					import { saveSettings } from './settings';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const NOTIFICATIONS_UPDATE      = 'NOTIFICATIONS_UPDATE';
 | 
					export const NOTIFICATIONS_UPDATE      = 'NOTIFICATIONS_UPDATE';
 | 
				
			||||||
@ -293,6 +294,10 @@ export function requestBrowserPermission(callback = noOp) {
 | 
				
			|||||||
    requestNotificationPermission((permission) => {
 | 
					    requestNotificationPermission((permission) => {
 | 
				
			||||||
      dispatch(setBrowserPermission(permission));
 | 
					      dispatch(setBrowserPermission(permission));
 | 
				
			||||||
      callback(permission);
 | 
					      callback(permission);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      if (permission === 'granted') {
 | 
				
			||||||
 | 
					        dispatch(registerPushNotifications());
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
  };
 | 
					  };
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -33,7 +33,7 @@ function main() {
 | 
				
			|||||||
        console.error(err);
 | 
					        console.error(err);
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      if (registration) {
 | 
					      if (registration && 'Notification' in window && Notification.permission === 'granted') {
 | 
				
			||||||
        const registerPushNotifications = await import('mastodon/actions/push_notifications');
 | 
					        const registerPushNotifications = await import('mastodon/actions/push_notifications');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        store.dispatch(registerPushNotifications.register());
 | 
					        store.dispatch(registerPushNotifications.register());
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user