Skip to content
This repository has been archived by the owner on Sep 12, 2023. It is now read-only.

Commit

Permalink
intrn(consultation): inject chat message activity
Browse files Browse the repository at this point in the history
  • Loading branch information
lemredd committed Oct 10, 2022
1 parent 5c52720 commit bb69940
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions components/consultation/chat_window/user_controller/file_upload.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,23 @@
</style>

<script setup lang="ts">
import { ref, computed, onMounted } from "vue"
import { ref, computed, inject, ComputedRef, DeepReadonly } from "vue"
import { CHAT_MESSAGE_ACTIVITY } from "$@/constants/provided_keys"
import Fetcher from "$@/fetchers/chat_message"
import Overlay from "@/helpers/overlay.vue"
let rawFetcher: Fetcher|null = null
import { DeserializedChatMessageActivityResource } from "$/types/documents/chat_message_activity"
defineProps<{ isShown: boolean }>()
const filename = ref<string|null>(null)
const hasExtracted = computed<boolean>(() => filename.value !== null)
const previewFile = ref<any>(null)
const fileUploadForm = ref()
const ownChatMessageActivity = inject(
CHAT_MESSAGE_ACTIVITY
) as DeepReadonly<ComputedRef<DeserializedChatMessageActivityResource>>
interface CustomEvents {
(event: "close"): void
Expand All @@ -91,17 +96,11 @@ function emitClose() {
emit("close")
}
function fetcher(): Fetcher {
if (rawFetcher === null) throw new Error("Chat cannot be processed yet")
return rawFetcher
}
function sendFile(event: Event): void {
const button = event.target as HTMLButtonElement
const formData = new FormData(button.form as HTMLFormElement)
function sendFile() {
const fetcher = new Fetcher()
const formData = new FormData(fileUploadForm.value as HTMLFormElement)
fetcher().createWithFile(formData)
fetcher.createWithFile(formData)
.then(() => {
emitClose()
})
Expand Down

0 comments on commit bb69940

Please sign in to comment.