Loading packages/client/src/components/Toolbar/UndoButton.tsx +16 −1 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ import { Button } from "@nextui-org/react"; import { useAppContext } from "../../contexts/AppContext"; import network from "../../lib/network"; import { useEffect, useState } from "react"; import { toast } from "react-toastify"; export const UndoButton = () => { const { undo, config } = useAppContext<true>(); Loading Loading @@ -34,7 +35,21 @@ export const UndoButton = () => { // ref-ify this? function execUndo() { network.socket.emitWithAck("undo").then((data) => { console.log("undo", data); if (data.success) { console.log("Undo pixel successful"); } else { console.log("Undo pixel error", data); switch (data.error) { case "pixel_covered": toast.error("You cannot undo a covered pixel"); break; case "unavailable": toast.error("You have no undo available"); break; default: toast.error("Undo error: " + data.error); } } }); } Loading packages/lib/src/net.ts +8 −1 Original line number Diff line number Diff line Loading @@ -40,6 +40,7 @@ export interface ClientToServerEvents { ack: ( _: PacketAck< Pixel, | "canvas_frozen" | "no_user" | "invalid_pixel" | "pixel_cooldown" Loading @@ -50,7 +51,12 @@ export interface ClientToServerEvents { ) => void ) => void; undo: ( ack: (_: PacketAck<{}, "no_user" | "unavailable" | "pixel_covered">) => void ack: ( _: PacketAck< {}, "canvas_frozen" | "no_user" | "unavailable" | "pixel_covered" > ) => void ) => void; subscribe: (topic: Subscription) => void; Loading Loading @@ -141,6 +147,7 @@ export type PalleteColor = { export type CanvasConfig = { size: [number, number]; frozen: boolean; zoom: number; pixel: { maxStack: number; Loading packages/server/prisma/dbml/schema.dbml +2 −0 Original line number Diff line number Diff line Loading @@ -136,6 +136,8 @@ Enum AuditLogAction { BAN_DELETE CANVAS_SIZE CANVAS_FILL CANVAS_FREEZE CANVAS_UNFREEZE } Ref: Pixel.userId > User.sub Loading packages/server/prisma/migrations/20240711173241_add_canvas_freeze_audit_log_type/migration.sql 0 → 100644 +10 −0 Original line number Diff line number Diff line -- AlterEnum -- This migration adds more than one value to an enum. -- With PostgreSQL versions 11 and earlier, this is not possible -- in a single migration. This can be worked around by creating -- multiple migrations, each migration adding only one value to -- the enum. ALTER TYPE "AuditLogAction" ADD VALUE 'CANVAS_FREEZE'; ALTER TYPE "AuditLogAction" ADD VALUE 'CANVAS_UNFREEZE'; packages/server/prisma/schema.prisma +2 −0 Original line number Diff line number Diff line Loading @@ -154,6 +154,8 @@ enum AuditLogAction { BAN_DELETE CANVAS_SIZE CANVAS_FILL CANVAS_FREEZE CANVAS_UNFREEZE } model AuditLog { Loading Loading
packages/client/src/components/Toolbar/UndoButton.tsx +16 −1 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ import { Button } from "@nextui-org/react"; import { useAppContext } from "../../contexts/AppContext"; import network from "../../lib/network"; import { useEffect, useState } from "react"; import { toast } from "react-toastify"; export const UndoButton = () => { const { undo, config } = useAppContext<true>(); Loading Loading @@ -34,7 +35,21 @@ export const UndoButton = () => { // ref-ify this? function execUndo() { network.socket.emitWithAck("undo").then((data) => { console.log("undo", data); if (data.success) { console.log("Undo pixel successful"); } else { console.log("Undo pixel error", data); switch (data.error) { case "pixel_covered": toast.error("You cannot undo a covered pixel"); break; case "unavailable": toast.error("You have no undo available"); break; default: toast.error("Undo error: " + data.error); } } }); } Loading
packages/lib/src/net.ts +8 −1 Original line number Diff line number Diff line Loading @@ -40,6 +40,7 @@ export interface ClientToServerEvents { ack: ( _: PacketAck< Pixel, | "canvas_frozen" | "no_user" | "invalid_pixel" | "pixel_cooldown" Loading @@ -50,7 +51,12 @@ export interface ClientToServerEvents { ) => void ) => void; undo: ( ack: (_: PacketAck<{}, "no_user" | "unavailable" | "pixel_covered">) => void ack: ( _: PacketAck< {}, "canvas_frozen" | "no_user" | "unavailable" | "pixel_covered" > ) => void ) => void; subscribe: (topic: Subscription) => void; Loading Loading @@ -141,6 +147,7 @@ export type PalleteColor = { export type CanvasConfig = { size: [number, number]; frozen: boolean; zoom: number; pixel: { maxStack: number; Loading
packages/server/prisma/dbml/schema.dbml +2 −0 Original line number Diff line number Diff line Loading @@ -136,6 +136,8 @@ Enum AuditLogAction { BAN_DELETE CANVAS_SIZE CANVAS_FILL CANVAS_FREEZE CANVAS_UNFREEZE } Ref: Pixel.userId > User.sub Loading
packages/server/prisma/migrations/20240711173241_add_canvas_freeze_audit_log_type/migration.sql 0 → 100644 +10 −0 Original line number Diff line number Diff line -- AlterEnum -- This migration adds more than one value to an enum. -- With PostgreSQL versions 11 and earlier, this is not possible -- in a single migration. This can be worked around by creating -- multiple migrations, each migration adding only one value to -- the enum. ALTER TYPE "AuditLogAction" ADD VALUE 'CANVAS_FREEZE'; ALTER TYPE "AuditLogAction" ADD VALUE 'CANVAS_UNFREEZE';
packages/server/prisma/schema.prisma +2 −0 Original line number Diff line number Diff line Loading @@ -154,6 +154,8 @@ enum AuditLogAction { BAN_DELETE CANVAS_SIZE CANVAS_FILL CANVAS_FREEZE CANVAS_UNFREEZE } model AuditLog { Loading