searchPrivate

This commit is contained in:
Pierre HUBERT 2021-03-06 15:04:10 +01:00
parent 4a02338d38
commit b44755b91e
4 changed files with 57 additions and 39 deletions

View File

@ -196,6 +196,10 @@ const ConvChatWindow = {
}); });
// =========== SEND FILES ===========
//Add image button //Add image button
const fileButton = createElem2({ const fileButton = createElem2({
appendTo: buttonGroup, appendTo: buttonGroup,
@ -229,6 +233,14 @@ const ConvChatWindow = {
type: "i", type: "i",
class: "fa fa-send-o", class: "fa fa-send-o",
}); });
console.info(infosBox)
//ConversationsUtils.registerInputToSendFile(, fileInput, formContainer);
// =========== /SEND FILES ===========
//Prevent textarea from adding a new line when pressing enter //Prevent textarea from adding a new line when pressing enter
$(inputText).keypress(function(event){ $(inputText).keypress(function(event){

View File

@ -237,9 +237,6 @@ const ConversationsInterface = {
callback(result); callback(result);
}); });
//Success
return true;
}, },
/** /**

View File

@ -210,6 +210,50 @@ const ConversationsUtils = {
"2": users.get(msg.server_message.user_removed).fullName "2": users.get(msg.server_message.user_removed).fullName
}); });
} }
},
/**
* @param {number} convID
* @param {HTMLInputElement} input
* @param {HTMLElement} target
*/
registerInputToSendFile: function(convID, fileInput, splashScreenTarget){
fileInput.addEventListener("change", async (e) => {
e.preventDefault();
let el;
try {
if(fileInput.files.length == 0)
return;
const file = fileInput.files[0];
if (ServerConfig.conf.allowed_conversation_files_type.indexOf(file.type) < 0) {
notify(tr("This file type is not allowed!"), "danger")
return;
}
if (file.size > ServerConfig.conf.conversation_files_max_size) {
notify(tr("This file is too big (max file size: %1%)", {"1": fileSizeToHuman(ServerConfig.conf.conversation_files_max_size)}), "danger");
return;
}
el = Page.showTransparentWaitSplashScreen(splashScreenTarget);
await ConversationsInterface.sendMessage(convID, null, fileInput);
}
catch(e) {
console.error(e);
notify(tr("Failed to send file!"), "danger");
}
el.remove();
});
} }
} }

View File

@ -445,42 +445,7 @@ const ConversationPageConvPart = {
class: "fa fa-plus" class: "fa fa-plus"
}); });
fileInput.addEventListener("change", async (e) => { ConversationsUtils.registerInputToSendFile(this._conv_info.id, fileInput, formContainer);
e.preventDefault();
let el;
try {
if(fileInput.files.length == 0)
return;
const file = fileInput.files[0];
if (ServerConfig.conf.allowed_conversation_files_type.indexOf(file.type) < 0) {
notify(tr("This file type is not allowed!"), "danger")
return;
}
if (file.size > ServerConfig.conf.conversation_files_max_size) {
notify(tr("This file is too big (max file size: %1%)", {"1": fileSizeToHuman(ServerConfig.conf.conversation_files_max_size)}), "danger");
return;
}
el = Page.showTransparentWaitSplashScreen();
await ConversationsInterface.sendMessage(this._conv_info.id, null, fileInput);
}
catch(e) {
console.error(e);
notify(tr("Failed to send file!"), "danger");
}
el.remove();
});
// ==== /FILE INPUT ==== // ==== /FILE INPUT ====