Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions src/components/appointment/ResponseEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@

<script setup>
import { NcButton, NcInputField } from '@nextcloud/vue'
import { computed, nextTick, onBeforeUnmount, ref, watch } from 'vue'
import { computed, nextTick, ref, watch } from 'vue'
import CheckCircle from 'vue-material-design-icons/CheckCircle.vue'
import ClockIcon from 'vue-material-design-icons/Clock.vue'
import CloseCircle from 'vue-material-design-icons/CloseCircle.vue'
Expand Down Expand Up @@ -135,7 +135,7 @@ const localComment = ref(props.comment)
const commentExpanded = ref(Boolean(props.comment) && !props.compact)
const commentInput = ref(null)

const { savingComment, errorComment, autoSaveComment, reset } = useAppointmentResponse()
const { savingComment, saveComment: saveCommentApi } = useAppointmentResponse()

// Saving a comment does not refresh the parent, so props.comment stays on the
// value the card was rendered with. Without a local baseline the Save button
Expand Down Expand Up @@ -165,15 +165,11 @@ watch(() => props.comment, (next) => {
async function saveComment() {
if (!commentChanged.value || savingComment.value) return
const pending = localComment.value
await autoSaveComment(props.appointmentId, props.userResponse, pending, false)
if (!errorComment.value) {
const saved = await saveCommentApi(props.appointmentId, props.userResponse, pending)
if (saved) {
savedComment.value = pending
}
}

// The composable keeps its own spinner/indicator timeouts, which would
// otherwise keep writing into refs of an unmounted card.
onBeforeUnmount(reset)
</script>

<style scoped lang="scss">
Expand Down
Loading
Loading