Skip to content

Commit

Permalink
fix: use correct name value and type in `notification paired device…
Browse files Browse the repository at this point in the history
…s` payload
  • Loading branch information
enzo-bitfly committed Jan 27, 2025
1 parent 2b8ee16 commit 8f212eb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ const emit = defineEmits<{
(e: 'remove-device', id: number): void,
(e: 'toggle-notifications', {
id,
name,
value,
}: {
id: number,
name?: string,
value: boolean,
}): void,
}>()
Expand All @@ -41,7 +43,7 @@ const hasNotifications = ref(props.device.is_notifications_enabled)
<div class="toggle-row">
<BcToggle
v-model="hasNotifications"
@update:model-value="emit('toggle-notifications', { id: device.id, value: $event })"
@update:model-value="emit('toggle-notifications', { id: device.id, name: device.name, value: $event })"
/>
{{ $t("notifications.general.paired_devices.mobile_notifications") }}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@ const close = () => {
const handleToggleNotifications = ({
id,
name,
value,
}: {
id: number,
name?: string,
value: boolean,
}) => {
notificationsManagementStore.setNotificationForPairedDevice({
id,
name,
value,
})
const device = notificationsManagementStore.settings.paired_devices.find(device => device.id === id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,22 +55,24 @@ export const useNotificationsManagementStore = defineStore('notifications-manage
).then(() => {
// using optimistic ui here to avoid calling the api after delete
settings.value.paired_devices
= [ ...settings.value.paired_devices.filter(device => device.id !== id) ]
= [ ...settings.value.paired_devices.filter(device => device.id !== id) ]
}).then(() => refreshOverview())
}
const setNotificationForPairedDevice = async ({
id,
name,
value,
}: {
id: number,
name?: string,
value: boolean,
}) => {
await fetch<PutUserNotificationSettingsPairedDevicesResponse>(
'NOTIFICATIONS_MANAGEMENT_PAIRED_DEVICES_SET_NOTIFICATION',
{
body: {
is_notifications_enabled: value,
name: id,
name,
},
},
{
Expand Down

0 comments on commit 8f212eb

Please sign in to comment.