feat: add push notification settings to user profile and update related functionality
All checks were successful
Chore App Build, Test, and Push Docker Images / build-and-push (push) Successful in 2m50s
All checks were successful
Chore App Build, Test, and Push Docker Images / build-and-push (push) Successful in 2m50s
This commit is contained in:
@@ -186,3 +186,25 @@ export async function isSubscribedToPush(): Promise<boolean> {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
/** localStorage key used to persist the user's explicit push opt-out across logins. */
|
||||
const PUSH_OPT_OUT_KEY = 'push_opt_out'
|
||||
|
||||
/**
|
||||
* Persist or clear the user's push opt-out preference in localStorage.
|
||||
* Call with `true` when the user disables push, `false` when they enable it.
|
||||
*/
|
||||
export function setPushOptOut(optOut: boolean): void {
|
||||
if (optOut) {
|
||||
localStorage.setItem(PUSH_OPT_OUT_KEY, '1')
|
||||
} else {
|
||||
localStorage.removeItem(PUSH_OPT_OUT_KEY)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the user has explicitly opted out of push notifications.
|
||||
*/
|
||||
export function isPushOptedOut(): boolean {
|
||||
return localStorage.getItem(PUSH_OPT_OUT_KEY) === '1'
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user