designtopack/src/stores/dialog.js

26 lines
697 B
JavaScript
Raw Normal View History

import { defineStore } from "pinia";
2024-11-16 12:05:37 +01:00
import { ref, computed } from "vue";
2024-11-27 17:51:49 +01:00
import { useRoute } from "vue-router";
export const useDialogStore = defineStore("dialog", () => {
const content = ref(null);
2024-11-16 12:05:37 +01:00
const openedFile = ref(null);
const comments = computed(() => {
return openedFile.value.comments;
});
2024-11-16 12:05:37 +01:00
function updateFile(newFile) {
content.value.files = content.value.files.map((file) =>
file.id === newFile.id ? newFile : file
);
openedFile.value = newFile;
}
2024-11-27 17:51:49 +01:00
const route = useRoute();
const isCommentsOpen = ref(
route.query.hasOwnProperty("comments") ? true : false
);
return { content, openedFile, comments, isCommentsOpen, updateFile };
});