about summary refs log tree commit diff
path: root/app/javascript
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2023-04-22 19:13:20 +0200
committerGitHub <noreply@github.com>2023-04-22 19:13:20 +0200
commit5b58ebb04fe197cc7aa0cfc05a4d1b2df8da0050 (patch)
tree13247fa31066595f1c699f098894b578611c60d9 /app/javascript
parent2ebbfebfe9c7c967e3bcc9da0eec4628f9188233 (diff)
Fix JS crashing if initial-state is not set (#2193)
Fixes issues with the JS for at least sign-up pages not working
Diffstat (limited to 'app/javascript')
-rw-r--r--app/javascript/flavours/glitch/initial_state.js10
1 files changed, 6 insertions, 4 deletions
diff --git a/app/javascript/flavours/glitch/initial_state.js b/app/javascript/flavours/glitch/initial_state.js
index 8b135006d..c3b27687d 100644
--- a/app/javascript/flavours/glitch/initial_state.js
+++ b/app/javascript/flavours/glitch/initial_state.js
@@ -96,10 +96,12 @@ const element = document.getElementById('initial-state');
 const initialState = element?.textContent && JSON.parse(element.textContent);
 
 // Glitch-soc-specific “local settings”
-try {
-  initialState.local_settings = JSON.parse(localStorage.getItem('mastodon-settings'));
-} catch (e) {
-  initialState.local_settings = {};
+if (initialState) {
+  try {
+    initialState.local_settings = JSON.parse(localStorage.getItem('mastodon-settings'));
+  } catch (e) {
+    initialState.local_settings = {};
+  }
 }
 
 /**