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) { openedFile.value = newFile; if (!content.value.files) return; content.value.files = content.value.files.map((file) => file.id === newFile.id ? newFile : file ); } const route = useRoute(); const isCommentsOpen = ref( route.query.hasOwnProperty("comments") ? true : false ); return { content, openedFile, comments, isCommentsOpen, updateFile }; });