🐛 Fix notifications
This commit is contained in:
parent
7e01edffbe
commit
21b2f1e555
@ -12,7 +12,8 @@
|
|||||||
|
|
||||||
<v-list v-if="notify.notifications.length <= 0" class="w-[380px]" density="compact">
|
<v-list v-if="notify.notifications.length <= 0" class="w-[380px]" density="compact">
|
||||||
<v-list-item>
|
<v-list-item>
|
||||||
<v-alert class="text-sm" variant="tonal" type="info">You are done! There is no unread notifications for you.</v-alert>
|
<v-alert class="text-sm" variant="tonal" type="info">You are done! There is no unread notifications for you.
|
||||||
|
</v-alert>
|
||||||
</v-list-item>
|
</v-list-item>
|
||||||
</v-list>
|
</v-list>
|
||||||
|
|
||||||
@ -36,8 +37,8 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { request } from "@/scripts/request"
|
import { request } from "@/scripts/request"
|
||||||
import { getAtk } from "@/stores/userinfo"
|
import { getAtk } from "@/stores/userinfo"
|
||||||
import { computed, onMounted, onUnmounted, ref } from "vue";
|
import { computed, onMounted, onUnmounted, ref } from "vue"
|
||||||
import { useNotifications } from "@/stores/notifications";
|
import { useNotifications } from "@/stores/notifications"
|
||||||
import { useUI } from "@/stores/ui"
|
import { useUI } from "@/stores/ui"
|
||||||
|
|
||||||
const notify = useNotifications()
|
const notify = useNotifications()
|
||||||
@ -47,10 +48,15 @@ const submitting = ref(false)
|
|||||||
const loading = computed(() => notify.loading || submitting.value)
|
const loading = computed(() => notify.loading || submitting.value)
|
||||||
|
|
||||||
async function markAsRead(item: any, idx: number) {
|
async function markAsRead(item: any, idx: number) {
|
||||||
|
if (item.is_realtime) {
|
||||||
|
notify.remove(idx)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
submitting.value = true
|
submitting.value = true
|
||||||
const res = await request("identity", `/api/notifications/${item.id}/read`, {
|
const res = await request("identity", `/api/notifications/${item.id}/read`, {
|
||||||
method: "PUT",
|
method: "PUT",
|
||||||
headers: { Authorization: `Bearer ${getAtk()}` },
|
headers: { Authorization: `Bearer ${await getAtk()}` }
|
||||||
})
|
})
|
||||||
if (res.status !== 200) {
|
if (res.status !== 200) {
|
||||||
showErrorSnackbar(await res.text())
|
showErrorSnackbar(await res.text())
|
||||||
|
Reference in New Issue
Block a user