Fix colons hiding in group chats. Fix jsonl chat imports hanging

This commit is contained in:
SillyLossy
2023-05-01 21:03:16 +03:00
parent 1fe0310de3
commit c4434c3747
2 changed files with 6 additions and 9 deletions

View File

@@ -969,13 +969,10 @@ function messageFormating(mes, ch_name, isSystem, forceAvatar) {
});
}
if (forceAvatar) {
if (ch_name && (forceAvatar || ch_name !== name1)) {
mes = mes.replaceAll(ch_name + ":", "");
}
if (ch_name !== name1) {
mes = mes.replaceAll(name2 + ":", "");
}
return mes;
}
@@ -3135,7 +3132,7 @@ function messageEditAuto(div) {
}
chat[this_edit_mes_id]["extra"]["bias"] = bias ?? null;
mesBlock.find(".mes_text").val('');
mesBlock.find(".mes_text").val(messageFormating(text));
mesBlock.find(".mes_text").val(messageFormating(text, this_edit_mes_chname, chat[this_edit_mes_id].is_system, chat[this_edit_mes_id].force_avatar));
saveChatDebounced();
}
@@ -4950,7 +4947,7 @@ $(document).ready(function () {
var text = chat[edit_mes_id]["mes"];
if (chat[edit_mes_id]["is_user"]) {
this_edit_mes_chname = name1;
} else if (chat[edit_mes_id]["forced_avatar"]) {
} else if (chat[edit_mes_id]["force_avatar"]) {
this_edit_mes_chname = chat[edit_mes_id]["name"];
} else {
this_edit_mes_chname = name2;
@@ -4995,7 +4992,7 @@ $(document).ready(function () {
$(this)
.closest(".mes_block")
.find(".mes_text")
.append(messageFormating(text, this_edit_mes_chname));
.append(messageFormating(text, this_edit_mes_chname, chat[this_edit_mes_id].is_system, chat[this_edit_mes_id].force_avatar));
appendImageToMessage(chat[this_edit_mes_id], $(this).closest(".mes"));
addCopyToCodeBlocks($(this).closest(".mes"));
this_edit_mes_id = undefined;

View File

@@ -1618,7 +1618,7 @@ app.post("/importchat", urlencodedParser, function (request, response) {
rl.once('line', (line) => {
let jsonData = json5.parse(line);
if (jsonData.user_name !== undefined) {
if (jsonData.user_name !== undefined || jsonData.name !== undefined) {
//console.log(humanizedISO8601DateTime()+':/importchat copying chat as '+ch_name+' - '+humanizedISO8601DateTime()+'.jsonl');
fs.copyFile('./uploads/' + filedata.filename, chatsPath + avatar_url + '/' + ch_name + ' - ' + humanizedISO8601DateTime() + '.jsonl', (err) => { //added character name and replaced Date.now() with humanizedISO8601DateTime
if (err) {
@@ -1630,7 +1630,7 @@ app.post("/importchat", urlencodedParser, function (request, response) {
}
});
} else {
//response.send({error:true});
response.send({error:true});
return;
}
rl.close();