fix: fix notification count
This commit is contained in:
parent
719c3171f8
commit
78bc8426dd
|
@ -1,7 +1,7 @@
|
|||
<script setup lang="ts">
|
||||
import type { Notification, LibraryFollow } from '~/types'
|
||||
|
||||
import { computed, ref, watchEffect } from 'vue'
|
||||
import { computed, ref, watchEffect, watch } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { useStore } from '~/store'
|
||||
|
||||
|
@ -30,7 +30,7 @@ const notificationData = computed(() => {
|
|||
|
||||
if (activity.type === 'Follow') {
|
||||
if (activity.object && activity.object.type === 'music.Library') {
|
||||
const detailUrl = { name: 'content.libraries.detail', params: { id: activity.object.uuid } }
|
||||
const detailUrl = { name: 'library.detail.edit', params: { id: activity.object.uuid } }
|
||||
|
||||
if (activity.related_object?.approved === null) {
|
||||
return {
|
||||
|
@ -76,7 +76,7 @@ const notificationData = computed(() => {
|
|||
})
|
||||
|
||||
const read = ref(false)
|
||||
watchEffect(async () => {
|
||||
watch(read, async () => {
|
||||
await axios.patch(`federation/inbox/${item.value.id}/`, { is_read: read.value })
|
||||
|
||||
item.value.is_read = read.value
|
||||
|
@ -92,11 +92,13 @@ const handleAction = (handler?: () => void) => {
|
|||
const approveLibraryFollow = async (follow: LibraryFollow) => {
|
||||
await axios.post(`federation/follows/library/${follow.uuid}/accept/`)
|
||||
follow.approved = true
|
||||
item.value.is_read = true
|
||||
}
|
||||
|
||||
const rejectLibraryFollow = async (follow: LibraryFollow) => {
|
||||
await axios.post(`federation/follows/library/${follow.uuid}/reject/`)
|
||||
follow.approved = false
|
||||
item.value.is_read = true
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import type { Notification } from '~/types'
|
|||
import moment from 'moment'
|
||||
import axios from 'axios'
|
||||
|
||||
import { ref, reactive, computed, watch, markRaw } from 'vue'
|
||||
import { ref, reactive, computed, watch } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { useStore } from '~/store'
|
||||
|
||||
|
@ -38,7 +38,7 @@ const fetchData = async () => {
|
|||
try {
|
||||
const response = await axios.get('federation/inbox/', { params: filters })
|
||||
notifications.count = response.data.count
|
||||
notifications.results = response.data.results.map(markRaw)
|
||||
notifications.results = response.data.results
|
||||
} catch (error) {
|
||||
useErrorHandler(error as Error)
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ watch(filters, fetchData, { immediate: true })
|
|||
|
||||
useWebSocketHandler('inbox.item_added', (event) => {
|
||||
notifications.count += 1
|
||||
notifications.results.unshift(markRaw((event.item)))
|
||||
notifications.results.unshift(event.item)
|
||||
})
|
||||
|
||||
const instanceSupportMessageDelay = ref(60)
|
||||
|
|
Loading…
Reference in New Issue