(note) init image display

This commit is contained in:
2021-03-22 22:27:11 +01:00
parent cb5ff68866
commit d4391bb8c6
7 changed files with 106 additions and 28 deletions

View File

@@ -1,4 +1,4 @@
import { Ref, onMounted, ref, watch } from '@vue/runtime-core'
import { Ref, ref, watch } from '@vue/runtime-core'
import { Octokit } from '@octokit/rest'
import { useGitHubLogin } from '@/hooks/useGitHubLogin.hook'
@@ -14,7 +14,13 @@ interface Tree {
url?: string
}
export const useRepo = (owner: Ref<string>, repo: Ref<string>) => {
const tree = ref<Tree[]>([])
export const useRepo = (
owner: Ref<string>,
repo: Ref<string>,
retrieve = true
) => {
const { getCachedNote, saveCacheNote } = useNoteCache('README')
const { accessToken } = useGitHubLogin()
const { render } = useMarkdown()
@@ -25,7 +31,6 @@ export const useRepo = (owner: Ref<string>, repo: Ref<string>) => {
const readme = ref<string | null>(null)
const notFound = ref(false)
const tree = ref<Tree[]>([])
const retrieveRepo = async () => {
if (!owner.value || !repo.value) {
@@ -82,9 +87,9 @@ export const useRepo = (owner: Ref<string>, repo: Ref<string>) => {
}
}
onMounted(() => {
if (retrieve) {
retrieveRepo()
})
}
watch([owner, repo], () => retrieveRepo())