🐛 (flux) listen to click day 1
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import { createEventBus } from 'retrobus'
|
||||
|
||||
interface EventBusParams {
|
||||
user: string
|
||||
repo: string
|
||||
path: string
|
||||
currentNoteSHA?: string
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ import {
|
||||
computed,
|
||||
watch,
|
||||
nextTick,
|
||||
toRefs,
|
||||
onUnmounted
|
||||
} from 'vue'
|
||||
import HeaderNote from '@/components/HeaderNote.vue'
|
||||
@@ -63,6 +64,7 @@ export default defineComponent({
|
||||
content: { type: String, required: false, default: null }
|
||||
},
|
||||
setup(props) {
|
||||
const refProps = toRefs(props)
|
||||
const store = useUserRepoStore()
|
||||
const { renderString } = useMarkdown()
|
||||
const { listenToClick } = useLinks('note-display')
|
||||
@@ -76,18 +78,26 @@ export default defineComponent({
|
||||
|
||||
const hasContent = computed(() => !!renderedContent.value)
|
||||
|
||||
watch(renderedContent, () =>
|
||||
watch(
|
||||
renderedContent,
|
||||
() =>
|
||||
nextTick(() => {
|
||||
console.log(renderedContent)
|
||||
|
||||
listenToClick()
|
||||
})
|
||||
}),
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
watch(
|
||||
[refProps.user, refProps.repo],
|
||||
() => {
|
||||
store.setUserRepo(props.user, props.repo)
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
onUnmounted(() => {
|
||||
store.resetUserRepo()
|
||||
store.resetFiles()
|
||||
resetStackedNotes()
|
||||
})
|
||||
|
||||
return {
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
import { noteEventBus } from '@/bus/noteBusEvent'
|
||||
import { useUserRepoStore } from '@/modules/repo/store/userRepo.store'
|
||||
import { onUnmounted } from '@vue/runtime-core'
|
||||
|
||||
const LINKS = ['http://', 'https://']
|
||||
|
||||
export const useLinks = (className: string, sha?: string) => {
|
||||
const store = useUserRepoStore()
|
||||
|
||||
const linkNote: EventListener = (event) => {
|
||||
event.preventDefault()
|
||||
const target = event.target as HTMLElement
|
||||
@@ -20,7 +23,9 @@ export const useLinks = (className: string, sha?: string) => {
|
||||
|
||||
noteEventBus.emit({
|
||||
path: href,
|
||||
currentNoteSHA: sha
|
||||
currentNoteSHA: sha,
|
||||
user: store.user,
|
||||
repo: store.repo
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ export const useNote = (containerClass: string) => {
|
||||
)
|
||||
|
||||
const unsubscribeLink = noteEventBus.addEventBusListener(
|
||||
({ path, currentNoteSHA }) => {
|
||||
({ user, repo, path, currentNoteSHA }) => {
|
||||
const currentFile = store.files.find(
|
||||
(file) => file.sha === currentNoteSHA
|
||||
)
|
||||
@@ -77,8 +77,8 @@ export const useNote = (containerClass: string) => {
|
||||
push({
|
||||
name: currentRoute.value.name ?? 'Home',
|
||||
params: {
|
||||
user: store.user,
|
||||
repo: store.repo
|
||||
user,
|
||||
repo
|
||||
},
|
||||
query: {
|
||||
stackedNotes: newStackedNotes
|
||||
|
||||
@@ -32,6 +32,9 @@ export const useUserRepoStore = defineStore({
|
||||
resetUserRepo() {
|
||||
this.user = ''
|
||||
this.repo = ''
|
||||
this.resetFiles()
|
||||
},
|
||||
resetFiles() {
|
||||
this.files = []
|
||||
this.readme = null
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user