Ensure no history gets overwritten.
This commit is contained in:
parent
12de0a7c7c
commit
ea8c460db8
1 changed files with 3 additions and 0 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue