read notification fully working (content, comment and reply)

This commit is contained in:
isUnknown 2024-12-19 11:11:43 +01:00
parent 51409bd090
commit cce158e80a
6 changed files with 10 additions and 10 deletions

View file

@ -117,7 +117,7 @@ const { page } = storeToRefs(usePageStore());
const unreadNotificationsCount = computed(() => { const unreadNotificationsCount = computed(() => {
if (!user.value) return undefined; if (!user.value) return undefined;
const count = user.value.notifications.filter( const count = user.value.notifications.filter(
(notification) => notification.isread (notification) => notification.isread != "true"
).length; ).length;
if (count === 0) return undefined; if (count === 0) return undefined;
return count; return count;
@ -164,7 +164,7 @@ function hasUnreadNotification(project) {
if (!user.value) return false; if (!user.value) return false;
return user.value.notifications.some((notification) => { return user.value.notifications.some((notification) => {
return ( return (
notification.isread != true && notification.isread != "true" &&
project.uri.includes(notification.location.project.uri) project.uri.includes(notification.location.project.uri)
); );
}); });

View file

@ -2,7 +2,7 @@
<article <article
:id="`comment-${comment.id}`" :id="`comment-${comment.id}`"
class="comment | flow" class="comment | flow"
:data-status="status" :data-status="getStatus"
@click="read()" @click="read()"
> >
<header> <header>
@ -70,11 +70,11 @@ const api = useApiStore();
const dialog = useDialogStore(); const dialog = useDialogStore();
// Functions // Functions
const status = computed(() => { const getStatus = computed(() => {
const correspondingNotification = userStore.notifications.find( const correspondingNotification = userStore.notifications.find(
(notification) => notification.id === comment.id (notification) => notification.id === comment.id
); );
if (correspondingNotification && !correspondingNotification.isread) { if (correspondingNotification && correspondingNotification.isread != "true") {
return "unread"; return "unread";
} }
return undefined; return undefined;
@ -101,9 +101,10 @@ function closeAddField() {
} }
async function read() { async function read() {
if (status.value !== "unread") return; if (getStatus.value !== "unread") return;
try { try {
const newNotification = await api.readNotification(comment.id); const newNotification = await api.readNotification(comment.id);
console.log(newNotification);
userStore.readNotification(comment.id); userStore.readNotification(comment.id);
} catch (error) { } catch (error) {
console.log("Erreur lors de la lecture de la notification : ", error); console.log("Erreur lors de la lecture de la notification : ", error);

View file

@ -1,7 +1,7 @@
<template> <template>
<article <article
class="notification | bg-white rounded-lg | p-16 | flow" class="notification | bg-white rounded-lg | p-16 | flow"
:data-status="notification.isread == true ? 'read' : 'unread'" :data-status="notification.isread == 'true' ? 'read' : 'unread'"
data-type="comment" data-type="comment"
@click="router.push(notification.location.dialoguri + '&comments=true')" @click="router.push(notification.location.dialoguri + '&comments=true')"
> >

View file

@ -1,7 +1,7 @@
<template> <template>
<article <article
class="notification | bg-white rounded-lg | p-16 | flow" class="notification | bg-white rounded-lg | p-16 | flow"
:data-status="notification.isread == true ? 'read' : 'unread'" :data-status="notification.isread == 'true' ? 'read' : 'unread'"
data-type="comment" data-type="comment"
@click="router.push(notification.location.dialoguri + '&comments=true')" @click="router.push(notification.location.dialoguri + '&comments=true')"
> >

View file

@ -223,7 +223,6 @@ function getFrontView(track) {
const extension = track.files[0].name.split(".")[1]; const extension = track.files[0].name.split(".")[1];
const frontViewName = "0_" + xFrontView + "." + extension; const frontViewName = "0_" + xFrontView + "." + extension;
const frontView = track.files.find((file) => file.name === frontViewName); const frontView = track.files.find((file) => file.name === frontViewName);
console.log(frontView);
return frontView; return frontView;
} }
</script> </script>

View file

@ -13,7 +13,7 @@ export const useUserStore = defineStore("user", () => {
function readNotification(notificationId) { function readNotification(notificationId) {
user.value.notifications.forEach((notification) => { user.value.notifications.forEach((notification) => {
if (notification.id === notificationId) { if (notification.id === notificationId) {
notification.isread = true; notification.isread = "true";
} }
}); });
} }