Loading packages/client/src/components/Toolbar/UndoButton.tsx +16 −1 Changes for packages/client/src/components/Toolbar/UndoButton.tsx: 16 added lines, 1 removed line. Original line number Original line Diff line number Diff line Loading @@ -2,6 +2,7 @@ import { Button } from "@nextui-org/react"; import { useAppContext } from "../../contexts/AppContext"; import { useAppContext } from "../../contexts/AppContext"; import network from "../../lib/network"; import network from "../../lib/network"; import { useEffect, useState } from "react"; import { useEffect, useState } from "react"; import { toast } from "react-toastify"; export const UndoButton = () => { export const UndoButton = () => { const { undo, config } = useAppContext<true>(); const { undo, config } = useAppContext<true>(); Loading Loading @@ -34,7 +35,21 @@ export const UndoButton = () => { // ref-ify this? // ref-ify this? function execUndo() { function execUndo() { network.socket.emitWithAck("undo").then((data) => { 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 Changes for packages/lib/src/net.ts: 8 added lines, 1 removed line. Original line number Original line Diff line number Diff line Loading @@ -40,6 +40,7 @@ export interface ClientToServerEvents { ack: ( ack: ( _: PacketAck< _: PacketAck< Pixel, Pixel, | "canvas_frozen" | "no_user" | "no_user" | "invalid_pixel" | "invalid_pixel" | "pixel_cooldown" | "pixel_cooldown" Loading @@ -50,7 +51,12 @@ export interface ClientToServerEvents { ) => void ) => void ) => void; ) => void; undo: ( undo: ( ack: (_: PacketAck<{}, "no_user" | "unavailable" | "pixel_covered">) => void ack: ( _: PacketAck< {}, "canvas_frozen" | "no_user" | "unavailable" | "pixel_covered" > ) => void ) => void; ) => void; subscribe: (topic: Subscription) => void; subscribe: (topic: Subscription) => void; Loading Loading @@ -141,6 +147,7 @@ export type PalleteColor = { export type CanvasConfig = { export type CanvasConfig = { size: [number, number]; size: [number, number]; frozen: boolean; zoom: number; zoom: number; pixel: { pixel: { maxStack: number; maxStack: number; Loading packages/server/prisma/dbml/schema.dbml +2 −0 Changes for packages/server/prisma/dbml/schema.dbml: 2 added lines, 0 removed lines. Original line number Original line Diff line number Diff line Loading @@ -136,6 +136,8 @@ Enum AuditLogAction { BAN_DELETE BAN_DELETE CANVAS_SIZE CANVAS_SIZE CANVAS_FILL CANVAS_FILL CANVAS_FREEZE CANVAS_UNFREEZE } } Ref: Pixel.userId > User.sub Ref: Pixel.userId > User.sub Loading packages/server/prisma/migrations/20240711173241_add_canvas_freeze_audit_log_type/migration.sql 0 → 100644 +10 −0 Changes for packages/server/prisma/migrations/20240711173241_add_canvas_freeze_audit_log_type/migration.sql: 10 added lines, 0 removed lines. Original line number Original line 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 Changes for packages/server/prisma/schema.prisma: 2 added lines, 0 removed lines. Original line number Original line Diff line number Diff line Loading @@ -154,6 +154,8 @@ enum AuditLogAction { BAN_DELETE BAN_DELETE CANVAS_SIZE CANVAS_SIZE CANVAS_FILL CANVAS_FILL CANVAS_FREEZE CANVAS_UNFREEZE } } model AuditLog { model AuditLog { Loading Loading
packages/client/src/components/Toolbar/UndoButton.tsx +16 −1 Changes for packages/client/src/components/Toolbar/UndoButton.tsx: 16 added lines, 1 removed line. Original line number Original line Diff line number Diff line Loading @@ -2,6 +2,7 @@ import { Button } from "@nextui-org/react"; import { useAppContext } from "../../contexts/AppContext"; import { useAppContext } from "../../contexts/AppContext"; import network from "../../lib/network"; import network from "../../lib/network"; import { useEffect, useState } from "react"; import { useEffect, useState } from "react"; import { toast } from "react-toastify"; export const UndoButton = () => { export const UndoButton = () => { const { undo, config } = useAppContext<true>(); const { undo, config } = useAppContext<true>(); Loading Loading @@ -34,7 +35,21 @@ export const UndoButton = () => { // ref-ify this? // ref-ify this? function execUndo() { function execUndo() { network.socket.emitWithAck("undo").then((data) => { 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 Changes for packages/lib/src/net.ts: 8 added lines, 1 removed line. Original line number Original line Diff line number Diff line Loading @@ -40,6 +40,7 @@ export interface ClientToServerEvents { ack: ( ack: ( _: PacketAck< _: PacketAck< Pixel, Pixel, | "canvas_frozen" | "no_user" | "no_user" | "invalid_pixel" | "invalid_pixel" | "pixel_cooldown" | "pixel_cooldown" Loading @@ -50,7 +51,12 @@ export interface ClientToServerEvents { ) => void ) => void ) => void; ) => void; undo: ( undo: ( ack: (_: PacketAck<{}, "no_user" | "unavailable" | "pixel_covered">) => void ack: ( _: PacketAck< {}, "canvas_frozen" | "no_user" | "unavailable" | "pixel_covered" > ) => void ) => void; ) => void; subscribe: (topic: Subscription) => void; subscribe: (topic: Subscription) => void; Loading Loading @@ -141,6 +147,7 @@ export type PalleteColor = { export type CanvasConfig = { export type CanvasConfig = { size: [number, number]; size: [number, number]; frozen: boolean; zoom: number; zoom: number; pixel: { pixel: { maxStack: number; maxStack: number; Loading
packages/server/prisma/dbml/schema.dbml +2 −0 Changes for packages/server/prisma/dbml/schema.dbml: 2 added lines, 0 removed lines. Original line number Original line Diff line number Diff line Loading @@ -136,6 +136,8 @@ Enum AuditLogAction { BAN_DELETE BAN_DELETE CANVAS_SIZE CANVAS_SIZE CANVAS_FILL CANVAS_FILL CANVAS_FREEZE CANVAS_UNFREEZE } } Ref: Pixel.userId > User.sub Ref: Pixel.userId > User.sub Loading
packages/server/prisma/migrations/20240711173241_add_canvas_freeze_audit_log_type/migration.sql 0 → 100644 +10 −0 Changes for packages/server/prisma/migrations/20240711173241_add_canvas_freeze_audit_log_type/migration.sql: 10 added lines, 0 removed lines. Original line number Original line 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 Changes for packages/server/prisma/schema.prisma: 2 added lines, 0 removed lines. Original line number Original line Diff line number Diff line Loading @@ -154,6 +154,8 @@ enum AuditLogAction { BAN_DELETE BAN_DELETE CANVAS_SIZE CANVAS_SIZE CANVAS_FILL CANVAS_FILL CANVAS_FREEZE CANVAS_UNFREEZE } } model AuditLog { model AuditLog { Loading