diff --git a/public/script.js b/public/script.js index 0dc5c3c0a..672a6c511 100644 --- a/public/script.js +++ b/public/script.js @@ -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; diff --git a/server.js b/server.js index 8a343ba20..43e0c2f37 100644 --- a/server.js +++ b/server.js @@ -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();