summaryrefslogtreecommitdiff
path: root/app/load.js
diff options
context:
space:
mode:
authorMinteck <contact@minteck.org>2022-08-31 22:03:07 +0200
committerMinteck <contact@minteck.org>2022-08-31 22:03:07 +0200
commitb5f589c323f415bb42ea7069cb4d1a8a2233dd69 (patch)
treec3b80234ab7f463a2e7b8b672ceff57422b3496b /app/load.js
parent09bd0164ebc020a54b944b7326dcba496fb5d82c (diff)
downloadpluralconnect-b5f589c323f415bb42ea7069cb4d1a8a2233dd69.tar.gz
pluralconnect-b5f589c323f415bb42ea7069cb4d1a8a2233dd69.tar.bz2
pluralconnect-b5f589c323f415bb42ea7069cb4d1a8a2233dd69.zip
Update I guess - Stuffie
Diffstat (limited to 'app/load.js')
-rw-r--r--app/load.js58
1 files changed, 54 insertions, 4 deletions
diff --git a/app/load.js b/app/load.js
index 9e4d3b9..1be0b57 100644
--- a/app/load.js
+++ b/app/load.js
@@ -46,6 +46,21 @@ let valuesToGet = {
limited: false,
name: "Switches at Raindrops...",
},
+ "actions": {
+ url: "/api/data?f=actions.json",
+ limited: false,
+ name: "Actions...",
+ },
+ "rules": {
+ url: "/api/data?f=rules.json",
+ limited: false,
+ name: "Systems rules...",
+ },
+ "nicknames": {
+ url: "/api/data?f=nicknames.json",
+ limited: false,
+ name: "Relations nicknames...",
+ },
"peh-cloudburst-data": {
url: "/api/cloudburst-data",
limited: false,
@@ -56,6 +71,16 @@ let valuesToGet = {
limited: false,
name: "Raindrops data...",
},
+ "peh-cloudburst-scored": {
+ url: "/api/cloudburst-scored",
+ limited: false,
+ name: "Cloudburst ordered members...",
+ },
+ "peh-raindrops-scored": {
+ url: "/api/raindrops-scored",
+ limited: false,
+ name: "Raindrops ordered members...",
+ },
"peh-cloudburst-banners": {
url: "/api/cloudburst-banners",
limited: false,
@@ -138,13 +163,27 @@ async function getNewValue() {
}
try {
- if (valuesToGet[keys[0]].condition && !(await valuesToGet[keys[0]].condition())) throw new Error();
+ if (valuesToGet[keys[0]].condition && !(await valuesToGet[keys[0]].condition())) {
+ keys.shift();
+
+ if (!keys[0]) {
+ await localforage.setItem("refresh", new Date().toISOString());
+ await postLoad();
+ return;
+ }
+
+ document.getElementById("progress-inner").style.width = ((index / Object.keys(valuesToGet).length) * 100) + "%";
+ index++;
+ await getNewValue();
+ return;
+ }
document.getElementById("loader-message").innerText = valuesToGet[keys[0]].name;
await localforage.setItem(keys[0], (await (await fetchPlus(valuesToGet[keys[0]]["url"], { timeout: 3000 })).text()));
keys.shift();
if (!keys[0]) {
+ await localforage.setItem("refresh", new Date().toISOString());
await postLoad();
return;
}
@@ -155,6 +194,9 @@ async function getNewValue() {
await getNewValue();
}, valuesToGet[keys[0]]["limited"] ? 550 : 0);
} catch (e) {
+ console.log("Error while fetching", keys[0]);
+ console.error(e);
+
for (let key of Object.keys(valuesToGet)) {
if (await localforage.getItem(key) === null) {
throw new Error("App requested key '" + key + "' but it can't be retrieved at the moment");
@@ -181,6 +223,8 @@ async function postLoad() {
if (key !== "images") localStorage.setItem(key, await localforage.getItem(key))
}
+ window.images = JSON.parse(await localforage.getItem("images"));
+
localStorage.setItem("pluralkit-0", localStorage.getItem("pluralkit-raindrops-members"));
localStorage.setItem("pluralkit-1", localStorage.getItem("pluralkit-cloudburst-members"));
@@ -242,6 +286,13 @@ async function postLoad() {
break;
}
+ window.otherSystem = window.data.identity.id === "raindrops" ? "cloudburst" : "raindrops";
+ window.otherFronters = window.data["pluralkit-" + otherSystem + "-fronters"];
+
+ document.getElementById("home-other-system").innerText = otherSystem === "raindrops" ? "Raindrops System" : "Cloudburst System";
+ document.getElementById("home-other-name").innerText = window.otherFronters.members[0].display_name ?? window.otherFronters.members[0].name;
+ document.getElementById("home-other-img").src = window.images.profile[otherSystem === "raindrops" ? "gdapd" : "ynmuc"][window.otherFronters.members[0].id];
+
if (!window.connected) {
document.getElementById("home-app-planner").classList.add("disabled");
document.getElementById("home-app-emergency").classList.add("disabled");
@@ -261,9 +312,8 @@ async function postLoad() {
}
}
- window.currentMemberData = JSON.parse(localStorage.getItem("peh-" + JSON.parse(localStorage.getItem("identity")).id + "-banners"))[JSON.parse(localStorage.getItem("pluralkit-" + JSON.parse(localStorage.getItem("identity")).id + "-fronters")).members[0].name];
-
- //await refreshBanner(true); refreshTooltips();
+ document.getElementById("copyright-year").innerText = new Date().getFullYear().toString();
+ document.getElementById("update-date").innerText = timeAgo(await localforage.getItem("refresh"));
setInterval(async () => {
Array.from(document.getElementsByClassName("relative-time")).forEach((el) => {