forked from mastodon/mastodon
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Disable push notification when not logged in (mastodon#19272)
- Loading branch information
Showing
5 changed files
with
75 additions
and
48 deletions.
There are no files selected for viewing
26 changes: 10 additions & 16 deletions
26
app/javascript/mastodon/actions/push_notifications/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,17 @@ | ||
import { | ||
SET_BROWSER_SUPPORT, | ||
SET_SUBSCRIPTION, | ||
CLEAR_SUBSCRIPTION, | ||
SET_ALERTS, | ||
setAlerts, | ||
} from './setter'; | ||
import { register, saveSettings } from './registerer'; | ||
|
||
export { | ||
SET_BROWSER_SUPPORT, | ||
SET_SUBSCRIPTION, | ||
CLEAR_SUBSCRIPTION, | ||
SET_ALERTS, | ||
register, | ||
}; | ||
import { setAlerts } from './setter'; | ||
import { saveSettings } from './registerer'; | ||
|
||
export function changeAlerts(path, value) { | ||
return dispatch => { | ||
dispatch(setAlerts(path, value)); | ||
dispatch(saveSettings()); | ||
}; | ||
} | ||
|
||
export { | ||
CLEAR_SUBSCRIPTION, | ||
SET_BROWSER_SUPPORT, | ||
SET_SUBSCRIPTION, | ||
SET_ALERTS, | ||
} from './setter'; | ||
export { register } from './registerer'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,32 @@ | ||
export default function ready(loaded) { | ||
if (['interactive', 'complete'].includes(document.readyState)) { | ||
loaded(); | ||
} else { | ||
document.addEventListener('DOMContentLoaded', loaded); | ||
} | ||
// @ts-check | ||
|
||
/** | ||
* @param {(() => void) | (() => Promise<void>)} callback | ||
* @returns {Promise<void>} | ||
*/ | ||
export default function ready(callback) { | ||
return new Promise((resolve, reject) => { | ||
function loaded() { | ||
let result; | ||
try { | ||
result = callback(); | ||
} catch (err) { | ||
reject(err); | ||
|
||
return; | ||
} | ||
|
||
if (typeof result?.then === 'function') { | ||
result.then(resolve).catch(reject); | ||
} else { | ||
resolve(); | ||
} | ||
} | ||
|
||
if (['interactive', 'complete'].includes(document.readyState)) { | ||
loaded(); | ||
} else { | ||
document.addEventListener('DOMContentLoaded', loaded); | ||
} | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters