From 7555757ca855e0e72e4af91f9ca9501630bd3df4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Feb 2025 01:00:08 +0000 Subject: [PATCH 1/4] chore(deps): bump @tanstack/react-router from 1.109.2 to 1.111.3 Bumps [@tanstack/react-router](https://github.com/TanStack/router/tree/HEAD/packages/react-router) from 1.109.2 to 1.111.3. - [Release notes](https://github.com/TanStack/router/releases) - [Commits](https://github.com/TanStack/router/commits/v1.111.3/packages/react-router) --- updated-dependencies: - dependency-name: "@tanstack/react-router" dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- package.json | 2 +- pnpm-lock.yaml | 36 ++++++++++++++++++------------------ 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/package.json b/package.json index de0fc79..06648f5 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ "@radix-ui/react-toggle-group": "^1.1.2", "@radix-ui/react-tooltip": "^1.1.7", "@tanstack/react-query": "^5.66.9", - "@tanstack/react-router": "^1.109.2", + "@tanstack/react-router": "^1.111.3", "@tiptap/extension-code-block-lowlight": "^2.11.5", "@tiptap/extension-color": "^2.11.5", "@tiptap/extension-heading": "^2.11.5", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 7e03b2d..b366511 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -81,8 +81,8 @@ importers: specifier: ^5.66.9 version: 5.66.9(react@19.0.0) '@tanstack/react-router': - specifier: ^1.109.2 - version: 1.109.2(react-dom@19.0.0(react@19.0.0))(react@19.0.0) + specifier: ^1.111.3 + version: 1.111.3(react-dom@19.0.0(react@19.0.0))(react@19.0.0) '@tiptap/extension-code-block-lowlight': specifier: ^2.11.5 version: 2.11.5(@tiptap/core@2.11.5(@tiptap/pm@2.11.5))(@tiptap/extension-code-block@2.11.5(@tiptap/core@2.11.5(@tiptap/pm@2.11.5))(@tiptap/pm@2.11.5))(@tiptap/pm@2.11.5)(highlight.js@11.11.1)(lowlight@3.3.0) @@ -197,10 +197,10 @@ importers: version: 4.0.8 '@tanstack/router-devtools': specifier: ^1.109.2 - version: 1.109.2(@tanstack/react-router@1.109.2(react-dom@19.0.0(react@19.0.0))(react@19.0.0))(csstype@3.1.3)(react-dom@19.0.0(react@19.0.0))(react@19.0.0) + version: 1.109.2(@tanstack/react-router@1.111.3(react-dom@19.0.0(react@19.0.0))(react@19.0.0))(csstype@3.1.3)(react-dom@19.0.0(react@19.0.0))(react@19.0.0) '@tanstack/router-plugin': specifier: ^1.109.2 - version: 1.109.2(@tanstack/react-router@1.109.2(react-dom@19.0.0(react@19.0.0))(react@19.0.0))(vite@6.1.1(@types/node@22.13.5)(jiti@2.4.2)(lightningcss@1.29.1)(tsx@4.19.3)(yaml@2.7.0)) + version: 1.109.2(@tanstack/react-router@1.111.3(react-dom@19.0.0(react@19.0.0))(react@19.0.0))(vite@6.1.1(@types/node@22.13.5)(jiti@2.4.2)(lightningcss@1.29.1)(tsx@4.19.3)(yaml@2.7.0)) '@types/better-sqlite3': specifier: ^7.6.12 version: 7.6.12 @@ -1962,8 +1962,8 @@ packages: peerDependencies: react: ^18 || ^19 - '@tanstack/react-router@1.109.2': - resolution: {integrity: sha512-cJZGIvYIrd5lcwbwoB2vxJe379TQZIM5/RAzlDSrvV5KAPlkmK3cqZHZ8zPrsZIBASEyERM8Od+jM9s3qDTXkA==} + '@tanstack/react-router@1.111.3': + resolution: {integrity: sha512-OsqAuExa4WF7+BbjENWlb4dHRousxU5jahJHUPyO0gaUcWwzaVloJKi8lTFTd1PWQ8waz5V7BedkV67hd8syUw==} engines: {node: '>=12'} peerDependencies: react: '>=18.0.0 || >=19.0.0' @@ -1975,8 +1975,8 @@ packages: react: ^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 react-dom: ^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 - '@tanstack/router-core@1.108.0': - resolution: {integrity: sha512-lo6Nqdp8gxWNZ8YZ6UhiQgR0CgcAiMaw1cxgKK7M4u3nFFwqW7Hzycl5ik1l3NRh5/pQVK+OVzlKok5rrrHxSg==} + '@tanstack/router-core@1.111.3': + resolution: {integrity: sha512-q+CHuOhTgqHudVKijL89jIdLe5A00RzV8ZMMSi4qiHGnggm4nisF8eSE3dFQaic1+YFk1wR7dfFA2hvkr1hFIA==} engines: {node: '>=12'} '@tanstack/router-devtools@1.109.2': @@ -6896,11 +6896,11 @@ snapshots: '@tanstack/query-core': 5.66.4 react: 19.0.0 - '@tanstack/react-router@1.109.2(react-dom@19.0.0(react@19.0.0))(react@19.0.0)': + '@tanstack/react-router@1.111.3(react-dom@19.0.0(react@19.0.0))(react@19.0.0)': dependencies: '@tanstack/history': 1.99.13 '@tanstack/react-store': 0.7.0(react-dom@19.0.0(react@19.0.0))(react@19.0.0) - '@tanstack/router-core': 1.108.0 + '@tanstack/router-core': 1.111.3 jsesc: 3.1.0 react: 19.0.0 react-dom: 19.0.0(react@19.0.0) @@ -6914,14 +6914,14 @@ snapshots: react-dom: 19.0.0(react@19.0.0) use-sync-external-store: 1.4.0(react@19.0.0) - '@tanstack/router-core@1.108.0': + '@tanstack/router-core@1.111.3': dependencies: '@tanstack/history': 1.99.13 '@tanstack/store': 0.7.0 - '@tanstack/router-devtools@1.109.2(@tanstack/react-router@1.109.2(react-dom@19.0.0(react@19.0.0))(react@19.0.0))(csstype@3.1.3)(react-dom@19.0.0(react@19.0.0))(react@19.0.0)': + '@tanstack/router-devtools@1.109.2(@tanstack/react-router@1.111.3(react-dom@19.0.0(react@19.0.0))(react@19.0.0))(csstype@3.1.3)(react-dom@19.0.0(react@19.0.0))(react@19.0.0)': dependencies: - '@tanstack/react-router': 1.109.2(react-dom@19.0.0(react@19.0.0))(react@19.0.0) + '@tanstack/react-router': 1.111.3(react-dom@19.0.0(react@19.0.0))(react@19.0.0) clsx: 2.1.1 goober: 2.1.16(csstype@3.1.3) react: 19.0.0 @@ -6929,16 +6929,16 @@ snapshots: optionalDependencies: csstype: 3.1.3 - '@tanstack/router-generator@1.109.2(@tanstack/react-router@1.109.2(react-dom@19.0.0(react@19.0.0))(react@19.0.0))': + '@tanstack/router-generator@1.109.2(@tanstack/react-router@1.111.3(react-dom@19.0.0(react@19.0.0))(react@19.0.0))': dependencies: '@tanstack/virtual-file-routes': 1.99.0 prettier: 3.5.2 tsx: 4.19.3 zod: 3.24.2 optionalDependencies: - '@tanstack/react-router': 1.109.2(react-dom@19.0.0(react@19.0.0))(react@19.0.0) + '@tanstack/react-router': 1.111.3(react-dom@19.0.0(react@19.0.0))(react@19.0.0) - '@tanstack/router-plugin@1.109.2(@tanstack/react-router@1.109.2(react-dom@19.0.0(react@19.0.0))(react@19.0.0))(vite@6.1.1(@types/node@22.13.5)(jiti@2.4.2)(lightningcss@1.29.1)(tsx@4.19.3)(yaml@2.7.0))': + '@tanstack/router-plugin@1.109.2(@tanstack/react-router@1.111.3(react-dom@19.0.0(react@19.0.0))(react@19.0.0))(vite@6.1.1(@types/node@22.13.5)(jiti@2.4.2)(lightningcss@1.29.1)(tsx@4.19.3)(yaml@2.7.0))': dependencies: '@babel/core': 7.26.9 '@babel/plugin-syntax-jsx': 7.25.9(@babel/core@7.26.9) @@ -6946,7 +6946,7 @@ snapshots: '@babel/template': 7.26.9 '@babel/traverse': 7.26.9 '@babel/types': 7.26.9 - '@tanstack/router-generator': 1.109.2(@tanstack/react-router@1.109.2(react-dom@19.0.0(react@19.0.0))(react@19.0.0)) + '@tanstack/router-generator': 1.109.2(@tanstack/react-router@1.111.3(react-dom@19.0.0(react@19.0.0))(react@19.0.0)) '@tanstack/router-utils': 1.102.2 '@tanstack/virtual-file-routes': 1.99.0 '@types/babel__core': 7.20.5 @@ -6957,7 +6957,7 @@ snapshots: unplugin: 2.2.0 zod: 3.24.2 optionalDependencies: - '@tanstack/react-router': 1.109.2(react-dom@19.0.0(react@19.0.0))(react@19.0.0) + '@tanstack/react-router': 1.111.3(react-dom@19.0.0(react@19.0.0))(react@19.0.0) vite: 6.1.1(@types/node@22.13.5)(jiti@2.4.2)(lightningcss@1.29.1)(tsx@4.19.3)(yaml@2.7.0) transitivePeerDependencies: - supports-color From 908bc8ca62dcc72c708dd3c2c82595b5076feecc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Feb 2025 01:00:31 +0000 Subject: [PATCH 2/4] chore(deps): bump tailwind-merge from 3.0.1 to 3.0.2 Bumps [tailwind-merge](https://github.com/dcastil/tailwind-merge) from 3.0.1 to 3.0.2. - [Release notes](https://github.com/dcastil/tailwind-merge/releases) - [Commits](https://github.com/dcastil/tailwind-merge/compare/v3.0.1...v3.0.2) --- updated-dependencies: - dependency-name: tailwind-merge dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- package.json | 2 +- pnpm-lock.yaml | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index de0fc79..e116bec 100644 --- a/package.json +++ b/package.json @@ -82,7 +82,7 @@ "react-hook-form": "^7.54.2", "react-medium-image-zoom": "^5.2.14", "react-resizable-panels": "^2.1.7", - "tailwind-merge": "^3.0.1", + "tailwind-merge": "^3.0.2", "tailwindcss-animate": "^1.0.7", "tiptap-extension-global-drag-handle": "^0.1.16", "zod": "^3.24.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 7e03b2d..a899876 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -162,8 +162,8 @@ importers: specifier: ^2.1.7 version: 2.1.7(react-dom@19.0.0(react@19.0.0))(react@19.0.0) tailwind-merge: - specifier: ^3.0.1 - version: 3.0.1 + specifier: ^3.0.2 + version: 3.0.2 tailwindcss-animate: specifier: ^1.0.7 version: 1.0.7(tailwindcss@4.0.8) @@ -5026,8 +5026,8 @@ packages: resolution: {integrity: sha512-vrozgXDQwYO72vHjUb/HnFbQx1exDjoKzqx23aXEg2a9VIg2TSFZ8FmeZpTjUCFMYw7mpX4BE2SFu8wI7asYsw==} engines: {node: ^14.18.0 || >=16.0.0} - tailwind-merge@3.0.1: - resolution: {integrity: sha512-AvzE8FmSoXC7nC+oU5GlQJbip2UO7tmOhOfQyOmPhrStOGXHU08j8mZEHZ4BmCqY5dWTCo4ClWkNyRNx1wpT0g==} + tailwind-merge@3.0.2: + resolution: {integrity: sha512-l7z+OYZ7mu3DTqrL88RiKrKIqO3NcpEO8V/Od04bNpvk0kiIFndGEoqfuzvj4yuhRkHKjRkII2z+KS2HfPcSxw==} tailwindcss-animate@1.0.7: resolution: {integrity: sha512-bl6mpH3T7I3UFxuvDEXLxy/VuFxBk5bbzplh7tXI68mwMokNYd1t9qPBHlnyTwfa4JGC4zP516I1hYYtQ/vspA==} @@ -10457,7 +10457,7 @@ snapshots: '@pkgr/core': 0.1.1 tslib: 2.8.1 - tailwind-merge@3.0.1: {} + tailwind-merge@3.0.2: {} tailwindcss-animate@1.0.7(tailwindcss@4.0.8): dependencies: From 5b564c0325dbc7e4d1d7d24a99e066d25120c1df Mon Sep 17 00:00:00 2001 From: devtayyab <93027825+Your-Ehsan@users.noreply.github.com> Date: Mon, 24 Feb 2025 18:13:07 +0500 Subject: [PATCH 3/4] fix(#52): add favorite option in notes --- .../0006_great_supreme_intelligence.sql | 1 + .../migrations/meta/0006_snapshot.json | 123 ++++++++++++++++++ .../database/migrations/meta/_journal.json | 7 + src/main/drizzle/schema.ts | 1 + src/main/index.ts | 2 + src/main/utils/notes-operations.ts | 69 +++++----- src/preload/index.d.ts | 14 +- src/preload/index.ts | 3 +- .../components/home/components/note-list.tsx | 4 +- .../home/components/notes-nav-actions.tsx | 52 +++++++- src/renderer/src/components/home/index.tsx | 2 +- src/renderer/src/types/notes.ts | 1 + 12 files changed, 230 insertions(+), 49 deletions(-) create mode 100644 resources/database/migrations/0006_great_supreme_intelligence.sql create mode 100644 resources/database/migrations/meta/0006_snapshot.json diff --git a/resources/database/migrations/0006_great_supreme_intelligence.sql b/resources/database/migrations/0006_great_supreme_intelligence.sql new file mode 100644 index 0000000..6530a78 --- /dev/null +++ b/resources/database/migrations/0006_great_supreme_intelligence.sql @@ -0,0 +1 @@ +ALTER TABLE `notes` ADD `favorite` integer DEFAULT false NOT NULL; \ No newline at end of file diff --git a/resources/database/migrations/meta/0006_snapshot.json b/resources/database/migrations/meta/0006_snapshot.json new file mode 100644 index 0000000..7e15355 --- /dev/null +++ b/resources/database/migrations/meta/0006_snapshot.json @@ -0,0 +1,123 @@ +{ + "version": "6", + "dialect": "sqlite", + "id": "00186e7f-6619-4cb4-baab-04410aa0e24f", + "prevId": "e0c8c2de-4cdd-4096-8c59-eb8d298b03e5", + "tables": { + "clipboard": { + "name": "clipboard", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "content": { + "name": "content", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "createdAt": { + "name": "createdAt", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "notes": { + "name": "notes", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "favorite": { + "name": "favorite", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "content": { + "name": "content", + "type": "blob", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "labels": { + "name": "labels", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "createdAt": { + "name": "createdAt", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updatedAt": { + "name": "updatedAt", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + } + }, + "views": {}, + "enums": {}, + "_meta": { + "schemas": {}, + "tables": {}, + "columns": {} + }, + "internal": { + "indexes": {} + } +} diff --git a/resources/database/migrations/meta/_journal.json b/resources/database/migrations/meta/_journal.json index bd05172..c9c5a5e 100644 --- a/resources/database/migrations/meta/_journal.json +++ b/resources/database/migrations/meta/_journal.json @@ -43,6 +43,13 @@ "when": 1739196843790, "tag": "0005_volatile_titania", "breakpoints": true + }, + { + "idx": 6, + "version": "6", + "when": 1740400576615, + "tag": "0006_great_supreme_intelligence", + "breakpoints": true } ] } diff --git a/src/main/drizzle/schema.ts b/src/main/drizzle/schema.ts index efbe50b..a9710bc 100644 --- a/src/main/drizzle/schema.ts +++ b/src/main/drizzle/schema.ts @@ -18,6 +18,7 @@ export const notesSchema = sqliteTable('notes', { id: integer().primaryKey({ autoIncrement: true }), title: text().notNull(), description: text().notNull(), + favorite: integer({ mode: 'boolean' }).notNull().default(false), content: blob().notNull(), // content is going to be JSON labels: blob(), // content is going to be JSON createdAt: integer() diff --git a/src/main/index.ts b/src/main/index.ts index d98a01c..e45f2b6 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -14,6 +14,7 @@ import { deleteNote, getAllNotes, getNoteById, + toggleFavoriteNote, updateNote } from './utils/notes-operations' @@ -177,6 +178,7 @@ app.whenReady().then(() => { ipcMain.handle('delete-note', (_, id) => deleteNote(id)) ipcMain.handle('get-note', (_, id) => getNoteById(id)) ipcMain.handle('get-all-notes', getAllNotes) + ipcMain.handle('toggle-favorite-note', (_, values) => toggleFavoriteNote(values)) let previousContent = clipboard.readText() async function checkClipboard(): Promise { diff --git a/src/main/utils/notes-operations.ts b/src/main/utils/notes-operations.ts index 461eaf0..2df2d81 100644 --- a/src/main/utils/notes-operations.ts +++ b/src/main/utils/notes-operations.ts @@ -49,17 +49,7 @@ export function getAllNotes(): { updatedAt: number }[] { // Explicitly select only the required fields - const allNotes = db - .select({ - id: notesSchema.id, - title: notesSchema.title, - description: notesSchema.description, - createdAt: notesSchema.createdAt, - updatedAt: notesSchema.updatedAt - }) - .from(notesSchema) - .all() - + const allNotes = db.select().from(notesSchema).all() return allNotes } @@ -92,19 +82,13 @@ export async function updateNote({ title }: { id: string - content: object | unknown[] + content?: object | unknown[] title?: string description?: string -}): Promise< - | { - result: string - error?: undefined - } - | { - error: unknown - result?: undefined - } -> { +}): Promise<{ + result?: string + error?: unknown +}> { try { await db .update(notesSchema) @@ -122,23 +106,42 @@ export async function updateNote({ } } +// Function to toggle favorite a note +export async function toggleFavoriteNote({ + id, + favorite +}: { + id: string + favorite: boolean +}): Promise<{ + result?: string + error?: unknown +}> { + try { + await db + .update(notesSchema) + .set({ + favorite, + updatedAt: Date.now() // Update timestamp + }) + .where(eq(notesSchema.id, Number(id))) + return { result: 'success' } + } catch (error) { + console.error(error) + return { error } + } +} + // Function to delete a note -export async function deleteNote(id: string): Promise< - | { - result: string - error?: undefined - } - | { - error: unknown - result?: undefined - } -> { +export async function deleteNote(id: string): Promise<{ + error?: unknown + result?: string +}> { try { await db.delete(notesSchema).where(eq(notesSchema.id, Number(id))) return { result: 'success' } } catch (error) { console.error(error) - return { error } } } diff --git a/src/preload/index.d.ts b/src/preload/index.d.ts index 62c6178..8e08c79 100644 --- a/src/preload/index.d.ts +++ b/src/preload/index.d.ts @@ -31,20 +31,14 @@ interface Note { id: number title: string description: string + favorite: boolean content: Content // Can be an object or array createdAt: number updatedAt: number } // Define the response structure for create/update operations -interface MutationResponse { - id: number - content: Content - createdAt: number - title: string - description: string - labels: unknown - updatedAt: number +interface MutationResponse extends Note { error?: unknown } @@ -72,6 +66,10 @@ interface RendererAPI { deleteNote: (id: string) => Promise getNote: (id: string) => Promise getAllNotes: () => Promise + toggleFavoriteNote: (values: { id: string; favorite: boolean }) => Promise<{ + result?: string + error?: unknown + }> } // Extend the global Window interface to include the Electron API and custom API diff --git a/src/preload/index.ts b/src/preload/index.ts index 92f3b92..46b0805 100644 --- a/src/preload/index.ts +++ b/src/preload/index.ts @@ -16,7 +16,8 @@ const api = { updateNote: (values): Promise => ipcRenderer.invoke('update-note', values), deleteNote: (id): Promise => ipcRenderer.invoke('delete-note', id), getNote: (id): Promise => ipcRenderer.invoke('get-note', id), - getAllNotes: (): Promise => ipcRenderer.invoke('get-all-notes') + getAllNotes: (): Promise => ipcRenderer.invoke('get-all-notes'), + toggleFavoriteNote: (values): Promise => ipcRenderer.invoke('toggle-favorite-note', values) } // Use `contextBridge` APIs to expose Electron APIs to // renderer only if context isolation is enabled, otherwise diff --git a/src/renderer/src/components/home/components/note-list.tsx b/src/renderer/src/components/home/components/note-list.tsx index acdd068..8ce85fa 100644 --- a/src/renderer/src/components/home/components/note-list.tsx +++ b/src/renderer/src/components/home/components/note-list.tsx @@ -5,6 +5,7 @@ import { formatDistanceToNow } from 'date-fns' import { NoteInterface } from '@renderer/types/notes' import { Link, useLocation } from '@tanstack/react-router' import { NoteListMenu } from './note-list-menu' +import { StarIcon } from 'lucide-react' interface NoteListProps { readonly items: NoteInterface[] @@ -35,7 +36,8 @@ export function NoteList({ items }: NoteListProps): React.JSX.Element {
{item.description}
-
+
+
([queryKeys.note, noteId]) const isMutatingNote = queryClient.isMutating({ - mutationKey: [mutationKeys['update-note'], noteId] + mutationKey: [mutationKeys['update-note'], noteId, 'toggle-favorite'] + }) + const { mutate } = useMutation({ + mutationKey: [mutationKeys['update-note'], noteId], + mutationFn: (values: { id: string; favorite: boolean }) => + window.api.toggleFavoriteNote(values), + async onMutate(variables) { + await queryClient.cancelQueries({ queryKey: allNoteKey }) + const snapshot = queryClient.getQueryData(allNoteKey) + queryClient.setQueryData(allNoteKey, (previousEntities) => + previousEntities?.map((entity) => + entity.id.toString() === variables.id + ? { + ...entity, + favorite: variables.favorite, + updatedAt: Date.now() + } + : entity + ) + ) + queryClient.setQueryData([queryKeys.note, noteId], (previousNote) => { + if (!previousNote) return + return { + ...previousNote, + favorite: variables.favorite, + updatedAt: Date.now() + } + }) + return { snapshot } + }, + onError(error) { + toast({ + title: 'Failed to toggle favorite ❌ ', + description: error.message, + variant: 'destructive' + }) + } }) return ( @@ -29,8 +66,13 @@ export function NotesNavActions(): React.JSX.Element { includeSeconds: true })}`}
- diff --git a/src/renderer/src/components/home/index.tsx b/src/renderer/src/components/home/index.tsx index 22f7833..187abab 100644 --- a/src/renderer/src/components/home/index.tsx +++ b/src/renderer/src/components/home/index.tsx @@ -41,7 +41,7 @@ export function Note({ Notes, defaultLayout = [12, 32, 48] }: NoteProps): React. return [...entities, createdNote] }) toast({ title: 'New Note Created 🎉' }) - navigate({ to: `/${data.id}` }) + navigate({ to: '/$noteId', params: { noteId: data.id.toString() } }) }, onError(error) { toast({ diff --git a/src/renderer/src/types/notes.ts b/src/renderer/src/types/notes.ts index 510b8a7..6a97135 100644 --- a/src/renderer/src/types/notes.ts +++ b/src/renderer/src/types/notes.ts @@ -3,6 +3,7 @@ export interface NoteInterface { id: number title: string description: string + favorite: boolean content: Content // Can be an object or array createdAt: number updatedAt: number From ce8ecdb4d95842ce1559ff5f65c6e317bd3913ea Mon Sep 17 00:00:00 2001 From: devtayyab <93027825+Your-Ehsan@users.noreply.github.com> Date: Mon, 24 Feb 2025 18:58:43 +0500 Subject: [PATCH 4/4] chore(refactor): removed some useless code --- .github/FUNDING.yml | 15 --------------- src/main/utils/notes-operations.ts | 2 -- 2 files changed, 17 deletions(-) delete mode 100644 .github/FUNDING.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml deleted file mode 100644 index a0149de..0000000 --- a/.github/FUNDING.yml +++ /dev/null @@ -1,15 +0,0 @@ -# These are supported funding model platforms - -github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] -patreon: # Replace with a single Patreon username -open_collective: # Replace with a single Open Collective username -ko_fi: # Replace with a single Ko-fi username -tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel -community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry -liberapay: # Replace with a single Liberapay username -issuehunt: # Replace with a single IssueHunt username -lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry -polar: # Replace with a single Polar username -buy_me_a_coffee: your_ehsan # Replace with a single Buy Me a Coffee username -thanks_dev: # Replace with a single thanks.dev username -custom: ['https://buymeacoffee.com/your_ehsan'] # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] diff --git a/src/main/utils/notes-operations.ts b/src/main/utils/notes-operations.ts index 2df2d81..febcd2a 100644 --- a/src/main/utils/notes-operations.ts +++ b/src/main/utils/notes-operations.ts @@ -69,8 +69,6 @@ export function getNoteById(id: string): .from(notesSchema) .where(eq(notesSchema.id, Number(id))) .get() - console.log(result) - return result && { ...result, content: JSON.parse(result?.content as string) } }