-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: disable moe push preferences if no push token or push permissi…
…ons (#34)
- Loading branch information
Showing
3 changed files
with
38 additions
and
13 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// SPDX-License-Identifier: ice License 1.0 | ||
|
||
import {NotificationDeliveryChannel} from '@api/devices/types'; | ||
import {getFcmToken} from '@services/firebase'; | ||
import {store} from '@store/configureStore'; | ||
import {isPermissionGrantedSelector} from '@store/modules/Permissions/selectors'; | ||
|
||
export async function isPreferencesEnabled({ | ||
notificationDeliveryChannel, | ||
}: { | ||
notificationDeliveryChannel: NotificationDeliveryChannel; | ||
}) { | ||
if (notificationDeliveryChannel === 'push') { | ||
const hasPushPermissions = isPermissionGrantedSelector('pushNotifications')( | ||
store.getState(), | ||
); | ||
if (!hasPushPermissions) { | ||
return false; | ||
} | ||
const token = await getFcmToken(); | ||
if (!token) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} |
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