refacto: prepare for a relevant useNote hook
This commit is contained in:
@@ -13,7 +13,7 @@ import LiteLoading from '@/components/LiteLoading.vue'
|
||||
import StackedNote from '@/components/StackedNote.vue'
|
||||
import { useLinks } from '@/hooks/useLinks.hook'
|
||||
import { useMarkdown } from '@/hooks/useMarkdown.hook'
|
||||
import { useNote } from '@/hooks/useNote.hook'
|
||||
import { useNoteView } from '@/hooks/useNoteView.hook'
|
||||
import { useRouteQueryStackedNotes } from '@/hooks/useRouteQueryStackedNotes.hook'
|
||||
import { useVisitRepo } from '@/modules/history/hooks/useVisitRepo.hook'
|
||||
import CacheAllNotes from '@/modules/note/components/CacheAllNote.vue'
|
||||
@@ -52,7 +52,7 @@ const { toHTML } = useMarkdown(repo)
|
||||
const { listenToClick } = useLinks('note-display')
|
||||
const { stackedNotes, scrollToTop } = useRouteQueryStackedNotes()
|
||||
|
||||
const { titles } = useNote('note-container')
|
||||
const { titles } = useNoteView('note-container')
|
||||
|
||||
const renderedContent = computed(() =>
|
||||
props.content !== null
|
||||
|
||||
@@ -88,15 +88,19 @@ watch([content, mode], () => {
|
||||
})
|
||||
|
||||
watch(mode, async (newMode) => {
|
||||
if (newMode === 'read' && rawContent.value !== initialRawContent.value) {
|
||||
const editedSha = (await getEditedSha()) ?? sha.value
|
||||
const hasUserFinishedToEdit =
|
||||
newMode === 'read' && rawContent.value !== initialRawContent.value
|
||||
|
||||
if (!hasUserFinishedToEdit) {
|
||||
return
|
||||
}
|
||||
if (!path.value) {
|
||||
console.warn('no path found for this file')
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
const editedSha = (await getEditedSha()) ?? sha.value
|
||||
const newSha = await updateFile({
|
||||
content: rawContent.value,
|
||||
path: path.value,
|
||||
@@ -113,7 +117,6 @@ watch(mode, async (newMode) => {
|
||||
editedSha: newSha
|
||||
})
|
||||
initialRawContent.value = rawContent.value
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import { resolvePath } from '@/modules/repo/services/resolvePath'
|
||||
import { useUserRepoStore } from '@/modules/repo/store/userRepo.store'
|
||||
import { pathToNotePathTitle } from '@/utils/noteTitle'
|
||||
|
||||
export const useNote = (containerClass: string) => {
|
||||
export const useNoteView = (containerClass: string) => {
|
||||
const store = useUserRepoStore()
|
||||
const { isMobile } = useOverlay(false)
|
||||
const { stackedNotes, addStackedNote } = useRouteQueryStackedNotes()
|
||||
Reference in New Issue
Block a user