feat(notifications): add config for setting notification defaults
This commit is contained in:
parent
a1cbcd9dd6
commit
b962f35152
|
@ -49,6 +49,8 @@ const defaults = {
|
|||
|
||||
default_party_pause_enabled: true,
|
||||
default_auto_host_enabled: false,
|
||||
default_are_notification_enabled: false,
|
||||
default_are_sound_notification_enabled: false,
|
||||
|
||||
force_slplayer: false,
|
||||
|
||||
|
|
|
@ -420,6 +420,13 @@ export default {
|
|||
}
|
||||
|
||||
if (getters.ARE_NOTIFICATIONS_ENABLED) {
|
||||
if (Notification.permission !== 'granted') {
|
||||
const permission = await Notification.requestPermission();
|
||||
if (permission !== 'granted') {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const { username, thumb } = getters.GET_MESSAGES_USER_CACHE_USER(msg.senderId);
|
||||
|
||||
// TODO: notifications don't work when on http. Maybe make alternative popup thing?
|
||||
|
|
|
@ -84,7 +84,11 @@ export default {
|
|||
|
||||
GET_UP_NEXT_TRIGGERED: (state) => state.upNextTriggered,
|
||||
|
||||
ARE_NOTIFICATIONS_ENABLED: (state) => state.areNotificationsEnabled,
|
||||
ARE_NOTIFICATIONS_ENABLED: (state, getters, rootState, rootGetters) => state
|
||||
.areNotificationsEnabled
|
||||
?? rootGetters.GET_CONFIG?.default_are_notification_enabled,
|
||||
|
||||
ARE_SOUND_NOTIFICATIONS_ENABLED: (state) => state.areSoundNotificationsEnabled,
|
||||
ARE_SOUND_NOTIFICATIONS_ENABLED: (state, getters, rootState, rootGetters) => state
|
||||
.areSoundNotificationsEnabled
|
||||
?? rootGetters.GET_CONFIG?.default_are_sound_notification_enabled,
|
||||
};
|
||||
|
|
|
@ -18,8 +18,8 @@ const state = () => ({
|
|||
// This tracks whether the upnext screen was triggered for this playback already.
|
||||
// It is reset to false when the player gets out of the upNext time zone (at the end of episode)
|
||||
upNextTriggered: false,
|
||||
areNotificationsEnabled: false,
|
||||
areSoundNotificationsEnabled: false,
|
||||
areNotificationsEnabled: null,
|
||||
areSoundNotificationsEnabled: null,
|
||||
});
|
||||
|
||||
export default state;
|
||||
|
|
Loading…
Reference in New Issue