Skip to content

Commit 0d44871

Browse files
Automatically synchronise after a month (#237)
* auto sync * inline one month * inline isstale * Apply suggestions from code review --------- Co-authored-by: Steven Clontz <steven.clontz@gmail.com>
1 parent 40c598c commit 0d44871

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

packages/viewer/src/context.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,10 @@ export function initialize({
6666

6767
db.subscribe(project(store))
6868

69-
if (!pre.sync) {
69+
if (
70+
!pre.sync ||
71+
new Date(pre.sync.at).getTime() < Date.now() - 7 * 24 * 60 * 60 * 1000
72+
) {
7073
store.sync.sync()
7174
}
7275

packages/viewer/src/stores/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,10 @@ export function create(pre: Prestore, gateway: Gateway.Sync): Store {
9494

9595
set(pre.properties, pre.spaces, pre.theorems, pre.traits)
9696

97-
if (!pre.sync) {
97+
if (
98+
!pre.sync ||
99+
new Date(pre.sync.at).getTime() < Date.now() - 7 * 24 * 60 * 60 * 1000
100+
) {
98101
sync.sync()
99102
}
100103

0 commit comments

Comments
 (0)