possible fix of stuck file input

This commit is contained in:
DJ2LS 2024-02-07 22:46:45 +01:00
parent 8be087e4fc
commit c33d23f326
2 changed files with 10 additions and 7 deletions

View file

@ -77,6 +77,11 @@ function handleFileSelection(event) {
function removeFile(index) {
selectedFiles.value.splice(index, 1);
// Check if the selectedFiles array is empty
if (selectedFiles.value.length === 0) {
// Reset the file input if there are no files left
resetFile();
}
}
function transmitNewMessage() {
@ -118,11 +123,11 @@ function transmitNewMessage() {
}
function resetFile(event){
//fileInput.reset()
fileInput.value = null
if (fileInput.value) {
fileInput.value.value = ''; // Reset the file input
}
// Clear the selected files array to reset the state of attachments
selectedFiles.value = [];
}

View file

@ -26,7 +26,7 @@ interface Message {
}
export async function processFreedataMessages(data) {
if (typeof data != "undefined") {
if (typeof data !== "undefined" && typeof data.messages !== "undefined" && Array.isArray(data.messages)) {
chatStore.callsign_list = createCallsignListFromAPI(data);
chatStore.sorted_chat_list = createSortedMessagesList(data);
}
@ -38,9 +38,7 @@ function createCallsignListFromAPI(data: {
}): { [key: string]: { timestamp: string; body: string } } {
const callsignList: { [key: string]: { timestamp: string; body: string } } =
{};
if (typeof data == "undefined") {
return callsignList;
}
data.messages.forEach((message) => {
let callsign =
message.direction === "receive" ? message.origin : message.destination;