aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortdro <tdro@noreply.example.com>2024-02-24 18:33:47 -0500
committertdro <tdro@noreply.example.com>2024-02-24 18:33:47 -0500
commite05da6316590f7b355b2526c2da78d4a3682b65d (patch)
tree12fbe1669567a6db1802eb998b8c2c5dd69b3c2b
parent07dc8aee3651dd68a741055a8edb5de5b361999e (diff)
downloadcanory-e05da6316590f7b355b2526c2da78d4a3682b65d.tar.gz
canory-e05da6316590f7b355b2526c2da78d4a3682b65d.tar.bz2
canory-e05da6316590f7b355b2526c2da78d4a3682b65d.zip
static/js/forms: Early persistence
-rw-r--r--assets/js/index.js14
-rw-r--r--static/js/forms.ts16
2 files changed, 27 insertions, 3 deletions
diff --git a/assets/js/index.js b/assets/js/index.js
index 69001ad..55a9bf2 100644
--- a/assets/js/index.js
+++ b/assets/js/index.js
@@ -739,8 +739,7 @@
});
});
[
- "storage",
- "DOMContentLoaded"
+ "storage"
].forEach(function(event) {
self.addEventListener(event, function() {
let stylesheet;
@@ -775,6 +774,17 @@
}
});
});
+ const early = setInterval(persistence, 4);
+ function persistence() {
+ if (document.styleSheets.length > 0) {
+ self.dispatchEvent(new Event("storage"));
+ clearInterval(early);
+ }
+ }
+ self.addEventListener("DOMContentLoaded", function() {
+ self.dispatchEvent(new Event("storage"));
+ clearInterval(early);
+ });
})();
(function() {
const timeout = 300;
diff --git a/static/js/forms.ts b/static/js/forms.ts
index 533623f..e35a4b2 100644
--- a/static/js/forms.ts
+++ b/static/js/forms.ts
@@ -69,7 +69,7 @@
});
});
- ["storage", "DOMContentLoaded"].forEach(function (event) {
+ ["storage"].forEach(function (event) {
self.addEventListener(event, function () {
let stylesheet;
@@ -106,4 +106,18 @@
}
});
});
+
+ const early = setInterval(persistence, 4);
+
+ function persistence() {
+ if (document.styleSheets.length > 0) {
+ self.dispatchEvent(new Event("storage"));
+ clearInterval(early);
+ }
+ }
+
+ self.addEventListener("DOMContentLoaded", function () {
+ self.dispatchEvent(new Event("storage"));
+ clearInterval(early);
+ });
})();