feat(notifications): add config for setting notification defaults

This commit is contained in:
Travis Shivers 2020-10-13 16:22:52 -05:00
parent a1cbcd9dd6
commit b962f35152
No known key found for this signature in database
GPG Key ID: EE4CC2891B8FCD33
4 changed files with 17 additions and 4 deletions

View File

@ -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,

View File

@ -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?

View File

@ -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,
};

View File

@ -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;