diff --git a/app/javascript/flavours/glitch/actions/settings.js b/app/javascript/flavours/glitch/actions/settings.js index 120ae133e..fa0d0f5b6 100644 --- a/app/javascript/flavours/glitch/actions/settings.js +++ b/app/javascript/flavours/glitch/actions/settings.js @@ -26,9 +26,8 @@ const debouncedSave = debounce((dispatch, getState) => { const data = getState().get('settings').filter((_, path) => path !== 'saved').toJS(); - api(getState).put('/api/web/settings', { data }) - .then(() => dispatch({ type: SETTING_SAVE })) - .catch(error => dispatch(showAlertForError(error))); + localStorage.setItem('web_settings', JSON.stringify(data)); + dispatch({ type: SETTING_SAVE }); }, 5000, { trailing: true }); export function saveSettings() { diff --git a/public/verify-state.js b/public/verify-state.js index 8a12d8bdd..6b2aab14a 100644 --- a/public/verify-state.js +++ b/public/verify-state.js @@ -6,14 +6,20 @@ async function loadState() { const domain = localStorage.getItem('domain'); const access_token = localStorage.getItem('access_token'); const storedState = localStorage.getItem('initial_state'); + const webSettings = localStorage.getItem('web_settings'); if (!domain || !access_token) { window.location.href = '/login.html'; return; } + /* We try to load the initial state now to prevent a race between us and mastodon */ if (storedState && window.location.pathname !== '/prepare.html') { - document.getElementById('initial-state').textContent = storedState; + const state = JSON.parse(storedState); + if (webSettings) { + state.settings = JSON.parse(webSettings); + } + document.getElementById('initial-state').textContent = JSON.stringify(state); } const apiUrl = `${protocol}${domain}/api`; @@ -1092,8 +1098,12 @@ async function loadState() { ], }; + if (webSettings) { + state.settings = JSON.parse(webSettings); + } + const json = JSON.stringify(state); if (window.location.pathname !== '/prepare.html') document.getElementById('initial-state').textContent = json; localStorage.setItem("initial_state", json); if (window.location.pathname === '/prepare.html') window.location.href = '/'; -} \ No newline at end of file +}