Skip to content

Commit

Permalink
Fixed issue with creation of the new conversation (#119)
Browse files Browse the repository at this point in the history
  • Loading branch information
NeonKirill authored Dec 14, 2024
1 parent 2db570f commit 79ab764
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
6 changes: 6 additions & 0 deletions chat_client/static/js/base_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
`<div class="alert alert-${alertType} alert-dismissible" role="alert" id="${alertID}">
Expand Down
11 changes: 2 additions & 9 deletions chat_client/static/js/chat_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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");
Expand All @@ -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');
Expand Down

0 comments on commit 79ab764

Please sign in to comment.