Skip to content

Commit 5ab7e1e

Browse files
committed
refactoring
1 parent 7c0d3fb commit 5ab7e1e

7 files changed

Lines changed: 32 additions & 65 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ apps/*/.agent
3333
.DS_Store
3434
*.pem
3535

36+
# redis dumps
37+
*.rdb
38+
3639
# debug
3740
npm-debug.log*
3841
yarn-debug.log*

apps/backend/pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ dependencies = [
99
"uvicorn[standard]>=0.35.0",
1010
"pydantic-settings>=2.10.1",
1111
"firebase-admin>=7.1.0",
12-
"pymongo",
1312
"motor>=3.7.0",
1413
"python-jose[cryptography]>=3.5.0",
1514
"boto3>=1.38.0",

apps/web/package.json

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
"@dnd-kit/utilities": "^3.2.2",
1919
"@hookform/resolvers": "^3",
2020
"@monaco-editor/react": "^4.7.0",
21-
"@pdfsmaller/pdf-decrypt": "^1.0.1",
22-
"@pdfsmaller/pdf-encrypt": "^1.0.2",
2321
"@peculiar/x509": "^2.0.0",
2422
"@radix-ui/react-accordion": "^1.2.12",
2523
"@radix-ui/react-alert-dialog": "^1.1.15",
@@ -50,8 +48,6 @@
5048
"@tanstack/react-virtual": "^3.14.3",
5149
"@vercel/analytics": "^1.5.0",
5250
"@vercel/speed-insights": "^1.2.0",
53-
"ajv": "^8.17.1",
54-
"ajv-formats": "^3.0.1",
5551
"bcryptjs": "^3.0.3",
5652
"class-variance-authority": "^0.7.1",
5753
"clsx": "^2.1.1",
@@ -73,14 +69,9 @@
7369
"ipaddr.js": "^2.3.0",
7470
"js-md5": "^0.8.3",
7571
"js-yaml": "^4.1.1",
76-
"jsonpath-plus": "^10.3.0",
7772
"jsonrepair": "^3.13.1",
7873
"jspdf": "^4.2.1",
79-
"jspdf-autotable": "^5.0.7",
8074
"jszip": "^3.10.1",
81-
"katex": "^0.16.25",
82-
"lodash": "^4.17.21",
83-
"lodash.debounce": "^4.0.8",
8475
"lowlight": "^3.3.0",
8576
"lucide-react": "^0.552.0",
8677
"marked": "^18.0.0",
@@ -92,9 +83,6 @@
9283
"next": "^16.2.2",
9384
"next-intl": "^4.8.3",
9485
"next-themes": "^0.4.6",
95-
"novel": "^1.0.2",
96-
"pdf-lib": "^1.17.1",
97-
"pdfjs-dist": "4.10.38",
9886
"pg": "^8.20.0",
9987
"qr-code-styling": "^1.9.2",
10088
"qrcode": "^1.5.4",
@@ -112,7 +100,6 @@
112100
"svgo": "^4.0.0",
113101
"tailwind-merge": "^2.6.0",
114102
"tailwindcss-animate": "^1.0.7",
115-
"tiptap-markdown": "^0.8.10",
116103
"turndown": "^7.2.4",
117104
"ua-parser-js": "^2.0.9",
118105
"use-debounce": "^10.0.6",
@@ -126,21 +113,16 @@
126113
"devDependencies": {
127114
"@eslint/eslintrc": "^3",
128115
"@next/bundle-analyzer": "^15.5.15",
129-
"@shadcn/ui": "^0.0.4",
130-
"@types/date-fns": "^2.6.3",
131116
"@types/file-saver": "^2.0.7",
132117
"@types/jest": "^30.0.0",
133118
"@types/js-yaml": "^4.0.9",
134-
"@types/lodash": "^4.17.20",
135119
"@types/mime-types": "^3.0.1",
136120
"@types/node": "^24",
137121
"@types/pg": "^8.20.0",
138122
"@types/qrcode": "^1.5.6",
139123
"@types/react": "^19",
140124
"@types/react-dom": "^19",
141-
"@types/react-window": "^2.0.0",
142125
"@types/turndown": "^5.0.6",
143-
"@vitalets/google-translate-api": "^9.2.1",
144126
"autoprefixer": "^10.4.21",
145127
"eslint": "^9.39.4",
146128
"eslint-config-next": "16.0.1",

apps/web/src/components/snippet-manager/snippet-manager-tool.tsx

Lines changed: 29 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { memo, useCallback, useEffect, useMemo, useRef, useState, type RefObject
44
import { useInfiniteScroll } from "@/hooks/use-infinite-scroll";
55
import { useAuthState } from "react-firebase-hooks/auth";
66
import { useTranslations } from "next-intl";
7-
import debounce from "lodash/debounce";
7+
import { useDebouncedCallback } from "use-debounce";
88
import { auth } from "@/database/firebase";
99
import {
1010
createCodeSnippetApi,
@@ -313,52 +313,38 @@ export function SnippetManagerTool() {
313313
const selectedIdRef = useRef(selectedId);
314314
selectedIdRef.current = selectedId;
315315

316-
const debouncedSaveCode = useMemo(
317-
() =>
318-
debounce((code: string) => {
319-
const id = selectedIdRef.current;
320-
if (!id) return;
321-
useSnippetManagerStore.getState().updateSnippet(id, { code });
322-
const u = userRef.current;
323-
if (u) {
324-
void patchCodeSnippetApi(id, { code })
325-
.then((s) =>
326-
useSnippetManagerStore.getState().mergeSnippetFromRemote(s)
327-
)
328-
.catch(() => toast.error(t("toastSyncFailed")));
329-
}
330-
}, 450),
331-
[t]
332-
);
333-
334-
const debouncedSetLangCode = useMemo(
335-
() => debounce((code: string) => setDebouncedCode(code), 300),
336-
[]
337-
);
316+
const debouncedSaveCode = useDebouncedCallback((code: string) => {
317+
const id = selectedIdRef.current;
318+
if (!id) return;
319+
useSnippetManagerStore.getState().updateSnippet(id, { code });
320+
const u = userRef.current;
321+
if (u) {
322+
void patchCodeSnippetApi(id, { code })
323+
.then((s) =>
324+
useSnippetManagerStore.getState().mergeSnippetFromRemote(s)
325+
)
326+
.catch(() => toast.error(t("toastSyncFailed")));
327+
}
328+
}, 450);
338329

339-
const debouncedPersistTitleLang = useMemo(
340-
() =>
341-
debounce((title: string, language: string, id: string) => {
342-
useSnippetManagerStore.getState().updateSnippet(id, { title, language });
343-
const u = userRef.current;
344-
if (u) {
345-
void patchCodeSnippetApi(id, { title, language })
346-
.then((s) =>
347-
useSnippetManagerStore.getState().mergeSnippetFromRemote(s)
348-
)
349-
.catch(() => toast.error(t("toastSyncFailed")));
350-
}
351-
}, 400),
352-
[t]
330+
const debouncedSetLangCode = useDebouncedCallback(
331+
(code: string) => setDebouncedCode(code),
332+
300
353333
);
354334

355-
useEffect(
356-
() => () => {
357-
debouncedSaveCode.cancel();
358-
debouncedSetLangCode.cancel();
359-
debouncedPersistTitleLang.cancel();
335+
const debouncedPersistTitleLang = useDebouncedCallback(
336+
(title: string, language: string, id: string) => {
337+
useSnippetManagerStore.getState().updateSnippet(id, { title, language });
338+
const u = userRef.current;
339+
if (u) {
340+
void patchCodeSnippetApi(id, { title, language })
341+
.then((s) =>
342+
useSnippetManagerStore.getState().mergeSnippetFromRemote(s)
343+
)
344+
.catch(() => toast.error(t("toastSyncFailed")));
345+
}
360346
},
361-
[debouncedSaveCode, debouncedSetLangCode, debouncedPersistTitleLang]
347+
400
362348
);
363349

364350
const [storeHydrated, setStoreHydrated] = useState(() => {

dump.rdb

-484 Bytes
Binary file not shown.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
"clean-install": "rimraf node_modules apps/*/node_modules && pnpm install"
1515
},
1616
"devDependencies": {
17-
"next": "16.0.10",
1817
"rimraf": "^6.1.0"
1918
},
2019
"pnpm": {

test-script.js

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)