From 79ab76489b07e42de53142fab5320f83f9ea02af Mon Sep 17 00:00:00 2001
From: NeonKirill <74428618+NeonKirill@users.noreply.github.com>
Date: Sat, 14 Dec 2024 12:54:27 +0100
Subject: [PATCH] Fixed issue with creation of the new conversation (#119)
---
chat_client/static/js/base_utils.js | 6 ++++++
chat_client/static/js/chat_utils.js | 11 ++---------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/chat_client/static/js/base_utils.js b/chat_client/static/js/base_utils.js
index 308a3ea3..6ba06307 100644
--- a/chat_client/static/js/base_utils.js
+++ b/chat_client/static/js/base_utils.js
@@ -33,6 +33,12 @@ function displayAlert(parentElem,text='Error Occurred',alertType='danger',alertI
alert.remove();
}
+ if(!alertBehaviorProperties){
+ alertBehaviorProperties = {
+ 'type': alertBehaviors.AUTO_EXPIRE,
+ }
+ }
+
if(text) {
parentElem.insertAdjacentHTML('afterbegin',
`
diff --git a/chat_client/static/js/chat_utils.js b/chat_client/static/js/chat_utils.js
index ffa68861..09ebb060 100644
--- a/chat_client/static/js/chat_utils.js
+++ b/chat_client/static/js/chat_utils.js
@@ -392,9 +392,6 @@ async function getConversationDataByInput(input="", skin=CONVERSATION_SKINS.BASE
conversationData = data;
}).catch(async err=> {
console.warn('Failed to fulfill request due to error:',err);
- if (input === '1'){
- await createNewConversation('Global', false, '1');
- }
});
}
return conversationData;
@@ -743,16 +740,14 @@ async function displayConversation(searchStr, skin=CONVERSATION_SKINS.BASE, aler
* Handles requests on creation new conversation by the user
* @param conversationName - New Conversation Name
* @param isPrivate - if conversation should be private (defaults to false)
- * @param conversationID - New Conversation ID (optional)
* @param boundServiceID - id of the service to bind to conversation (optional)
* @param createLiveConversation - if conversation should be treated as live conversation (defaults to false)
*/
-async function createNewConversation(conversationName, isPrivate=false, conversationID=null, boundServiceID=null, createLiveConversation=false) {
+async function createNewConversation(conversationName, isPrivate=false,boundServiceID=null, createLiveConversation=false) {
let formData = new FormData();
formData.append('conversation_name', conversationName);
- formData.append('conversation_id', conversationID);
formData.append('is_private', isPrivate? '1': '0')
formData.append('bound_service', boundServiceID?boundServiceID: '');
formData.append('is_live_conversation', createLiveConversation? '1': '0')
@@ -793,7 +788,6 @@ document.addEventListener('DOMContentLoaded', (e)=>{
conversationSearchInput.addEventListener('input', async (e)=>{ await renderSuggestions();});
addNewConversation.addEventListener('click', async (e) => {
e.preventDefault();
- const newConversationID = document.getElementById('conversationID');
const newConversationName = document.getElementById('conversationName');
const isPrivate = document.getElementById('isPrivate');
const createLiveConversation = document.getElementById("createLiveConversation");
@@ -813,9 +807,8 @@ document.addEventListener('DOMContentLoaded', (e)=>{
}
}
- createNewConversation(newConversationName.value, isPrivate.checked, newConversationID ? newConversationID.value : null, boundServiceID, createLiveConversation.checked).then(responseOk=>{
+ createNewConversation(newConversationName.value, isPrivate.checked, boundServiceID, createLiveConversation.checked).then(responseOk=>{
newConversationName.value = "";
- newConversationID.value = "";
isPrivate.checked = false;
if(responseOk) {
newConversationModal.modal('hide');