Making periodic Synchronisation
This commit is contained in:
parent
c3c36504ab
commit
e5b0c96434
@ -48,19 +48,12 @@ var Types;
|
|||||||
Types[Types["REFRESH"] = 2] = "REFRESH";
|
Types[Types["REFRESH"] = 2] = "REFRESH";
|
||||||
})(Types || (Types = {}));
|
})(Types || (Types = {}));
|
||||||
|
|
||||||
let rules = [
|
let rules = [{
|
||||||
{
|
|
||||||
match: (url) => {
|
match: (url) => {
|
||||||
return url.indexOf("/api/") >= 0;
|
return url.indexOf("/api/") >= 0;
|
||||||
},
|
},
|
||||||
type: Types.NOCACHE
|
type: Types.NOCACHE
|
||||||
},
|
},
|
||||||
{
|
|
||||||
match: (url) => {
|
|
||||||
return url.indexOf("/version_hash") >= 0;
|
|
||||||
},
|
|
||||||
type: Types.NOCACHE
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
match: () => {
|
match: () => {
|
||||||
return true;
|
return true;
|
||||||
@ -95,7 +88,12 @@ async function fromCache(request) {
|
|||||||
return matching
|
return matching
|
||||||
|
|
||||||
let res = await fetch(request.clone());
|
let res = await fetch(request.clone());
|
||||||
await cache.put(request, res);
|
await cache.put(request, {
|
||||||
|
match: (url) => {
|
||||||
|
return url.indexOf("/version_hash") >= 0;
|
||||||
|
},
|
||||||
|
type: Types.NOCACHE
|
||||||
|
}, res);
|
||||||
return await cache.match(request);
|
return await cache.match(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,7 +167,7 @@ class NotesProvider {
|
|||||||
public async start() {
|
public async start() {
|
||||||
const next = () => {
|
const next = () => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.sync().then(() => next);
|
this.sync().then(next);
|
||||||
}, 30000)
|
}, 30000)
|
||||||
}
|
}
|
||||||
this.syncedObservableServer.send((await this.oplogDB.getAll()).length <= 0);
|
this.syncedObservableServer.send((await this.oplogDB.getAll()).length <= 0);
|
||||||
|
Loading…
Reference in New Issue
Block a user