From 91796fda054acbc04fcf135d961abb76a63211ae Mon Sep 17 00:00:00 2001 From: Audrey Yang Date: Wed, 4 Dec 2024 21:02:37 -0600 Subject: [PATCH] Fix typing issues --- package-lock.json | 257 +-------------------- package.json | 2 +- src/global.d.ts | 15 ++ src/main/backend/api.ts | 17 +- src/main/backend/db.ts | 10 +- src/main/index.ts | 2 +- src/preload/index.d.ts | 21 -- src/renderer/components/EditComponents.tsx | 37 ++- src/renderer/components/Task.tsx | 16 +- tsconfig.json | 5 +- 10 files changed, 84 insertions(+), 298 deletions(-) create mode 100644 src/global.d.ts delete mode 100644 src/preload/index.d.ts diff --git a/package-lock.json b/package-lock.json index d0de983..4f073d5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "taskflow2", - "version": "0.0.0", + "version": "0.0.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "taskflow2", - "version": "0.0.0", + "version": "0.0.1", "license": "MIT", "dependencies": { "@emotion/react": "^11.13.3", @@ -20,8 +20,7 @@ "pouchdb": "^9.0.0", "pouchdb-adapter-idb": "^9.0.0", "pouchdb-browser": "^9.0.0", - "pouchdb-find": "^9.0.0", - "use-pouchdb": "^2.0.2" + "pouchdb-find": "^9.0.0" }, "devDependencies": { "@electron-forge/cli": "7.4.0", @@ -3040,6 +3039,7 @@ "version": "7.0.15", "resolved": "https://registry.npmjs.org/@types/pouchdb-core/-/pouchdb-core-7.0.15.tgz", "integrity": "sha512-gq1Qbqn9nCaAKRRv6fRHZ4/ER+QYEwSXBZlDQcxwdbPrtZO8EhIn2Bct0AlguaSEdFcABfbaxxyQwFINkNQ9dQ==", + "dev": true, "dependencies": { "@types/debug": "*", "@types/pouchdb-find": "*" @@ -3049,6 +3049,7 @@ "version": "7.3.3", "resolved": "https://registry.npmjs.org/@types/pouchdb-find/-/pouchdb-find-7.3.3.tgz", "integrity": "sha512-U7zXk67s9Ar+9Pwj5kSbuMnn8zif0AOOIPy4KRFeJ/S/Tk+mNS90soj+3OV21H8xyB7WTxjvS1JLablZC6C6ow==", + "dev": true, "dependencies": { "@types/pouchdb-core": "*" } @@ -3067,6 +3068,7 @@ "version": "6.1.10", "resolved": "https://registry.npmjs.org/@types/pouchdb-mapreduce/-/pouchdb-mapreduce-6.1.10.tgz", "integrity": "sha512-AgYVqCnaA5D7cWkWyzZVuk0137N4yZsmIQTD/i3DmuMxYYoFrtWUoQu0tbA52SpTRGdL8ubQ7JFQXzA13fA6IQ==", + "dev": true, "dependencies": { "@types/pouchdb-core": "*" } @@ -3398,17 +3400,6 @@ "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==", "dev": true }, - "node_modules/abort-controller": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz", - "integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==", - "dependencies": { - "event-target-shim": "^5.0.0" - }, - "engines": { - "node": ">=6.5" - } - }, "node_modules/abstract-leveldown": { "version": "6.2.3", "resolved": "https://registry.npmjs.org/abstract-leveldown/-/abstract-leveldown-6.2.3.tgz", @@ -4065,7 +4056,8 @@ "node_modules/buffer-from": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", - "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==" + "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", + "dev": true }, "node_modules/bytes": { "version": "3.1.2", @@ -4464,14 +4456,6 @@ "node": ">=0.8" } }, - "node_modules/clone-buffer": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/clone-buffer/-/clone-buffer-1.0.0.tgz", - "integrity": "sha512-KLLTJWrvwIP+OPfMn0x2PheDEP20RPUcGXj/ERegTgdmPEZylALQldygiqrPPu8P45uNuPs7ckmReLY6v/iA5g==", - "engines": { - "node": ">= 0.10" - } - }, "node_modules/clone-response": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/clone-response/-/clone-response-1.0.3.tgz", @@ -6177,14 +6161,6 @@ "node": ">= 0.6" } }, - "node_modules/event-target-shim": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", - "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==", - "engines": { - "node": ">=6" - } - }, "node_modules/eventemitter3": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-5.0.1.tgz", @@ -6406,7 +6382,8 @@ "node_modules/fast-deep-equal": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", - "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==" + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "dev": true }, "node_modules/fast-diff": { "version": "1.3.0", @@ -10020,172 +9997,11 @@ "vuvuzela": "1.0.3" } }, - "node_modules/pouchdb-changes-filter": { - "version": "8.0.1", - "resolved": "https://registry.npmjs.org/pouchdb-changes-filter/-/pouchdb-changes-filter-8.0.1.tgz", - "integrity": "sha512-UKgH6YRA9PnvIGHb0FuDEEqeTewgHugbbBt5vpVo0QmbWKxNiau/JiTC9mY5Hj9l7ghaIUpO0TFG95a6RXWsQA==", - "dependencies": { - "pouchdb-errors": "8.0.1", - "pouchdb-selector-core": "8.0.1", - "pouchdb-utils": "8.0.1" - } - }, - "node_modules/pouchdb-changes-filter/node_modules/pouchdb-binary-utils": { - "version": "8.0.1", - "resolved": "https://registry.npmjs.org/pouchdb-binary-utils/-/pouchdb-binary-utils-8.0.1.tgz", - "integrity": "sha512-WsuR/S0aoUlcA0Alt99czkXsfuXWcrYXAcvGiTW02zawVXOafCnb/qHjA09TUaV0oy5HeHmYaNnDckoOUqspeA==", - "dependencies": { - "buffer-from": "1.1.2" - } - }, - "node_modules/pouchdb-changes-filter/node_modules/pouchdb-collate": { - "version": "8.0.1", - "resolved": "https://registry.npmjs.org/pouchdb-collate/-/pouchdb-collate-8.0.1.tgz", - "integrity": "sha512-DTuNz1UJjBTGZMUlWS1klSE1rPsmHy8IIDie3MFH1ZTz/C+SwGgGwkiAyUDv/n00D18EMLgXq5mu+r7L6K1BwQ==" - }, - "node_modules/pouchdb-changes-filter/node_modules/pouchdb-errors": { - "version": "8.0.1", - "resolved": "https://registry.npmjs.org/pouchdb-errors/-/pouchdb-errors-8.0.1.tgz", - "integrity": "sha512-H+ZsQxcG/JV3Tn29gnM6c9+lRPCN91ZYOkoIICsLjVRYgOTzN1AvNUD/G5JCB+81aI/u3fxZec0LEaZh6g6NHA==" - }, - "node_modules/pouchdb-changes-filter/node_modules/pouchdb-md5": { - "version": "8.0.1", - "resolved": "https://registry.npmjs.org/pouchdb-md5/-/pouchdb-md5-8.0.1.tgz", - "integrity": "sha512-shVcs/K/iilrcAhDEERpLIrGm/cnDVsXiocOzs7kycJEuBqYnLD9nj58VwWDcum26wfa8T9cznvEGE1jlYVNPQ==", - "dependencies": { - "pouchdb-binary-utils": "8.0.1", - "spark-md5": "3.0.2" - } - }, - "node_modules/pouchdb-changes-filter/node_modules/pouchdb-selector-core": { - "version": "8.0.1", - "resolved": "https://registry.npmjs.org/pouchdb-selector-core/-/pouchdb-selector-core-8.0.1.tgz", - "integrity": "sha512-dHWsnR+mLGyfVld1vSHJI1xKTwS1xk1G2dggjfXfUrLehI+wysjTUOwiSNytyPzG6DpT+o86wyUpwzPwsDCLBw==", - "dependencies": { - "pouchdb-collate": "8.0.1", - "pouchdb-utils": "8.0.1" - } - }, - "node_modules/pouchdb-changes-filter/node_modules/pouchdb-utils": { - "version": "8.0.1", - "resolved": "https://registry.npmjs.org/pouchdb-utils/-/pouchdb-utils-8.0.1.tgz", - "integrity": "sha512-pWgxdk9EHVWJmjQoEvTe+ZlPXyjcuQ/vgLITN+RjGwcYhoQYUE1M0PksQd2dUP3V8lGS4+wrg9lEM/qSJPYcpw==", - "dependencies": { - "clone-buffer": "1.0.0", - "immediate": "3.3.0", - "pouchdb-collections": "8.0.1", - "pouchdb-errors": "8.0.1", - "pouchdb-md5": "8.0.1", - "uuid": "8.3.2" - } - }, "node_modules/pouchdb-collate": { "version": "9.0.0", "resolved": "https://registry.npmjs.org/pouchdb-collate/-/pouchdb-collate-9.0.0.tgz", "integrity": "sha512-TrnEDNZEmIIl+W3xKUO8h+geqVLQ90oZe5ujPkl8myUzpREULWXWQBnV5EzPXVEKDBpJlb8T3I6oy/zdWGQpdA==" }, - "node_modules/pouchdb-collections": { - "version": "8.0.1", - "resolved": "https://registry.npmjs.org/pouchdb-collections/-/pouchdb-collections-8.0.1.tgz", - "integrity": "sha512-TlkQ2GGHJApJgL0b7bJMQcwX6eMfVenLeoK9mqHfC2fJssui+HWJJ5LYKHOWan11SeB90BQVFbO6rHN6CJQeDg==" - }, - "node_modules/pouchdb-core": { - "version": "8.0.1", - "resolved": "https://registry.npmjs.org/pouchdb-core/-/pouchdb-core-8.0.1.tgz", - "integrity": "sha512-Qkcmh3eoMHiKUma5Y/rH0Z7kjxXrr6p54j/WOH+TZ/RlJAchmdVY1TRfqay5CoK+8Ka0m8eibP+wD1DKZKJbDg==", - "dependencies": { - "pouchdb-changes-filter": "8.0.1", - "pouchdb-collections": "8.0.1", - "pouchdb-errors": "8.0.1", - "pouchdb-fetch": "8.0.1", - "pouchdb-merge": "8.0.1", - "pouchdb-utils": "8.0.1", - "uuid": "8.3.2" - } - }, - "node_modules/pouchdb-core/node_modules/fetch-cookie": { - "version": "0.11.0", - "resolved": "https://registry.npmjs.org/fetch-cookie/-/fetch-cookie-0.11.0.tgz", - "integrity": "sha512-BQm7iZLFhMWFy5CZ/162sAGjBfdNWb7a8LEqqnzsHFhxT/X/SVj/z2t2nu3aJvjlbQkrAlTUApplPRjWyH4mhA==", - "dependencies": { - "tough-cookie": "^2.3.3 || ^3.0.1 || ^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/pouchdb-core/node_modules/node-fetch": { - "version": "2.6.7", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz", - "integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==", - "dependencies": { - "whatwg-url": "^5.0.0" - }, - "engines": { - "node": "4.x || >=6.0.0" - }, - "peerDependencies": { - "encoding": "^0.1.0" - }, - "peerDependenciesMeta": { - "encoding": { - "optional": true - } - } - }, - "node_modules/pouchdb-core/node_modules/pouchdb-binary-utils": { - "version": "8.0.1", - "resolved": "https://registry.npmjs.org/pouchdb-binary-utils/-/pouchdb-binary-utils-8.0.1.tgz", - "integrity": "sha512-WsuR/S0aoUlcA0Alt99czkXsfuXWcrYXAcvGiTW02zawVXOafCnb/qHjA09TUaV0oy5HeHmYaNnDckoOUqspeA==", - "dependencies": { - "buffer-from": "1.1.2" - } - }, - "node_modules/pouchdb-core/node_modules/pouchdb-errors": { - "version": "8.0.1", - "resolved": "https://registry.npmjs.org/pouchdb-errors/-/pouchdb-errors-8.0.1.tgz", - "integrity": "sha512-H+ZsQxcG/JV3Tn29gnM6c9+lRPCN91ZYOkoIICsLjVRYgOTzN1AvNUD/G5JCB+81aI/u3fxZec0LEaZh6g6NHA==" - }, - "node_modules/pouchdb-core/node_modules/pouchdb-fetch": { - "version": "8.0.1", - "resolved": "https://registry.npmjs.org/pouchdb-fetch/-/pouchdb-fetch-8.0.1.tgz", - "integrity": "sha512-Px5HLT8MxqTujc8bpPRKoouznDTJa9XBGqCbhl95q6rhjWRfwZEvXjV92z0B5BALAM6D6avMyG0DjuNfUWnMuA==", - "dependencies": { - "abort-controller": "3.0.0", - "fetch-cookie": "0.11.0", - "node-fetch": "2.6.7" - } - }, - "node_modules/pouchdb-core/node_modules/pouchdb-md5": { - "version": "8.0.1", - "resolved": "https://registry.npmjs.org/pouchdb-md5/-/pouchdb-md5-8.0.1.tgz", - "integrity": "sha512-shVcs/K/iilrcAhDEERpLIrGm/cnDVsXiocOzs7kycJEuBqYnLD9nj58VwWDcum26wfa8T9cznvEGE1jlYVNPQ==", - "dependencies": { - "pouchdb-binary-utils": "8.0.1", - "spark-md5": "3.0.2" - } - }, - "node_modules/pouchdb-core/node_modules/pouchdb-merge": { - "version": "8.0.1", - "resolved": "https://registry.npmjs.org/pouchdb-merge/-/pouchdb-merge-8.0.1.tgz", - "integrity": "sha512-79dw6+K7js2+/kt9u4hKOkGCnz+ov0+yft2k21n6M+ylFEQyMKuWHEZRoFWr72o1vxwjhIXhUM1PB2PIdxIh0Q==", - "dependencies": { - "pouchdb-utils": "8.0.1" - } - }, - "node_modules/pouchdb-core/node_modules/pouchdb-utils": { - "version": "8.0.1", - "resolved": "https://registry.npmjs.org/pouchdb-utils/-/pouchdb-utils-8.0.1.tgz", - "integrity": "sha512-pWgxdk9EHVWJmjQoEvTe+ZlPXyjcuQ/vgLITN+RjGwcYhoQYUE1M0PksQd2dUP3V8lGS4+wrg9lEM/qSJPYcpw==", - "dependencies": { - "clone-buffer": "1.0.0", - "immediate": "3.3.0", - "pouchdb-collections": "8.0.1", - "pouchdb-errors": "8.0.1", - "pouchdb-md5": "8.0.1", - "uuid": "8.3.2" - } - }, "node_modules/pouchdb-errors": { "version": "9.0.0", "resolved": "https://registry.npmjs.org/pouchdb-errors/-/pouchdb-errors-9.0.0.tgz", @@ -12417,59 +12233,6 @@ "requires-port": "^1.0.0" } }, - "node_modules/use-pouchdb": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/use-pouchdb/-/use-pouchdb-2.0.2.tgz", - "integrity": "sha512-V1zfglhosqJCQZ1EXpBXrgcix5IAur0MItceN9DV1bW8xztebEmS1BkJUA9ogr1DgKA/XKwVC8mS2vSWewaUZw==", - "dependencies": { - "@types/pouchdb-core": "^7.0.11", - "@types/pouchdb-find": "^7.3.0", - "@types/pouchdb-mapreduce": "^6.1.6", - "@types/react": "^18.0.14", - "fast-deep-equal": "^3.1.3", - "pouchdb-core": "^8.0.1", - "pouchdb-errors": "^8.0.1", - "pouchdb-utils": "^8.0.1" - }, - "peerDependencies": { - "react": ">=16.8" - } - }, - "node_modules/use-pouchdb/node_modules/pouchdb-binary-utils": { - "version": "8.0.1", - "resolved": "https://registry.npmjs.org/pouchdb-binary-utils/-/pouchdb-binary-utils-8.0.1.tgz", - "integrity": "sha512-WsuR/S0aoUlcA0Alt99czkXsfuXWcrYXAcvGiTW02zawVXOafCnb/qHjA09TUaV0oy5HeHmYaNnDckoOUqspeA==", - "dependencies": { - "buffer-from": "1.1.2" - } - }, - "node_modules/use-pouchdb/node_modules/pouchdb-errors": { - "version": "8.0.1", - "resolved": "https://registry.npmjs.org/pouchdb-errors/-/pouchdb-errors-8.0.1.tgz", - "integrity": "sha512-H+ZsQxcG/JV3Tn29gnM6c9+lRPCN91ZYOkoIICsLjVRYgOTzN1AvNUD/G5JCB+81aI/u3fxZec0LEaZh6g6NHA==" - }, - "node_modules/use-pouchdb/node_modules/pouchdb-md5": { - "version": "8.0.1", - "resolved": "https://registry.npmjs.org/pouchdb-md5/-/pouchdb-md5-8.0.1.tgz", - "integrity": "sha512-shVcs/K/iilrcAhDEERpLIrGm/cnDVsXiocOzs7kycJEuBqYnLD9nj58VwWDcum26wfa8T9cznvEGE1jlYVNPQ==", - "dependencies": { - "pouchdb-binary-utils": "8.0.1", - "spark-md5": "3.0.2" - } - }, - "node_modules/use-pouchdb/node_modules/pouchdb-utils": { - "version": "8.0.1", - "resolved": "https://registry.npmjs.org/pouchdb-utils/-/pouchdb-utils-8.0.1.tgz", - "integrity": "sha512-pWgxdk9EHVWJmjQoEvTe+ZlPXyjcuQ/vgLITN+RjGwcYhoQYUE1M0PksQd2dUP3V8lGS4+wrg9lEM/qSJPYcpw==", - "dependencies": { - "clone-buffer": "1.0.0", - "immediate": "3.3.0", - "pouchdb-collections": "8.0.1", - "pouchdb-errors": "8.0.1", - "pouchdb-md5": "8.0.1", - "uuid": "8.3.2" - } - }, "node_modules/username": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/username/-/username-5.1.0.tgz", diff --git a/package.json b/package.json index 21262bf..bfc507c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "taskflow2", - "version": "0.0.0", + "version": "0.0.1", "description": "a little task manager", "main": ".vite/build/main/index.js", "author": "@audrey-yang", diff --git a/src/global.d.ts b/src/global.d.ts new file mode 100644 index 0000000..3a169f4 --- /dev/null +++ b/src/global.d.ts @@ -0,0 +1,15 @@ +interface Window { + api: { + createTask: (task: Task) => Promise; + getAllTasks: () => Promise; + getChildTasks: (parentId: string) => Promise; + getChildTasksIncomplete: (parentId: string) => Promise; + getChildTasksComplete: (parentId: string) => Promise; + countChildTasksByStatus: (parentId: string, status: Status) => Promise; + changeTaskPriority: (id: string, priority: Priority) => Promise; + changeTaskStatus: (id: string, status: Status) => Promise; + changeTaskTitle: (id: string, title: string) => Promise; + changeTaskNote: (id: string, note: string) => Promise; + deleteTask: (id: string) => Promise; + }; +} diff --git a/src/main/backend/api.ts b/src/main/backend/api.ts index 1635418..e6a8e61 100644 --- a/src/main/backend/api.ts +++ b/src/main/backend/api.ts @@ -17,8 +17,8 @@ export const api = { }); }, getAllTasks: async () => { - return await db.allDocs({ include_docs: true }).then((res) => { - return res.rows.map((row) => row.doc); + return await db.allDocs({ include_docs: true }).then((res: { rows: any[] }) => { + return res.rows.map((row: { doc: any }) => row.doc); }); }, getChildTasks: async (parentId: string) => { @@ -29,7 +29,7 @@ export const api = { }, sort: [{ priority: "desc" }, { status: "desc" }], }) - .then((res) => { + .then((res: { docs: any }) => { return res.docs; }); }, @@ -42,9 +42,8 @@ export const api = { status: { $gte: STATUS.IN_PROGRESS }, }, sort: [{ priority: "desc" }, { status: "desc" }], - using: "parent-status-priority", }) - .then((res) => { + .then((res: { docs: any }) => { return res.docs; }); }, @@ -56,7 +55,7 @@ export const api = { status: STATUS.COMPLETED, }, }) - .then((res) => { + .then((res: { docs: any }) => { return res.docs; }); }, @@ -69,7 +68,7 @@ export const api = { }, fields: ["_id"], // Only select the _id field to reduce data transfer }) - .then((res) => { + .then((res: { docs: string | any[] }) => { return res.docs.length; }); }, @@ -96,13 +95,13 @@ export const api = { const children = result.docs; await Promise.all( - children.map((child) => { + children.map((child: { _id: string }) => { recursiveDelete(child._id); }), ); // Delete self - await db.get(parentId).then((doc) => { + await db.get(parentId).then((doc: any) => { db.remove(doc); }); }; diff --git a/src/main/backend/db.ts b/src/main/backend/db.ts index 0c0278a..a7838d2 100644 --- a/src/main/backend/db.ts +++ b/src/main/backend/db.ts @@ -4,7 +4,7 @@ import path from "path"; import PouchDB from "pouchdb"; PouchDB.plugin(require("pouchdb-find")); -export const db: PouchDB = new PouchDB(path.join(app.getPath("sessionData"), "leveldb")); +export const db = new PouchDB(path.join(app.getPath("sessionData"), "leveldb")); // Get Cloudant auth credentials const authenticator = new IamAuthenticator({ @@ -12,9 +12,9 @@ const authenticator = new IamAuthenticator({ }); // Create DB and sync with remote DB -const remoteDb: PouchDB = new PouchDB(`${import.meta.env.VITE_CLOUDANT_URL}`, { +const remoteDb = new PouchDB(`${import.meta.env.VITE_CLOUDANT_URL}`, { fetch: async (url: any, opts: any) => { - const bearerOpts = {}; + const bearerOpts: { headers: { [key: string]: string } } = { headers: {} }; await authenticator.authenticate(bearerOpts); opts.headers.set("Authorization", bearerOpts["headers"]["Authorization"]); return PouchDB.fetch(url, opts); @@ -33,7 +33,6 @@ remoteDb db.sync(remoteDb, { live: true, retry: true, - continuous: true, }); // Create indexes for Mango @@ -47,6 +46,5 @@ db.createIndex({ index: { fields: ["parentId", "status"] }, }); db.createIndex({ - index: { fields: ["parentId", "priority", "status"] }, - ddoc: "parent-status-priority", + index: { fields: ["parentId", "priority", "status"], ddoc: "parent-status-priority" }, }); diff --git a/src/main/index.ts b/src/main/index.ts index 3514ab8..c6cfcfd 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -3,7 +3,7 @@ import { join } from "path"; import { electronApp, optimizer, is } from "@electron-toolkit/utils"; import icon from "../../resources/icon.png"; import { api } from "./backend/api"; -import { Priority, Status, Task } from "../renderer/src/types"; +import { Priority, Status, Task } from "../renderer/types"; const createWindow = (): void => { // Create the browser window. diff --git a/src/preload/index.d.ts b/src/preload/index.d.ts deleted file mode 100644 index f8caecc..0000000 --- a/src/preload/index.d.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { ElectronAPI } from "@electron-toolkit/preload"; -import { Task } from "@renderer/src/types"; - -declare global { - interface Window { - electron: ElectronAPI; - api: { - createTask: (task: Task) => any; - getAllTasks: () => any; - getChildTasks: (parentId: string) => any; - getChildTasksIncomplete: (parentId: string) => any; - getChildTasksComplete: (parentId: string) => any; - countChildTasksByStatus: (parentId: string, status: Status) => any; - changeTaskPriority: (id: string, priority: Priority) => any; - changeTaskStatus: (id: string, status: Status) => any; - changeTaskTitle: (id: string, title: string) => any; - changeTaskNote: (id: string, note: string) => any; - deleteTask: (id: string) => any; - }; - } -} diff --git a/src/renderer/components/EditComponents.tsx b/src/renderer/components/EditComponents.tsx index 93da415..79925cf 100644 --- a/src/renderer/components/EditComponents.tsx +++ b/src/renderer/components/EditComponents.tsx @@ -1,10 +1,15 @@ -import Select from "@mui/material/Select"; +import Select, { SelectChangeEvent } from "@mui/material/Select"; import MenuItem from "@mui/material/MenuItem"; import TextField from "@mui/material/TextField"; import { Priority, priorityToString, Status, statusToString } from "../types"; const selectOptions = [0, 1, 2]; -const customSelect = (curValue, label, changeHandler, stringDisplay) => ( +const customSelect = ( + curValue: any, + label: string, + changeHandler: (e: SelectChangeEvent) => Promise, + stringDisplay: (raw: any) => string, +) => ( ); -export const prioritySelect = (curValue: Priority, changePriority) => - customSelect(curValue, "Priority", changePriority, priorityToString); +export const prioritySelect = ( + curValue: Priority, + changePriority: (e: SelectChangeEvent) => Promise, +) => customSelect(curValue, "Priority", changePriority, priorityToString); -export const statusSelect = (curValue: Status, changeStatus) => - customSelect(curValue, "Status", changeStatus, statusToString); +export const statusSelect = ( + curValue: Status, + changeStatus: (e: SelectChangeEvent) => Promise, +) => customSelect(curValue, "Status", changeStatus, statusToString); -export const titleEditor = (newTitle, setNewTitle, submitFunction) => ( +export const titleEditor = ( + newTitle: string, + setNewTitle: (newTitle: string) => void, + submitFunction: (newTitle: string) => Promise, +) => ( setNewTitle(event.target.value)} - onKeyDown={(e) => { + onKeyDown={async (e) => { if (e.key === "Enter") { - submitFunction(newTitle); + await submitFunction(newTitle); setNewTitle(""); } }} @@ -36,7 +49,11 @@ export const titleEditor = (newTitle, setNewTitle, submitFunction) => ( /> ); -export const notesEditor = (note, setNote, disabled) => ( +export const notesEditor = ( + note: string, + setNote: (newNote: string) => void, + disabled: boolean, +) => ( { +const Task = ({ + _id, + title, + priority, + status, + note, + refresh, +}: { + _id: string; + title: string; + priority: Priority; + status: Status; + note: string; + refresh: () => Promise; +}) => { const [isExpanded, setIsExpanded] = useState(false); const [taskTitle, setTaskTitle] = useState(title); const [isEditingTitle, setIsEditingTitle] = useState(false); diff --git a/tsconfig.json b/tsconfig.json index 0462f03..9d1b5c0 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,7 +1,7 @@ { "compilerOptions": { "target": "ESNext", - "module": "commonjs", + "module": "es2020", "allowJs": true, "skipLibCheck": true, "esModuleInterop": true, @@ -12,5 +12,6 @@ "moduleResolution": "node", "resolveJsonModule": true, "jsx": "react-jsx" - } + }, + "include": ["src", "global.d.ts"] }