From 6fe703c803f2bfe67f3b3247cc360072d97561ea Mon Sep 17 00:00:00 2001 From: Aaron Boodman Date: Thu, 30 Nov 2023 22:53:09 -1000 Subject: [PATCH 1/6] Upgrade to Replicache 14.0.2 --- backend/replicache-transaction.ts | 31 ++++++++-- frontend/app.tsx | 30 +++++----- frontend/issue-detail.tsx | 16 ++---- frontend/issue.ts | 6 +- package-lock.json | 95 ++++++++++++++++++------------- package.json | 4 +- 6 files changed, 106 insertions(+), 76 deletions(-) diff --git a/backend/replicache-transaction.ts b/backend/replicache-transaction.ts index 6c0881f6..18807f4b 100644 --- a/backend/replicache-transaction.ts +++ b/backend/replicache-transaction.ts @@ -1,7 +1,11 @@ import type { + DeepReadonly, + IndexKey, JSONValue, - KeyTypeForScanOptions, ReadTransaction, + ReadonlyJSONValue, + ScanIndexOptions, + ScanNoIndexOptions, ScanOptions, ScanResult, TransactionEnvironment, @@ -56,6 +60,10 @@ export class ReplicacheTransaction implements WriteTransaction { return "server"; } + get location() { + return this.environment; + } + get mutationID(): number { return this._mutationID; } @@ -65,6 +73,9 @@ export class ReplicacheTransaction implements WriteTransaction { } async put(key: string, value: JSONValue): Promise { + this.set(key, value); + } + async set(key: string, value: JSONValue): Promise { this._cache.set(key, { value, dirty: true }); } async del(key: string): Promise { @@ -90,10 +101,20 @@ export class ReplicacheTransaction implements WriteTransaction { async isEmpty(): Promise { throw new Error("Method isEmpty not implemented"); } - scan(): ScanResult; - scan( - _options?: Options - ): ScanResult> { + + scan(options: ScanIndexOptions): ScanResult; + scan(options?: ScanNoIndexOptions): ScanResult; + scan(options?: ScanOptions): ScanResult; + scan( + options: ScanIndexOptions + ): ScanResult>; + scan( + options?: ScanNoIndexOptions + ): ScanResult>; + scan( + options?: ScanOptions + ): ScanResult>; + scan(): ScanResult { throw new Error("Method scan not implemented."); } diff --git a/frontend/app.tsx b/frontend/app.tsx index 3aab0c8b..9b6ba29b 100644 --- a/frontend/app.tsx +++ b/frontend/app.tsx @@ -35,7 +35,7 @@ import IssueDetail from "./issue-detail"; import { generateKeyBetween } from "fractional-indexing"; import { useSubscribe } from "replicache-react"; import classnames from "classnames"; -import { getPartialSyncState, PartialSyncState } from "./control"; +import { getPartialSyncState } from "./control"; import type { UndoManager } from "@rocicorp/undo"; import { HotKeys } from "react-hotkeys"; @@ -358,14 +358,12 @@ const App = ({ rep, undoManager }: AppProps) => { issueOrder: getIssueOrder(view, orderBy), }); - const partialSync = useSubscribe< - PartialSyncState | "NOT_RECEIVED_FROM_SERVER" - >( + const partialSync = useSubscribe( rep, async (tx: ReadTransaction) => { return (await getPartialSyncState(tx)) || "NOT_RECEIVED_FROM_SERVER"; }, - "NOT_RECEIVED_FROM_SERVER" + { default: "NOT_RECEIVED_FROM_SERVER" as const } ); const partialSyncComplete = partialSync === "PARTIAL_SYNC_COMPLETE"; @@ -434,8 +432,8 @@ const App = ({ rep, undoManager }: AppProps) => { const handleUpdateIssues = useCallback( async (issueUpdates: Array) => { - const uChanges: Array = issueUpdates.map( - (issueUpdate) => { + const uChanges: Array = + issueUpdates.map((issueUpdate) => { const undoChanges = pickBy( issueUpdate.issue, (_, key) => key in issueUpdate.issueChanges @@ -452,8 +450,7 @@ const App = ({ rep, undoManager }: AppProps) => { }; } return rv; - } - ); + }); await undoManager.add({ execute: () => rep.mutate.updateIssues( @@ -483,13 +480,14 @@ const App = ({ rep, undoManager }: AppProps) => { }, [setDetailIssueID] ); - const handleCloseMenu = useCallback(() => setMenuVisible(false), [ - setMenuVisible, - ]); - const handleToggleMenu = useCallback(() => setMenuVisible(!menuVisible), [ - setMenuVisible, - menuVisible, - ]); + const handleCloseMenu = useCallback( + () => setMenuVisible(false), + [setMenuVisible] + ); + const handleToggleMenu = useCallback( + () => setMenuVisible(!menuVisible), + [setMenuVisible, menuVisible] + ); const handlers = { undo: () => undoManager.undo(), diff --git a/frontend/issue-detail.tsx b/frontend/issue-detail.tsx index 8d202d29..bada36f5 100644 --- a/frontend/issue-detail.tsx +++ b/frontend/issue-detail.tsx @@ -8,7 +8,6 @@ import PriorityMenu from "./priority-menu"; import { Comment, getIssueComments, - Description, getIssueDescription, Issue, Priority, @@ -92,7 +91,7 @@ export default function IssueDetail({ } }, [issues, detailIssueID]); - const issue = useSubscribe( + const issue = useSubscribe( rep, async (tx) => { if (detailIssueID) { @@ -100,10 +99,9 @@ export default function IssueDetail({ } return null; }, - null, - [detailIssueID] + { default: null, dependencies: [detailIssueID] } ); - const description = useSubscribe( + const description = useSubscribe( rep, async (tx) => { if (detailIssueID) { @@ -111,11 +109,10 @@ export default function IssueDetail({ } return null; }, - null, - [detailIssueID] + { default: null, dependencies: [detailIssueID] } ); - const comments = useSubscribe( + const comments = useSubscribe( rep, async (tx) => { if (detailIssueID) { @@ -123,8 +120,7 @@ export default function IssueDetail({ } return []; }, - [], - [detailIssueID] + { default: [], dependencies: [detailIssueID] } ); const handleClose = useCallback(async () => { diff --git a/frontend/issue.ts b/frontend/issue.ts index 5effc52a..d71dc62c 100644 --- a/frontend/issue.ts +++ b/frontend/issue.ts @@ -134,7 +134,7 @@ export async function putIssue( tx: WriteTransaction, issue: Issue ): Promise { - await tx.put(issueKey(issue.id), issue); + await tx.set(issueKey(issue.id), issue); } export function issueFromKeyAndValue( @@ -175,7 +175,7 @@ export async function putIssueDescription( issueID: string, description: Description ): Promise { - await tx.put(descriptionKey(issueID), description); + await tx.set(descriptionKey(issueID), description); } export const COMMENT_KEY_PREFIX = `comment/`; @@ -232,7 +232,7 @@ export async function putIssueComment( tx: WriteTransaction, comment: Comment ): Promise { - await tx.put(commentKey(comment.issueID, comment.id), comment); + await tx.set(commentKey(comment.issueID, comment.id), comment); } const REVERSE_TIMESTAMP_LENGTH = Number.MAX_SAFE_INTEGER.toString().length; diff --git a/package-lock.json b/package-lock.json index 57db08dc..ea96d159 100644 --- a/package-lock.json +++ b/package-lock.json @@ -32,8 +32,8 @@ "react-remark": "^2.1.0", "react-virtualized-auto-sizer": "^1.0.6", "react-window": "^1.8.6", - "replicache": ">=13.0.0", - "replicache-react": "3.0.0", + "replicache": ">=14.0.2", + "replicache-react": "5.0.0", "zod": "^3.13.4" }, "devDependencies": { @@ -1917,6 +1917,14 @@ "node": ">=6.9.0" } }, + "node_modules/@badrap/valita": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/@badrap/valita/-/valita-0.3.0.tgz", + "integrity": "sha512-bvsH70aYKOdB3rXVZXhJgGpHqxt+TcVperVvXCo9Dotpj9u0jBgQP5jgPmZNbIz0FyTvMP/oPUzqn6WS2L0l3w==", + "engines": { + "node": ">= 16" + } + }, "node_modules/@cspotcode/source-map-consumer": { "version": "0.8.0", "resolved": "https://registry.npmjs.org/@cspotcode/source-map-consumer/-/source-map-consumer-0.8.0.tgz", @@ -2872,25 +2880,25 @@ } }, "node_modules/@rocicorp/lock": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@rocicorp/lock/-/lock-1.0.1.tgz", - "integrity": "sha512-sYbcbiyEf61guk2DfcA6zzgDrW6ncJJW11JIFNSbByqYx80olhyp0IyXUMA3xmNK0YQSkAuufWvLExaWQXuzUQ==", + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@rocicorp/lock/-/lock-1.0.3.tgz", + "integrity": "sha512-aXRTG0Ul89KrV30J/p209RhMCRLIFFIT6RepvCPBicKTHaUtTlmJipgLl6QmSt5HJYYJ5P8Czp+4T4G1+6fcgQ==", "dependencies": { - "@rocicorp/resolver": "^1.0.0" + "@rocicorp/resolver": "^1.0.1" }, "engines": { "node": "^12.20.0 || ^14.13.1 || >=16.0.0" } }, "node_modules/@rocicorp/logger": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/@rocicorp/logger/-/logger-5.2.0.tgz", - "integrity": "sha512-PhnXnTxq8EdD/5e+eI/BQv1aSMG7bjVDI7Ngkje9rbo7RepsppdbwYW1CYfMXr2ZYmA46yhQbFz8bceTyRwRfA==" + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/@rocicorp/logger/-/logger-5.2.1.tgz", + "integrity": "sha512-/co4DJq3opjULOHe7hMAho/E2WJuv6rMOJ1QDlCKsPHZ09XkkKHDM8dPu+odmDHWBb5aMnnzC92WQLd05CTxnA==" }, "node_modules/@rocicorp/resolver": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/@rocicorp/resolver/-/resolver-1.0.0.tgz", - "integrity": "sha512-iK0QW74BKR0ogY4QwBEAMoevqypi5S/jjKqL6mc7KH7z2PFuOinOebsD1Ol8VIxrh23IPrMNwDNSrnfhKga9Vw==", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@rocicorp/resolver/-/resolver-1.0.1.tgz", + "integrity": "sha512-9+IK9C/du8Nrqn3LaKBxJwV4H2HyIpa7HlTuc4eQ938lL4faxN6TuQV+IpvX6PxQeR14X7yMtz1f9dfiS5fvlw==", "engines": { "node": "^12.20.0 || ^14.13.1 || >=16.0.0" } @@ -8801,13 +8809,14 @@ } }, "node_modules/replicache": { - "version": "13.0.0", - "resolved": "https://registry.npmjs.org/replicache/-/replicache-13.0.0.tgz", - "integrity": "sha512-Z4U3xSg7Tj0D+f+FLzVsg2va/9lhvqWORHZmVHPvcbYZXpaz65NITXfw0uEwxXrejRL5+2TpUDeGxWqxF1LTRw==", + "version": "14.0.2", + "resolved": "https://registry.npmjs.org/replicache/-/replicache-14.0.2.tgz", + "integrity": "sha512-Evzp9KfLV3aqwkS2BpWnJ9krhnSgFaoXdP11SWdSV7nIvur92MneZ4GCYhMpj9sgML1ifoOPbrTA23gJ0HGqdA==", "dependencies": { - "@rocicorp/lock": "^1.0.1", - "@rocicorp/logger": "^5.2.0", - "@rocicorp/resolver": "^1.0.0" + "@badrap/valita": "^0.3.0", + "@rocicorp/lock": "^1.0.3", + "@rocicorp/logger": "^5.2.1", + "@rocicorp/resolver": "^1.0.1" }, "bin": { "replicache": "out/cli.cjs" @@ -8817,9 +8826,9 @@ } }, "node_modules/replicache-react": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/replicache-react/-/replicache-react-3.0.0.tgz", - "integrity": "sha512-t2lO8+NMUzp83O4C5tzbzKZidadsslXOXNyLUWdcCGsEVTOToFK1TWW4ZFFtnhuTtDn7/DsqHnUUbQLQdGB0fw==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/replicache-react/-/replicache-react-5.0.0.tgz", + "integrity": "sha512-eudYqnM7zrwQBoKtixSp0zxc5HAA8QblOFspTD+Y/O3NfCSntFEhdJQH+juzY3WLMkokShVmPewBf8VsS6wePw==", "peerDependencies": { "react": ">=16.0 <19.0", "react-dom": ">=16.0 <19.0" @@ -11307,6 +11316,11 @@ "to-fast-properties": "^2.0.0" } }, + "@badrap/valita": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/@badrap/valita/-/valita-0.3.0.tgz", + "integrity": "sha512-bvsH70aYKOdB3rXVZXhJgGpHqxt+TcVperVvXCo9Dotpj9u0jBgQP5jgPmZNbIz0FyTvMP/oPUzqn6WS2L0l3w==" + }, "@cspotcode/source-map-consumer": { "version": "0.8.0", "resolved": "https://registry.npmjs.org/@cspotcode/source-map-consumer/-/source-map-consumer-0.8.0.tgz", @@ -11887,22 +11901,22 @@ "integrity": "sha512-q/ytXxO5NKvyT37pmisQAItCFqA7FD/vNb8dgaJy3/630Fsc+Mz9/9f2SziBoIZ30TJooXyTwZmhi1zjXmObYg==" }, "@rocicorp/lock": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@rocicorp/lock/-/lock-1.0.1.tgz", - "integrity": "sha512-sYbcbiyEf61guk2DfcA6zzgDrW6ncJJW11JIFNSbByqYx80olhyp0IyXUMA3xmNK0YQSkAuufWvLExaWQXuzUQ==", + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@rocicorp/lock/-/lock-1.0.3.tgz", + "integrity": "sha512-aXRTG0Ul89KrV30J/p209RhMCRLIFFIT6RepvCPBicKTHaUtTlmJipgLl6QmSt5HJYYJ5P8Czp+4T4G1+6fcgQ==", "requires": { - "@rocicorp/resolver": "^1.0.0" + "@rocicorp/resolver": "^1.0.1" } }, "@rocicorp/logger": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/@rocicorp/logger/-/logger-5.2.0.tgz", - "integrity": "sha512-PhnXnTxq8EdD/5e+eI/BQv1aSMG7bjVDI7Ngkje9rbo7RepsppdbwYW1CYfMXr2ZYmA46yhQbFz8bceTyRwRfA==" + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/@rocicorp/logger/-/logger-5.2.1.tgz", + "integrity": "sha512-/co4DJq3opjULOHe7hMAho/E2WJuv6rMOJ1QDlCKsPHZ09XkkKHDM8dPu+odmDHWBb5aMnnzC92WQLd05CTxnA==" }, "@rocicorp/resolver": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/@rocicorp/resolver/-/resolver-1.0.0.tgz", - "integrity": "sha512-iK0QW74BKR0ogY4QwBEAMoevqypi5S/jjKqL6mc7KH7z2PFuOinOebsD1Ol8VIxrh23IPrMNwDNSrnfhKga9Vw==" + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@rocicorp/resolver/-/resolver-1.0.1.tgz", + "integrity": "sha512-9+IK9C/du8Nrqn3LaKBxJwV4H2HyIpa7HlTuc4eQ938lL4faxN6TuQV+IpvX6PxQeR14X7yMtz1f9dfiS5fvlw==" }, "@rocicorp/undo": { "version": "0.2.0", @@ -16038,19 +16052,20 @@ } }, "replicache": { - "version": "13.0.0", - "resolved": "https://registry.npmjs.org/replicache/-/replicache-13.0.0.tgz", - "integrity": "sha512-Z4U3xSg7Tj0D+f+FLzVsg2va/9lhvqWORHZmVHPvcbYZXpaz65NITXfw0uEwxXrejRL5+2TpUDeGxWqxF1LTRw==", + "version": "14.0.2", + "resolved": "https://registry.npmjs.org/replicache/-/replicache-14.0.2.tgz", + "integrity": "sha512-Evzp9KfLV3aqwkS2BpWnJ9krhnSgFaoXdP11SWdSV7nIvur92MneZ4GCYhMpj9sgML1ifoOPbrTA23gJ0HGqdA==", "requires": { - "@rocicorp/lock": "^1.0.1", - "@rocicorp/logger": "^5.2.0", - "@rocicorp/resolver": "^1.0.0" + "@badrap/valita": "^0.3.0", + "@rocicorp/lock": "^1.0.3", + "@rocicorp/logger": "^5.2.1", + "@rocicorp/resolver": "^1.0.1" } }, "replicache-react": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/replicache-react/-/replicache-react-3.0.0.tgz", - "integrity": "sha512-t2lO8+NMUzp83O4C5tzbzKZidadsslXOXNyLUWdcCGsEVTOToFK1TWW4ZFFtnhuTtDn7/DsqHnUUbQLQdGB0fw==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/replicache-react/-/replicache-react-5.0.0.tgz", + "integrity": "sha512-eudYqnM7zrwQBoKtixSp0zxc5HAA8QblOFspTD+Y/O3NfCSntFEhdJQH+juzY3WLMkokShVmPewBf8VsS6wePw==", "requires": {} }, "require-directory": { diff --git a/package.json b/package.json index aa9fa6c6..cf9c65b0 100644 --- a/package.json +++ b/package.json @@ -38,8 +38,8 @@ "react-remark": "^2.1.0", "react-virtualized-auto-sizer": "^1.0.6", "react-window": "^1.8.6", - "replicache": ">=13.0.0", - "replicache-react": "3.0.0", + "replicache": ">=14.0.2", + "replicache-react": "5.0.0", "zod": "^3.13.4" }, "devDependencies": { From a5adc9bca01be8d080f8b4395805bf7c848ceb3b Mon Sep 17 00:00:00 2001 From: Aaron Boodman Date: Thu, 30 Nov 2023 23:52:37 -1000 Subject: [PATCH 2/6] Upgrade replicache-react to 5.0.1 --- package-lock.json | 14 +++++++------- package.json | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index ea96d159..f64a58f6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -33,7 +33,7 @@ "react-virtualized-auto-sizer": "^1.0.6", "react-window": "^1.8.6", "replicache": ">=14.0.2", - "replicache-react": "5.0.0", + "replicache-react": "5.0.1", "zod": "^3.13.4" }, "devDependencies": { @@ -8826,9 +8826,9 @@ } }, "node_modules/replicache-react": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/replicache-react/-/replicache-react-5.0.0.tgz", - "integrity": "sha512-eudYqnM7zrwQBoKtixSp0zxc5HAA8QblOFspTD+Y/O3NfCSntFEhdJQH+juzY3WLMkokShVmPewBf8VsS6wePw==", + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/replicache-react/-/replicache-react-5.0.1.tgz", + "integrity": "sha512-xwiVdoANIX9oagqK8sT/txx9ltfEmkKgbJivdVvyz13bj5PAT+b8o9xuMtY4X1bJgu+9mn04muWPKtPv9MV/ZA==", "peerDependencies": { "react": ">=16.0 <19.0", "react-dom": ">=16.0 <19.0" @@ -16063,9 +16063,9 @@ } }, "replicache-react": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/replicache-react/-/replicache-react-5.0.0.tgz", - "integrity": "sha512-eudYqnM7zrwQBoKtixSp0zxc5HAA8QblOFspTD+Y/O3NfCSntFEhdJQH+juzY3WLMkokShVmPewBf8VsS6wePw==", + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/replicache-react/-/replicache-react-5.0.1.tgz", + "integrity": "sha512-xwiVdoANIX9oagqK8sT/txx9ltfEmkKgbJivdVvyz13bj5PAT+b8o9xuMtY4X1bJgu+9mn04muWPKtPv9MV/ZA==", "requires": {} }, "require-directory": { diff --git a/package.json b/package.json index cf9c65b0..7f560b0a 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "react-virtualized-auto-sizer": "^1.0.6", "react-window": "^1.8.6", "replicache": ">=14.0.2", - "replicache-react": "5.0.0", + "replicache-react": "5.0.1", "zod": "^3.13.4" }, "devDependencies": { From b677b23d5df3931ee05265e14f17ded0384d7712 Mon Sep 17 00:00:00 2001 From: Aaron Boodman Date: Fri, 1 Dec 2023 14:19:44 -1000 Subject: [PATCH 3/6] Replicache 14.0.3 --- package-lock.json | 14 +++++++------- package.json | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index f64a58f6..e5cf077b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -32,7 +32,7 @@ "react-remark": "^2.1.0", "react-virtualized-auto-sizer": "^1.0.6", "react-window": "^1.8.6", - "replicache": ">=14.0.2", + "replicache": ">=14.0.3", "replicache-react": "5.0.1", "zod": "^3.13.4" }, @@ -8809,9 +8809,9 @@ } }, "node_modules/replicache": { - "version": "14.0.2", - "resolved": "https://registry.npmjs.org/replicache/-/replicache-14.0.2.tgz", - "integrity": "sha512-Evzp9KfLV3aqwkS2BpWnJ9krhnSgFaoXdP11SWdSV7nIvur92MneZ4GCYhMpj9sgML1ifoOPbrTA23gJ0HGqdA==", + "version": "14.0.3", + "resolved": "https://registry.npmjs.org/replicache/-/replicache-14.0.3.tgz", + "integrity": "sha512-BXj8Wg2LS15h+3H66ws5XDHlNT88mLjqEkvxhecg4OaqnfNMBJRr5/gM9Chu4gVciH5w90G1X6JTsshgvW2FBg==", "dependencies": { "@badrap/valita": "^0.3.0", "@rocicorp/lock": "^1.0.3", @@ -16052,9 +16052,9 @@ } }, "replicache": { - "version": "14.0.2", - "resolved": "https://registry.npmjs.org/replicache/-/replicache-14.0.2.tgz", - "integrity": "sha512-Evzp9KfLV3aqwkS2BpWnJ9krhnSgFaoXdP11SWdSV7nIvur92MneZ4GCYhMpj9sgML1ifoOPbrTA23gJ0HGqdA==", + "version": "14.0.3", + "resolved": "https://registry.npmjs.org/replicache/-/replicache-14.0.3.tgz", + "integrity": "sha512-BXj8Wg2LS15h+3H66ws5XDHlNT88mLjqEkvxhecg4OaqnfNMBJRr5/gM9Chu4gVciH5w90G1X6JTsshgvW2FBg==", "requires": { "@badrap/valita": "^0.3.0", "@rocicorp/lock": "^1.0.3", diff --git a/package.json b/package.json index 7f560b0a..54ebec35 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "react-remark": "^2.1.0", "react-virtualized-auto-sizer": "^1.0.6", "react-window": "^1.8.6", - "replicache": ">=14.0.2", + "replicache": ">=14.0.3", "replicache-react": "5.0.1", "zod": "^3.13.4" }, From 480182198467d81eb43a02eed3ca781b98c962ee Mon Sep 17 00:00:00 2001 From: Aaron Boodman Date: Fri, 1 Dec 2023 14:21:56 -1000 Subject: [PATCH 4/6] format --- frontend/app.tsx | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/frontend/app.tsx b/frontend/app.tsx index 9b6ba29b..80735027 100644 --- a/frontend/app.tsx +++ b/frontend/app.tsx @@ -432,8 +432,8 @@ const App = ({ rep, undoManager }: AppProps) => { const handleUpdateIssues = useCallback( async (issueUpdates: Array) => { - const uChanges: Array = - issueUpdates.map((issueUpdate) => { + const uChanges: Array = issueUpdates.map( + (issueUpdate) => { const undoChanges = pickBy( issueUpdate.issue, (_, key) => key in issueUpdate.issueChanges @@ -450,7 +450,8 @@ const App = ({ rep, undoManager }: AppProps) => { }; } return rv; - }); + } + ); await undoManager.add({ execute: () => rep.mutate.updateIssues( @@ -480,14 +481,13 @@ const App = ({ rep, undoManager }: AppProps) => { }, [setDetailIssueID] ); - const handleCloseMenu = useCallback( - () => setMenuVisible(false), - [setMenuVisible] - ); - const handleToggleMenu = useCallback( - () => setMenuVisible(!menuVisible), - [setMenuVisible, menuVisible] - ); + const handleCloseMenu = useCallback(() => setMenuVisible(false), [ + setMenuVisible, + ]); + const handleToggleMenu = useCallback(() => setMenuVisible(!menuVisible), [ + setMenuVisible, + menuVisible, + ]); const handlers = { undo: () => undoManager.undo(), From f9a8584226ef569bea39579c0cc5f9e13e3a1c84 Mon Sep 17 00:00:00 2001 From: Aaron Boodman Date: Fri, 1 Dec 2023 14:28:10 -1000 Subject: [PATCH 5/6] lint --- backend/replicache-transaction.ts | 2 +- frontend/app.tsx | 24 ++++++++++++------------ pages/d/[id].tsx | 2 +- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/backend/replicache-transaction.ts b/backend/replicache-transaction.ts index 18807f4b..a3c1e32b 100644 --- a/backend/replicache-transaction.ts +++ b/backend/replicache-transaction.ts @@ -73,7 +73,7 @@ export class ReplicacheTransaction implements WriteTransaction { } async put(key: string, value: JSONValue): Promise { - this.set(key, value); + await this.set(key, value); } async set(key: string, value: JSONValue): Promise { this._cache.set(key, { value, dirty: true }); diff --git a/frontend/app.tsx b/frontend/app.tsx index 80735027..7466cd33 100644 --- a/frontend/app.tsx +++ b/frontend/app.tsx @@ -370,7 +370,7 @@ const App = ({ rep, undoManager }: AppProps) => { useEffect(() => { console.log("partialSync", partialSync); if (!partialSyncComplete) { - rep.pull(); + void rep.pull(); } }, [rep, partialSync, partialSyncComplete]); @@ -432,8 +432,8 @@ const App = ({ rep, undoManager }: AppProps) => { const handleUpdateIssues = useCallback( async (issueUpdates: Array) => { - const uChanges: Array = issueUpdates.map( - (issueUpdate) => { + const uChanges: Array = + issueUpdates.map((issueUpdate) => { const undoChanges = pickBy( issueUpdate.issue, (_, key) => key in issueUpdate.issueChanges @@ -450,8 +450,7 @@ const App = ({ rep, undoManager }: AppProps) => { }; } return rv; - } - ); + }); await undoManager.add({ execute: () => rep.mutate.updateIssues( @@ -481,13 +480,14 @@ const App = ({ rep, undoManager }: AppProps) => { }, [setDetailIssueID] ); - const handleCloseMenu = useCallback(() => setMenuVisible(false), [ - setMenuVisible, - ]); - const handleToggleMenu = useCallback(() => setMenuVisible(!menuVisible), [ - setMenuVisible, - menuVisible, - ]); + const handleCloseMenu = useCallback( + () => setMenuVisible(false), + [setMenuVisible] + ); + const handleToggleMenu = useCallback( + () => setMenuVisible(!menuVisible), + [setMenuVisible, menuVisible] + ); const handlers = { undo: () => undoManager.undo(), diff --git a/pages/d/[id].tsx b/pages/d/[id].tsx index 37e4aa9c..996e5d55 100644 --- a/pages/d/[id].tsx +++ b/pages/d/[id].tsx @@ -39,7 +39,7 @@ export default function Home() { const channel = pusher.subscribe("default"); channel.bind("poke", () => { - r.pull(); + void r.pull(); }); } From 0686a0d91d870ee058b602fb38fda43e043c649d Mon Sep 17 00:00:00 2001 From: Aaron Boodman Date: Fri, 1 Dec 2023 14:32:39 -1000 Subject: [PATCH 6/6] prettier --- .eslintrc | 26 ++++++++++++++++---------- .github/workflows/js.yml | 4 ++-- frontend/app.tsx | 22 +++++++++++----------- 3 files changed, 29 insertions(+), 23 deletions(-) diff --git a/.eslintrc b/.eslintrc index 7849afe5..f518d6f0 100644 --- a/.eslintrc +++ b/.eslintrc @@ -7,9 +7,14 @@ "parserOptions": { "ecmaVersion": 12, "sourceType": "module", - "project": "./tsconfig.json", + "project": "./tsconfig.json" }, - "extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended", "next", "prettier"], + "extends": [ + "eslint:recommended", + "plugin:@typescript-eslint/recommended", + "next", + "prettier" + ], "rules": { "@typescript-eslint/no-floating-promises": "error", "@typescript-eslint/naming-convention": [ @@ -29,17 +34,18 @@ "error", { "VariableDeclarator": { - "object": true, - }, + "object": true + } }, { - "enforceForRenamedProperties": false, - }, + "enforceForRenamedProperties": false + } ], "no-unused-vars": "off", - "@typescript-eslint/no-unused-vars": ["error", {"argsIgnorePattern": "^_"}] + "@typescript-eslint/no-unused-vars": [ + "error", + { "argsIgnorePattern": "^_" } + ] }, - "plugins": [ - "react", "@typescript-eslint" - ] + "plugins": ["react", "@typescript-eslint"] } diff --git a/.github/workflows/js.yml b/.github/workflows/js.yml index a7ad3693..35954115 100644 --- a/.github/workflows/js.yml +++ b/.github/workflows/js.yml @@ -15,7 +15,7 @@ jobs: - uses: actions/setup-node@v2 with: node-version: 16.x - cache: 'npm' + cache: "npm" - name: npm install run: npm install - run: npm run check-format @@ -29,7 +29,7 @@ jobs: - uses: actions/setup-node@v2 with: node-version: 16.x - cache: 'npm' + cache: "npm" - name: npm install run: npm install - run: npm run build diff --git a/frontend/app.tsx b/frontend/app.tsx index 7466cd33..7e2c46ef 100644 --- a/frontend/app.tsx +++ b/frontend/app.tsx @@ -432,8 +432,8 @@ const App = ({ rep, undoManager }: AppProps) => { const handleUpdateIssues = useCallback( async (issueUpdates: Array) => { - const uChanges: Array = - issueUpdates.map((issueUpdate) => { + const uChanges: Array = issueUpdates.map( + (issueUpdate) => { const undoChanges = pickBy( issueUpdate.issue, (_, key) => key in issueUpdate.issueChanges @@ -450,7 +450,8 @@ const App = ({ rep, undoManager }: AppProps) => { }; } return rv; - }); + } + ); await undoManager.add({ execute: () => rep.mutate.updateIssues( @@ -480,14 +481,13 @@ const App = ({ rep, undoManager }: AppProps) => { }, [setDetailIssueID] ); - const handleCloseMenu = useCallback( - () => setMenuVisible(false), - [setMenuVisible] - ); - const handleToggleMenu = useCallback( - () => setMenuVisible(!menuVisible), - [setMenuVisible, menuVisible] - ); + const handleCloseMenu = useCallback(() => setMenuVisible(false), [ + setMenuVisible, + ]); + const handleToggleMenu = useCallback(() => setMenuVisible(!menuVisible), [ + setMenuVisible, + menuVisible, + ]); const handlers = { undo: () => undoManager.undo(),