Commit b38d84cd authored by Grant's avatar Grant
Browse files

Merge branch 'main' into feat-pixel-placement-log

parents b57f1a23 a659bfcf
Loading
Loading
Loading
Loading
+16 −1
Original line number Diff line number Diff line
@@ -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>();
@@ -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);
        }
      }
    });
  }

+8 −1
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ export interface ClientToServerEvents {
    ack: (
      _: PacketAck<
        Pixel,
        | "canvas_frozen"
        | "no_user"
        | "invalid_pixel"
        | "pixel_cooldown"
@@ -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;
@@ -141,6 +147,7 @@ export type PalleteColor = {

export type CanvasConfig = {
  size: [number, number];
  frozen: boolean;
  zoom: number;
  pixel: {
    maxStack: number;
+2 −0
Original line number Diff line number Diff line
@@ -136,6 +136,8 @@ Enum AuditLogAction {
  BAN_DELETE
  CANVAS_SIZE
  CANVAS_FILL
  CANVAS_FREEZE
  CANVAS_UNFREEZE
}

Ref: Pixel.userId > User.sub
+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';
+2 −0
Original line number Diff line number Diff line
@@ -154,6 +154,8 @@ enum AuditLogAction {
  BAN_DELETE
  CANVAS_SIZE
  CANVAS_FILL
  CANVAS_FREEZE
  CANVAS_UNFREEZE
}

model AuditLog {
Loading