Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Mar 9, 2025
1 parent d2c8707 commit 0bd27b8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
20 changes: 8 additions & 12 deletions frontend/src/components/scratchpad/scratchpad-storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import { ZodLocalStorage } from "@/utils/localStorage";
*/
export const getStorageKey = (): string => {
const filename = getFilenameFromDOM();
return filename ? `marimo:scratchpad:${filename}` : "marimo:scratchpad:default";
return filename
? `marimo:scratchpad:${filename}`
: "marimo:scratchpad:default";
};

// Schema for the scratchpad code
Expand All @@ -22,24 +24,18 @@ const scratchpadCodeSchema = z.string().default("");
export const scratchpadStorage = new ZodLocalStorage<string>(
getStorageKey(),
scratchpadCodeSchema,
() => ""
() => "",
);

/**
* Atom for the scratchpad code
* Using atomWithStorage to persist the code in localStorage
*/
export const scratchpadCodeAtom = atomWithStorage<string>(
getStorageKey(),
""
);
export const scratchpadCodeAtom = atomWithStorage<string>(getStorageKey(), "");

/**
* Action to update the scratchpad code in localStorage
*/
export const updateScratchpadCodeAtom = atom(
null,
(get, set, code: string) => {
set(scratchpadCodeAtom, code);
}
);
export const updateScratchpadCodeAtom = atom(null, (get, set, code: string) => {
set(scratchpadCodeAtom, code);
});
6 changes: 3 additions & 3 deletions frontend/src/components/scratchpad/scratchpad.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ import {
scratchpadHistoryAtom,
historyVisibleAtom,
} from "./scratchpad-history";
import {
scratchpadCodeAtom,
updateScratchpadCodeAtom
import {
scratchpadCodeAtom,
updateScratchpadCodeAtom,
} from "./scratchpad-storage";
import { cn } from "@/utils/cn";
import type { CellConfig } from "@/core/network/types";
Expand Down

0 comments on commit 0bd27b8

Please sign in to comment.