Skip to content

Commit 02dc6d8

Browse files
committed
update to replicache 14
see #159 which we're merging into this fork with this commit
1 parent 7e2bf41 commit 02dc6d8

File tree

6 files changed

+1494
-28
lines changed

6 files changed

+1494
-28
lines changed

client/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"react-remark": "^2.1.0",
3333
"react-virtualized-auto-sizer": "^1.0.20",
3434
"react-window": "^1.8.9",
35-
"replicache-react": "3.0.0",
35+
"replicache-react": "5.0.1",
3636
"shared": "^0.1.0",
3737
"todomvc-app-css": "^2.4.2"
3838
},

client/src/app.tsx

+5-13
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import {
2222
IssueUpdate,
2323
IssueUpdateWithID,
2424
ISSUE_KEY_PREFIX,
25-
PartialSyncState,
2625
} from 'shared';
2726
import {getFilters, getIssueOrder} from './filters';
2827
import {Layout} from './layout/layout';
@@ -49,27 +48,20 @@ const App = ({rep, undoManager}: AppProps) => {
4948
issueOrder: getIssueOrder(view, orderBy),
5049
});
5150

52-
const partialSync = useSubscribe<
53-
PartialSyncState | 'NOT_RECEIVED_FROM_SERVER'
54-
>(
51+
const partialSync = useSubscribe(
5552
rep,
5653
async (tx: ReadTransaction) => {
5754
return (await getPartialSyncState(tx)) || 'NOT_RECEIVED_FROM_SERVER';
5855
},
59-
'NOT_RECEIVED_FROM_SERVER',
56+
{default: 'NOT_RECEIVED_FROM_SERVER'},
6057
);
6158
const partialSyncComplete = partialSync === 'COMPLETE';
62-
function pull() {
59+
useEffect(() => {
6360
console.log('partialSync', partialSync);
6461
if (!partialSyncComplete) {
65-
if (document.hidden) {
66-
setTimeout(pull, 1000);
67-
} else {
68-
rep.pull();
69-
}
62+
void rep.pull();
7063
}
71-
}
72-
useEffect(pull, [rep, partialSync, partialSyncComplete]);
64+
}, [rep, partialSync, partialSyncComplete]);
7365

7466
useEffect(() => {
7567
const ev = new EventSource(`/api/replicache/poke?channel=poke`);

client/src/index.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {Replicache} from 'replicache';
55
import {UndoManager} from '@rocicorp/undo';
66
import App from './app';
77

8-
// TODO: see `id.tsx`
98
async function init() {
109
// See https://doc.replicache.dev/licensing for how to get a license key.
1110
const licenseKey = import.meta.env.VITE_REPLICACHE_LICENSE_KEY;

client/src/issue/issue-detail.tsx

+15-10
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import {sortBy} from 'lodash';
1919
import {useIssueDetailState} from '../hooks/query-state-hooks';
2020
import {
2121
Comment,
22-
Description,
2322
getDescription,
2423
getIssue,
2524
Issue,
@@ -88,39 +87,45 @@ export default function IssueDetail({
8887
}
8988
}, [issues, detailIssueID]);
9089

91-
const issue = useSubscribe<Issue | null>(
90+
const issue = useSubscribe(
9291
rep,
9392
async tx => {
9493
if (detailIssueID) {
9594
return (await getIssue(tx, detailIssueID)) || null;
9695
}
9796
return null;
9897
},
99-
null,
100-
[detailIssueID],
98+
{
99+
default: null,
100+
dependencies: [detailIssueID],
101+
},
101102
);
102-
const description = useSubscribe<Description | null>(
103+
const description = useSubscribe(
103104
rep,
104105
async tx => {
105106
if (detailIssueID) {
106107
return (await getDescription(tx, detailIssueID)) || null;
107108
}
108109
return null;
109110
},
110-
null,
111-
[detailIssueID],
111+
{
112+
default: null,
113+
dependencies: [detailIssueID],
114+
},
112115
);
113116

114-
const comments = useSubscribe<Comment[] | []>(
117+
const comments = useSubscribe(
115118
rep,
116119
async tx => {
117120
if (detailIssueID) {
118121
return (await getIssueComments(tx, detailIssueID)) || [];
119122
}
120123
return [];
121124
},
122-
[],
123-
[detailIssueID],
125+
{
126+
default: [],
127+
dependencies: [detailIssueID],
128+
},
124129
);
125130

126131
const handleClose = useCallback(async () => {

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "todo-row-versioning",
2+
"name": "repliear-row-versioning",
33
"version": "0.1.0",
44
"devDependencies": {
55
"@headlessui/react": "^1.7.16",
@@ -31,8 +31,8 @@
3131
"dependencies": {
3232
"@emotion/styled": "^11.11.0",
3333
"@mui/styled-engine": "^5.14.17",
34-
"@rocicorp/rails": "0.8.0",
34+
"@rocicorp/rails": "0.8.1",
3535
"fractional-indexing": "^3.2.0",
36-
"replicache": "^13.0.1"
36+
"replicache": ">=14.0.3"
3737
}
3838
}

0 commit comments

Comments
 (0)