Ensure no history gets overwritten.

This commit is contained in:
JOLIMAITRE Matthieu 2025-05-28 20:22:30 +02:00
parent 12de0a7c7c
commit ea8c460db8

View file

@ -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()