comments working
This commit is contained in:
parent
375bed1d01
commit
0b472988a2
14 changed files with 107 additions and 59 deletions
|
|
@ -85,6 +85,7 @@ import { useApiStore } from "../../stores/api";
|
|||
import { useDialogStore } from "../../stores/dialog";
|
||||
import { computed, onMounted, ref, useTemplateRef } from "vue";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { usePageStore } from "../../stores/page";
|
||||
|
||||
dayjs.locale("fr");
|
||||
|
||||
|
|
@ -102,6 +103,7 @@ const { activeTracks, openedComment } = storeToRefs(useDialogStore());
|
|||
const draftText = ref(comment.text);
|
||||
const editField = ref(null);
|
||||
const commentNode = useTemplateRef("comment-node");
|
||||
const { page } = storeToRefs(usePageStore());
|
||||
let correspondingMarker = null;
|
||||
|
||||
// Functions
|
||||
|
|
@ -143,7 +145,7 @@ function handleClick() {
|
|||
async function read() {
|
||||
if (getStatus.value !== "unread") return;
|
||||
try {
|
||||
const newNotification = await api.readNotification(comment);
|
||||
const newNotification = await api.readNotification(comment, page.value.uri);
|
||||
console.log(newNotification);
|
||||
userStore.readNotification(comment.id);
|
||||
} catch (error) {
|
||||
|
|
|
|||
|
|
@ -179,7 +179,6 @@ function handleSubmit(event = null) {
|
|||
}
|
||||
const date = dayjs().format();
|
||||
const newComment = {
|
||||
dialogUri: route.fullPath,
|
||||
fileName: openedFile.value ? openedFile.value.name : false,
|
||||
userUuid: user.uuid,
|
||||
text: draftComment.value.text,
|
||||
|
|
@ -202,7 +201,7 @@ function handleSubmit(event = null) {
|
|||
|
||||
async function replyComment(newComment) {
|
||||
newComment.parentId = openedComment.value.id;
|
||||
const matchFileParentUri = openedComment.value.location.file.url.match(
|
||||
const matchFileParentUri = openedFile.value.url.match(
|
||||
/projects\/.*?(?=\/[^/]+\/[^/]+$)/
|
||||
);
|
||||
newComment.fileParentUri = matchFileParentUri ? matchFileParentUri[0] : null;
|
||||
|
|
@ -224,14 +223,16 @@ async function addComment(newComment) {
|
|||
resetDraftComment();
|
||||
isAddOpen.value = false;
|
||||
dialog.updateFile(newFile);
|
||||
activeTracks.value = activeTracks.value.map((track) => {
|
||||
if (track.files) {
|
||||
track.files = track.files.map((file) =>
|
||||
file.uuid === newFile.uuid ? newFile : file
|
||||
);
|
||||
}
|
||||
return track;
|
||||
});
|
||||
if (activeTracks.value) {
|
||||
activeTracks.value = activeTracks.value.map((track) => {
|
||||
if (track.files) {
|
||||
track.files = track.files.map((file) =>
|
||||
file.uuid === newFile.uuid ? newFile : file
|
||||
);
|
||||
}
|
||||
return track;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function resetDraftComment() {
|
||||
|
|
@ -318,11 +319,15 @@ function openComment(comment) {
|
|||
openedComment.value = comment;
|
||||
|
||||
if (activeTracks.value?.length === 1) {
|
||||
openedFile.value = activeTracks.value[0].files.find(
|
||||
(file) => file.uuid === openedComment.value.location.file.uuid
|
||||
);
|
||||
showCorrespondingView();
|
||||
}
|
||||
}
|
||||
|
||||
function showCorrespondingView() {
|
||||
openedFile.value = activeTracks.value[0].files.find(
|
||||
(file) => file.uuid === openedComment.value.location.file.uuid
|
||||
);
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue