♻️ (notes) home is now the note initial screen with a fo…

This commit is contained in:
2021-03-13 22:38:21 +01:00
parent 8fad931dfd
commit 2286bd5d85
8 changed files with 133 additions and 85 deletions

View File

@@ -13,12 +13,9 @@ const sanitizePath = (path: string) => {
return decodeURIComponent(path)
}
export const useNote = (user: string, repo: string) => {
export const useNote = (user?: string, repo?: string) => {
const { push } = useRouter()
const { readme, notFound, tree } = useRepo(user, repo)
const { listenToClick } = useLinks('note-display')
const { query } = useRoute()
const stackedNotes = ref(
query.stackedNotes
? Array.isArray(query.stackedNotes)
@@ -27,6 +24,17 @@ export const useNote = (user: string, repo: string) => {
: []
)
if (!user || !repo) {
return {
readme: ref(null),
notFound: ref(true),
stackedNotes
}
}
const { readme, notFound, tree } = useRepo(user, repo)
const { listenToClick } = useLinks('note-display')
const unsubscribe = noteEventBus.addEventBusListener(
({ path, currentNoteSHA }) => {
const currentFile = tree.value.find((file) => file.sha === currentNoteSHA)
@@ -68,7 +76,11 @@ export const useNote = (user: string, repo: string) => {
const newStackedNotes = getStackedNotes()
push({
name: 'Note',
name: 'Home',
params: {
user,
repo
},
query: {
stackedNotes: newStackedNotes
}