From ea8c460db87f9c635d8d0a1e35f18fa033d3fe6f Mon Sep 17 00:00:00 2001 From: JOLIMAITRE Matthieu Date: Wed, 28 May 2025 20:22:30 +0200 Subject: [PATCH] Ensure no history gets overwritten. --- src/lib/history.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/lib/history.ts b/src/lib/history.ts index ad15cdf..4334ac2 100644 --- a/src/lib/history.ts +++ b/src/lib/history.ts @@ -8,6 +8,9 @@ export class History { ) {} public async push(value: Message) { + const content = await Deno.readTextFile(this.path) + const { messages } = JSON.parse(content) + this.messages = messages this.messages.push(value) while (this.messages.length > this.limit) this.messages.splice(0, 1) await this.save()