Fix: webapp console: Only add the date at the beginning if the last character was a newline

This commit is contained in:
Thomas Basler 2023-04-28 21:03:45 +02:00
parent 3504884836
commit 58214ccbea

View File

@ -43,6 +43,7 @@ export default defineComponent({
dataLoading: true,
consoleBuffer: "",
isAutoScroll: true,
endWithNewline: false,
};
},
created() {
@ -78,10 +79,13 @@ export default defineComponent({
console.log(event);
let outstr = new String(event.data);
let removedNewline = false;
if (outstr.endsWith('\n')) {
outstr = outstr.substring(0, outstr.length - 1);
removedNewline = true;
}
this.consoleBuffer += this.getOutDate() + outstr.replaceAll("\n", "\n" + this.getOutDate());
this.consoleBuffer += (this.endWithNewline ? this.getOutDate() : '') + outstr.replaceAll("\n", "\n" + this.getOutDate());
this.endWithNewline = removedNewline;
this.heartCheck(); // Reset heartbeat detection
};