hmm, weird db error

This commit is contained in:
Evert Prants 2022-04-03 18:15:35 +03:00
parent 55275ba9be
commit a27941bb7d
Signed by: evert
GPG Key ID: 1688DA83D222D0B5
3 changed files with 5 additions and 3 deletions

View File

@ -149,7 +149,7 @@ io.on('connection', (socket) => {
});
socket.on('color', ({ c, x, y, t }: Placement) => {
if (!user || c > 0xffffff || c < 0) {
if (!user || c > 0xffffff || c < 0 || c === null) {
return;
}

View File

@ -19,13 +19,14 @@ export class History {
}
async insert(record: CanvasRecord): Promise<void> {
const color = record.color ? record.color : 0;
await this.db.run(
`INSERT INTO Placement (user, x, y, ts, color) VALUES (?,?,?,?,?)`,
record.user,
record.x,
record.y,
record.ts,
record.color,
color,
);
}

View File

@ -14,6 +14,7 @@ export class Imager {
private _size: number,
private _store = join(__dirname, '..', '..', '..', 'canvas.png'),
private _debounce = 5000,
private _resaveInterval = 60000,
) {}
async toImage(array: Uint32Array): Promise<Buffer> {
@ -81,7 +82,7 @@ export class Imager {
this._lastSave = Date.now();
};
if (force || this._lastSave < Date.now() - this._debounce * 2) {
if (force || this._lastSave < Date.now() - this._resaveInterval) {
saveFn().catch((e) => console.error(e));
return;
}