import { defineStore } from "pinia"; import { ref, computed } from "vue"; import { useRoute } from "vue-router"; export const useDialogStore = defineStore("dialog", () => { const content = ref(null); const openedFile = ref(null); const comments = computed(() => { return openedFile.value.comments; }); function updateFile(newFile) { content.value.files = content.value.files.map((file) => file.id === newFile.id ? newFile : file ); openedFile.value = newFile; } const route = useRoute(); const isCommentsOpen = ref( route.query.hasOwnProperty("comments") ? true : false ); return { content, openedFile, comments, isCommentsOpen, updateFile }; });