♻️ (app)

This commit is contained in:
Julien Calixte
2023-08-14 14:08:10 +02:00
parent 111794a40b
commit c0182c7f57
24 changed files with 4281 additions and 2108 deletions

View File

@@ -2,12 +2,12 @@ import { useMarkdown } from '@/hooks/useMarkdown.hook'
import { prepareNoteCache } from '@/modules/note/cache/prepareNoteCache'
import { getFileContent } from '@/modules/repo/services/repo'
import { useUserRepoStore } from '@/modules/repo/store/userRepo.store'
import { ref } from 'vue'
import { Ref, ref, toValue } from 'vue'
export const useFile = (sha: string, retrieveContent = true) => {
const { render } = useMarkdown(sha)
export const useFile = (sha: Ref<string> | string, retrieveContent = true) => {
const { render } = useMarkdown(toValue(sha))
const store = useUserRepoStore()
const { getCachedNote, saveCacheNote } = prepareNoteCache(sha)
const { getCachedNote, saveCacheNote } = prepareNoteCache(toValue(sha))
const fromCache = ref(false)
const content = ref('')
@@ -42,7 +42,11 @@ export const useFile = (sha: string, retrieveContent = true) => {
return cachedNote.content
}
const contentFile = await getFileContent(store.user, store.repo, sha)
const contentFile = await getFileContent(
store.user,
store.repo,
toValue(sha)
)
if (!contentFile) {
return null