Fix JS crashing if initial-state is not set (#2193)

Fixes issues with the JS for at least sign-up pages not working
pull/59/head
Claire 2023-04-22 19:13:20 +02:00 committed by GitHub
parent 2ebbfebfe9
commit 5b58ebb04f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 4 deletions

View File

@ -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 = {};
}
}
/**