Loading packages/client/src/components/Toolbar/CanvasMeta.tsx +2 −1 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ const getTimeLeft = (pixels: { available: number }, config: ClientConfig) => { const cooldown = CanvasLib.getPixelCooldown(pixels.available + 1, config); const pixelExpiresAt = Canvas.instance?.lastPlace && Canvas.instance.lastPlace + cooldown * 1000; const pixelCooldown = pixelExpiresAt && (Date.now() - pixelExpiresAt) / 1000; if (!pixelCooldown) return undefined; Loading @@ -43,7 +44,7 @@ const PlaceCountdown = () => { return ( <> {timeLeft ? pixels.available + 1 < config.canvas.pixel.maxStack && timeLeft + "s" ? pixels.available < config.canvas.pixel.maxStack && timeLeft + "s" : ""} </> ); Loading packages/client/src/lib/canvas.ts +6 −4 Original line number Diff line number Diff line Loading @@ -53,11 +53,9 @@ export class Canvas extends EventEmitter<CanvasEvents> { this.PanZoom.addListener("click", this.handleMouseDown.bind(this)); this.PanZoom.addListener("longPress", this.handleLongPress); Network.waitForState("pixelLastPlaced").then( ([time]) => (this.lastPlace = time) ); Network.on("pixel", this.handlePixel); Network.on("square", this.handleSquare); Network.on("pixelLastPlaced", this.handlePixelLastPlaced); } destroy() { Loading @@ -70,6 +68,7 @@ export class Canvas extends EventEmitter<CanvasEvents> { Network.off("pixel", this.handlePixel); Network.off("square", this.handleSquare); Network.off("pixelLastPlaced", this.handlePixelLastPlaced); } /** Loading Loading @@ -309,6 +308,10 @@ export class Canvas extends EventEmitter<CanvasEvents> { getRenderer().usePixel({ x, y, hex: palette?.hex || "null" }); }; handlePixelLastPlaced = (time: number) => { this.lastPlace = time; }; Pallete = { getColor: (colorId: number) => { return this.config.pallete.colors.find((c) => c.id === colorId); Loading Loading @@ -358,7 +361,6 @@ export class Canvas extends EventEmitter<CanvasEvents> { ) .then((ack) => { if (ack.success) { this.lastPlace = Date.now(); this.handlePixel(ack.data); } else { console.warn( Loading packages/server/prisma/dbml/schema.dbml +1 −1 Original line number Diff line number Diff line Loading @@ -12,7 +12,7 @@ Table User { display_name String picture_url String profile_url String lastPixelTime DateTime [default: `now()`, not null] lastTimeGainStarted DateTime [default: `now()`, not null] pixelStack Int [not null, default: 0] undoExpires DateTime isAdmin Boolean [not null, default: false] Loading packages/server/prisma/migrations/20240712202519_rename_last_stack_change/migration.sql 0 → 100644 +1 −0 Original line number Diff line number Diff line ALTER TABLE "User" RENAME COLUMN "lastPixelTime" TO "lastTimeGainStarted"; No newline at end of file packages/server/prisma/schema.prisma +1 −1 Original line number Diff line number Diff line Loading @@ -25,7 +25,7 @@ model User { picture_url String? profile_url String? lastPixelTime DateTime @default(now()) // the time the last pixel was placed at lastTimeGainStarted DateTime @default(now()) // the time base used to determine the amount of stack the user should gain pixelStack Int @default(0) // amount of pixels stacked for this user undoExpires DateTime? // when the undo for the most recent pixel expires at Loading Loading
packages/client/src/components/Toolbar/CanvasMeta.tsx +2 −1 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ const getTimeLeft = (pixels: { available: number }, config: ClientConfig) => { const cooldown = CanvasLib.getPixelCooldown(pixels.available + 1, config); const pixelExpiresAt = Canvas.instance?.lastPlace && Canvas.instance.lastPlace + cooldown * 1000; const pixelCooldown = pixelExpiresAt && (Date.now() - pixelExpiresAt) / 1000; if (!pixelCooldown) return undefined; Loading @@ -43,7 +44,7 @@ const PlaceCountdown = () => { return ( <> {timeLeft ? pixels.available + 1 < config.canvas.pixel.maxStack && timeLeft + "s" ? pixels.available < config.canvas.pixel.maxStack && timeLeft + "s" : ""} </> ); Loading
packages/client/src/lib/canvas.ts +6 −4 Original line number Diff line number Diff line Loading @@ -53,11 +53,9 @@ export class Canvas extends EventEmitter<CanvasEvents> { this.PanZoom.addListener("click", this.handleMouseDown.bind(this)); this.PanZoom.addListener("longPress", this.handleLongPress); Network.waitForState("pixelLastPlaced").then( ([time]) => (this.lastPlace = time) ); Network.on("pixel", this.handlePixel); Network.on("square", this.handleSquare); Network.on("pixelLastPlaced", this.handlePixelLastPlaced); } destroy() { Loading @@ -70,6 +68,7 @@ export class Canvas extends EventEmitter<CanvasEvents> { Network.off("pixel", this.handlePixel); Network.off("square", this.handleSquare); Network.off("pixelLastPlaced", this.handlePixelLastPlaced); } /** Loading Loading @@ -309,6 +308,10 @@ export class Canvas extends EventEmitter<CanvasEvents> { getRenderer().usePixel({ x, y, hex: palette?.hex || "null" }); }; handlePixelLastPlaced = (time: number) => { this.lastPlace = time; }; Pallete = { getColor: (colorId: number) => { return this.config.pallete.colors.find((c) => c.id === colorId); Loading Loading @@ -358,7 +361,6 @@ export class Canvas extends EventEmitter<CanvasEvents> { ) .then((ack) => { if (ack.success) { this.lastPlace = Date.now(); this.handlePixel(ack.data); } else { console.warn( Loading
packages/server/prisma/dbml/schema.dbml +1 −1 Original line number Diff line number Diff line Loading @@ -12,7 +12,7 @@ Table User { display_name String picture_url String profile_url String lastPixelTime DateTime [default: `now()`, not null] lastTimeGainStarted DateTime [default: `now()`, not null] pixelStack Int [not null, default: 0] undoExpires DateTime isAdmin Boolean [not null, default: false] Loading
packages/server/prisma/migrations/20240712202519_rename_last_stack_change/migration.sql 0 → 100644 +1 −0 Original line number Diff line number Diff line ALTER TABLE "User" RENAME COLUMN "lastPixelTime" TO "lastTimeGainStarted"; No newline at end of file
packages/server/prisma/schema.prisma +1 −1 Original line number Diff line number Diff line Loading @@ -25,7 +25,7 @@ model User { picture_url String? profile_url String? lastPixelTime DateTime @default(now()) // the time the last pixel was placed at lastTimeGainStarted DateTime @default(now()) // the time base used to determine the amount of stack the user should gain pixelStack Int @default(0) // amount of pixels stacked for this user undoExpires DateTime? // when the undo for the most recent pixel expires at Loading