mirror of
https://github.com/hyperspacedev/hyperspace
synced 2025-02-07 12:53:31 +01:00
Disable notification switch when user denies permissions
This commit is contained in:
parent
7671524475
commit
58826fc14b
@ -214,16 +214,18 @@ class SettingsPage extends Component<any, ISettingsState> {
|
||||
<ListItemText
|
||||
primary="Enable push notifications"
|
||||
secondary={
|
||||
getUserDefaultBool('userDeniedNotification')?
|
||||
"Check your browser's notification permissions.":
|
||||
browserSupportsNotificationRequests()?
|
||||
"":
|
||||
"Notifications aren't supported in this browser."
|
||||
"Your browser doesn't support notifications."
|
||||
}
|
||||
/>
|
||||
<ListItemSecondaryAction>
|
||||
<Switch
|
||||
checked={this.state.pushNotificationsEnabled}
|
||||
onChange={this.togglePushNotifications}
|
||||
disabled={!browserSupportsNotificationRequests()}
|
||||
disabled={!browserSupportsNotificationRequests() || getUserDefaultBool('userDeniedNotification')}
|
||||
/>
|
||||
</ListItemSecondaryAction>
|
||||
</ListItem>
|
||||
@ -234,7 +236,7 @@ class SettingsPage extends Component<any, ISettingsState> {
|
||||
<Paper className={classes.pageListConstraints}>
|
||||
<List>
|
||||
<ListItem>
|
||||
<ListItemText primary="Configure on Mastodon" secondary="Configure your account settings on Mastodon"/>
|
||||
<ListItemText primary="Configure on Mastodon"/>
|
||||
<ListItemSecondaryAction>
|
||||
<IconButton href={(localStorage.getItem("baseurl") as string) + "/settings/preferences"} target="_blank" rel="noreferrer">
|
||||
<OpenInNewIcon/>
|
||||
|
@ -9,8 +9,10 @@ export function getNotificationRequestPermission() {
|
||||
let request = Notification.permission;
|
||||
if (request === "granted") {
|
||||
setUserDefaultBool('enablePushNotifications', true);
|
||||
setUserDefaultBool('userDeniedNotification', false);
|
||||
} else {
|
||||
setUserDefaultBool('enablePushNotifications', false);
|
||||
setUserDefaultBool('userDeniedNotification', true);
|
||||
}
|
||||
} else {
|
||||
console.warn("Notifications aren't supported in this browser. The setting will be disabled.");
|
||||
|
Loading…
x
Reference in New Issue
Block a user