Skip to content

Commit

Permalink
deploy: e56256a
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Apr 23, 2024
1 parent 2566eec commit efbc868
Showing 1 changed file with 28 additions and 15 deletions.
43 changes: 28 additions & 15 deletions mjs/question.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,7 @@ const EditQuestion = {
}, 100)

watchEffect(async () => {
if (!editing.value) return
debounceApi(request.value.body)
})

Expand All @@ -767,6 +768,15 @@ const EditQuestion = {
props.bus.publish('editDone', request.value)
}
}

async function loadQuestion() {
const api = await client.api(new GetQuestionFile({ id: props.id }))
if (api.succeeded) {
original = JSON.parse(api.response)
Object.assign(request.value, original)
}
nextTick(applyGlobalChanges)
}

onMounted(async () => {
const footer = $1('.question-footer')
Expand All @@ -775,17 +785,13 @@ const EditQuestion = {
footer.innerHTML = ''
}

props.bus.subscribe('toggleEdit', () => {
props.bus.subscribe('toggleEdit', async () => {
editing.value = !editing.value
if (!lastBody || request.value.body !== lastBody) {
await loadQuestion()
debounceApi(request.value.body)
}
})

const api = await client.api(new GetQuestionFile({ id: props.id }))
if (api.succeeded) {
original = JSON.parse(api.response)
Object.assign(request.value, original)
}

nextTick(applyGlobalChanges)
})

function close() {
Expand Down Expand Up @@ -942,6 +948,7 @@ const EditAnswer = {
}, 100)

watchEffect(async () => {
if (!editing.value) return
debounceApi(request.value.body)
})

Expand All @@ -953,18 +960,24 @@ const EditAnswer = {
close()
}
}

onMounted(async () => {
props.bus.subscribe('toggleEdit', () => {
editing.value = !editing.value
})


async function loadAnswer() {
const api = await client.api(new GetAnswer({ id: props.id }))
if (api.succeeded) {
answer.value = api.response?.result
request.value.body = answer.value.body || ''
nextTick(highlightAll)
}
}

onMounted(async () => {
props.bus.subscribe('toggleEdit', async () => {
editing.value = !editing.value
if (!answer.value) {
await loadAnswer()
debounceApi(request.value.body)
}
})
})

function close() {
Expand Down

0 comments on commit efbc868

Please sign in to comment.