Fix saving of notification settings
This commit is contained in:
committed by
Massedil
parent
63d44ce4db
commit
bcbc5acf67
@@ -104,7 +104,7 @@
|
|||||||
>
|
>
|
||||||
<o-select
|
<o-select
|
||||||
v-model="groupNotifications"
|
v-model="groupNotifications"
|
||||||
@update:modelValue="updateSetting({ groupNotifications })"
|
@update:modelValue="updateSetting(updatedSettings)"
|
||||||
id="groupNotifications"
|
id="groupNotifications"
|
||||||
>
|
>
|
||||||
<option
|
<option
|
||||||
@@ -132,7 +132,7 @@
|
|||||||
<div class="field">
|
<div class="field">
|
||||||
<o-checkbox
|
<o-checkbox
|
||||||
v-model="notificationOnDay"
|
v-model="notificationOnDay"
|
||||||
@input="updateSetting({ notificationOnDay })"
|
@update:modelValue="updateSetting(updatedSettings)"
|
||||||
>
|
>
|
||||||
<strong>{{ $t("Notification on the day of the event") }}</strong>
|
<strong>{{ $t("Notification on the day of the event") }}</strong>
|
||||||
<p>
|
<p>
|
||||||
@@ -162,7 +162,7 @@
|
|||||||
<div class="field">
|
<div class="field">
|
||||||
<o-checkbox
|
<o-checkbox
|
||||||
v-model="notificationEachWeek"
|
v-model="notificationEachWeek"
|
||||||
@input="updateSetting({ notificationEachWeek })"
|
@update:modelValue="updateSetting(updatedSettings)"
|
||||||
>
|
>
|
||||||
<strong>{{ $t("Recap every week") }}</strong>
|
<strong>{{ $t("Recap every week") }}</strong>
|
||||||
<p>
|
<p>
|
||||||
@@ -177,7 +177,7 @@
|
|||||||
<div class="field">
|
<div class="field">
|
||||||
<o-checkbox
|
<o-checkbox
|
||||||
v-model="notificationBeforeEvent"
|
v-model="notificationBeforeEvent"
|
||||||
@input="updateSetting({ notificationBeforeEvent })"
|
@update:modelValue="updateSetting(updatedSettings)"
|
||||||
>
|
>
|
||||||
<strong>{{ $t("Notification before the event") }}</strong>
|
<strong>{{ $t("Notification before the event") }}</strong>
|
||||||
<p>
|
<p>
|
||||||
@@ -210,7 +210,7 @@
|
|||||||
<o-select
|
<o-select
|
||||||
v-model="notificationPendingParticipation"
|
v-model="notificationPendingParticipation"
|
||||||
id="notificationPendingParticipation"
|
id="notificationPendingParticipation"
|
||||||
@input="updateSetting({ notificationPendingParticipation })"
|
@update:modelValue="updateSetting(updatedSettings)"
|
||||||
>
|
>
|
||||||
<option
|
<option
|
||||||
v-for="(value, key) in notificationPendingParticipationValues"
|
v-for="(value, key) in notificationPendingParticipationValues"
|
||||||
@@ -329,6 +329,7 @@ import {
|
|||||||
IActivitySetting,
|
IActivitySetting,
|
||||||
IActivitySettingMethod,
|
IActivitySettingMethod,
|
||||||
IUser,
|
IUser,
|
||||||
|
IUserSettings,
|
||||||
} from "../../types/current-user.model";
|
} from "../../types/current-user.model";
|
||||||
import RouteName from "../../router/name";
|
import RouteName from "../../router/name";
|
||||||
import { IFeedToken } from "@/types/feedtoken.model";
|
import { IFeedToken } from "@/types/feedtoken.model";
|
||||||
@@ -615,6 +616,15 @@ const notificationValues = computed(
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const updatedSettings = computed(() => ({
|
||||||
|
...loggedUser.value?.settings,
|
||||||
|
notificationOnDay: notificationOnDay.value,
|
||||||
|
notificationEachWeek: notificationEachWeek.value,
|
||||||
|
notificationBeforeEvent: notificationBeforeEvent.value,
|
||||||
|
notificationPendingParticipation: notificationPendingParticipation.value,
|
||||||
|
groupNotifications: groupNotifications.value,
|
||||||
|
}));
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
notificationPendingParticipationValues.value = {
|
notificationPendingParticipationValues.value = {
|
||||||
[INotificationPendingEnum.NONE]: t("Do not receive any mail"),
|
[INotificationPendingEnum.NONE]: t("Do not receive any mail"),
|
||||||
@@ -631,24 +641,29 @@ onMounted(async () => {
|
|||||||
[INotificationPendingEnum.ONE_WEEK]: t("Weekly email summary"),
|
[INotificationPendingEnum.ONE_WEEK]: t("Weekly email summary"),
|
||||||
};
|
};
|
||||||
canShowWebPush.value = await checkCanShowWebPush();
|
canShowWebPush.value = await checkCanShowWebPush();
|
||||||
|
setNotificationSettings(loggedUser.value?.settings);
|
||||||
});
|
});
|
||||||
|
|
||||||
watch(loggedUser, () => {
|
watch(loggedUser, () => {
|
||||||
if (loggedUser.value?.settings) {
|
if (loggedUser.value?.settings) {
|
||||||
notificationOnDay.value = loggedUser.value.settings.notificationOnDay;
|
setNotificationSettings(loggedUser.value?.settings);
|
||||||
notificationEachWeek.value = loggedUser.value.settings.notificationEachWeek;
|
|
||||||
notificationBeforeEvent.value =
|
|
||||||
loggedUser.value.settings.notificationBeforeEvent;
|
|
||||||
notificationPendingParticipation.value =
|
|
||||||
loggedUser.value.settings.notificationPendingParticipation;
|
|
||||||
groupNotifications.value = loggedUser.value.settings.groupNotifications;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const { mutate: updateSetting } = useMutation<{ setUserSettings: string }>(
|
const { mutate: updateSetting } = useMutation<{
|
||||||
SET_USER_SETTINGS,
|
setUserSettings: IUserSettings;
|
||||||
() => ({ refetchQueries: [{ query: USER_NOTIFICATIONS }] })
|
}>(SET_USER_SETTINGS, () => ({
|
||||||
);
|
refetchQueries: [{ query: USER_NOTIFICATIONS }],
|
||||||
|
}));
|
||||||
|
|
||||||
|
const setNotificationSettings = (settings: IUserSettings) => {
|
||||||
|
notificationOnDay.value = settings.notificationOnDay;
|
||||||
|
notificationEachWeek.value = settings.notificationEachWeek;
|
||||||
|
notificationBeforeEvent.value = settings.notificationBeforeEvent;
|
||||||
|
notificationPendingParticipation.value =
|
||||||
|
settings.notificationPendingParticipation;
|
||||||
|
groupNotifications.value = settings.groupNotifications;
|
||||||
|
};
|
||||||
|
|
||||||
const dialog = inject<Dialog>("dialog");
|
const dialog = inject<Dialog>("dialog");
|
||||||
|
|
||||||
@@ -790,7 +805,9 @@ const { mutate: updateNotificationValue } = useMutation<
|
|||||||
method: IActivitySettingMethod;
|
method: IActivitySettingMethod;
|
||||||
enabled: boolean;
|
enabled: boolean;
|
||||||
}
|
}
|
||||||
>(UPDATE_ACTIVITY_SETTING);
|
>(UPDATE_ACTIVITY_SETTING, () => ({
|
||||||
|
refetchQueries: [{ query: USER_NOTIFICATIONS }],
|
||||||
|
}));
|
||||||
|
|
||||||
const isSubscribed = async (): Promise<boolean> => {
|
const isSubscribed = async (): Promise<boolean> => {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user