M app/javascript/flavours/glitch/actions/settings.js => app/javascript/flavours/glitch/actions/settings.js +2 -3
@@ 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() {
M public/verify-state.js => public/verify-state.js +12 -2
@@ 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
+}