ui collection load: retry loading if index api fails, smooth transition from previous version

This commit is contained in:
Ilya Kreymer
2021-04-25 22:32:37 -07:00
parent 0ef8f955db
commit 5e72914bab
3 changed files with 31 additions and 30 deletions
+3 -2
View File
@@ -104,7 +104,7 @@ class CollIndex extends LitElement
const resp = await fetch(`${apiPrefix}/coll-index?${this.indexParams}`); const resp = await fetch(`${apiPrefix}/coll-index?${this.indexParams}`);
try { try {
if (resp.status !== 200) { if (resp.status !== 200) {
throw new Error("Invalid API Response"); throw new Error("Invalid API Response, Retry");
} }
const json = await resp.json(); const json = await resp.json();
this.colls = json.colls.map((coll) => { this.colls = json.colls.map((coll) => {
@@ -116,7 +116,8 @@ class CollIndex extends LitElement
this.sortedColls = []; this.sortedColls = [];
} catch (e) { } catch (e) {
// likely no sw registered yet, or waiting for new sw to register // likely no sw registered yet, or waiting for new sw to register, retry again
setTimeout(() => this.loadColls(), 5000);
} }
} }
+5 -5
View File
File diff suppressed because one or more lines are too long
+23 -23
View File
File diff suppressed because one or more lines are too long