Skip to content

Commit

Permalink
update to replicache 14
Browse files Browse the repository at this point in the history
see rocicorp#159 which we're merging into this fork with this commit
  • Loading branch information
tantaman committed Dec 5, 2023
1 parent dd1ffc7 commit a541701
Show file tree
Hide file tree
Showing 6 changed files with 1,488 additions and 42 deletions.
2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"react-remark": "^2.1.0",
"react-virtualized-auto-sizer": "^1.0.20",
"react-window": "^1.8.9",
"replicache-react": "3.0.0",
"replicache-react": "5.0.1",
"shared": "^0.1.0",
"todomvc-app-css": "^2.4.2"
},
Expand Down
18 changes: 5 additions & 13 deletions client/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import {
IssueUpdate,
IssueUpdateWithID,
ISSUE_KEY_PREFIX,
PartialSyncState,
} from 'shared';
import {getFilters, getIssueOrder} from './filters';
import {Layout} from './layout/layout';
Expand All @@ -49,27 +48,20 @@ 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'},
);
const partialSyncComplete = partialSync === 'COMPLETE';
function pull() {
useEffect(() => {
console.log('partialSync', partialSync);
if (!partialSyncComplete) {
if (document.hidden) {
setTimeout(pull, 1000);
} else {
rep.pull();
}
void rep.pull();
}
}
useEffect(pull, [rep, partialSync, partialSyncComplete]);
}, [rep, partialSync, partialSyncComplete]);

useEffect(() => {
const ev = new EventSource(`/api/replicache/poke?channel=poke`);
Expand Down
1 change: 0 additions & 1 deletion client/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {Replicache} from 'replicache';
import {UndoManager} from '@rocicorp/undo';
import App from './app';

// TODO: see `id.tsx`
async function init() {
// See https://doc.replicache.dev/licensing for how to get a license key.
const licenseKey = import.meta.env.VITE_REPLICACHE_LICENSE_KEY;
Expand Down
33 changes: 9 additions & 24 deletions client/src/issue/issue-detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,8 @@ import {sortBy} from 'lodash';
import {useIssueDetailState} from '../hooks/query-state-hooks';
import {
Comment,
<<<<<<< HEAD:frontend/issue-detail.tsx
getIssueComments,
getIssueDescription,
=======
Description,
getDescription,
getIssue,
>>>>>>> f8d3a33 (re-write to use the row versioning strategy and rails.):client/src/issue/issue-detail.tsx
Issue,
IssueUpdate,
Priority,
Expand Down Expand Up @@ -101,12 +95,7 @@ export default function IssueDetail({
}
return null;
},
<<<<<<< HEAD:frontend/issue-detail.tsx
{ default: null, dependencies: [detailIssueID] }
=======
null,
[detailIssueID],
>>>>>>> f8d3a33 (re-write to use the row versioning strategy and rails.):client/src/issue/issue-detail.tsx
{default: null, dependencies: [detailIssueID]},
);
const description = useSubscribe(
rep,
Expand All @@ -116,12 +105,10 @@ export default function IssueDetail({
}
return null;
},
<<<<<<< HEAD:frontend/issue-detail.tsx
{ default: null, dependencies: [detailIssueID] }
=======
null,
[detailIssueID],
>>>>>>> f8d3a33 (re-write to use the row versioning strategy and rails.):client/src/issue/issue-detail.tsx
{
default: null,
dependencies: [detailIssueID],
},
);

const comments = useSubscribe(
Expand All @@ -132,12 +119,10 @@ export default function IssueDetail({
}
return [];
},
<<<<<<< HEAD:frontend/issue-detail.tsx
{ default: [], dependencies: [detailIssueID] }
=======
[],
[detailIssueID],
>>>>>>> f8d3a33 (re-write to use the row versioning strategy and rails.):client/src/issue/issue-detail.tsx
{
default: [],
dependencies: [detailIssueID],
},
);

const handleClose = useCallback(async () => {
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "todo-row-versioning",
"name": "repliear-row-versioning",
"version": "0.1.0",
"devDependencies": {
"@headlessui/react": "^1.7.16",
Expand Down Expand Up @@ -31,8 +31,8 @@
"dependencies": {
"@emotion/styled": "^11.11.0",
"@mui/styled-engine": "^5.14.17",
"@rocicorp/rails": "0.8.0",
"@rocicorp/rails": "0.8.1",
"fractional-indexing": "^3.2.0",
"replicache": "^13.0.1"
"replicache": ">=14.0.3"
}
}
Loading

0 comments on commit a541701

Please sign in to comment.