|
|
@ -1,10 +1,13 @@
|
|
|
|
|
|
|
|
import { Map as ImmutableMap, List as ImmutableList, OrderedSet as ImmutableOrderedSet } from 'immutable';
|
|
|
|
import { debounce } from 'lodash';
|
|
|
|
import { debounce } from 'lodash';
|
|
|
|
import { showAlertForError } from './alerts';
|
|
|
|
import { createSelector } from 'reselect';
|
|
|
|
|
|
|
|
|
|
|
|
import { patchMe } from 'soapbox/actions/me';
|
|
|
|
import { patchMe } from 'soapbox/actions/me';
|
|
|
|
import { Map as ImmutableMap, List as ImmutableList, OrderedSet as ImmutableOrderedSet } from 'immutable';
|
|
|
|
|
|
|
|
import { isLoggedIn } from 'soapbox/utils/auth';
|
|
|
|
import { isLoggedIn } from 'soapbox/utils/auth';
|
|
|
|
|
|
|
|
|
|
|
|
import uuid from '../uuid';
|
|
|
|
import uuid from '../uuid';
|
|
|
|
import { createSelector } from 'reselect';
|
|
|
|
|
|
|
|
|
|
|
|
import { showAlertForError } from './alerts';
|
|
|
|
|
|
|
|
|
|
|
|
export const SETTING_CHANGE = 'SETTING_CHANGE';
|
|
|
|
export const SETTING_CHANGE = 'SETTING_CHANGE';
|
|
|
|
export const SETTING_SAVE = 'SETTING_SAVE';
|
|
|
|
export const SETTING_SAVE = 'SETTING_SAVE';
|
|
|
@ -165,6 +168,18 @@ export const getSettings = createSelector([
|
|
|
|
.mergeDeep(settings);
|
|
|
|
.mergeDeep(settings);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export function changeSettingImmediate(path, value) {
|
|
|
|
|
|
|
|
return dispatch => {
|
|
|
|
|
|
|
|
dispatch({
|
|
|
|
|
|
|
|
type: SETTING_CHANGE,
|
|
|
|
|
|
|
|
path,
|
|
|
|
|
|
|
|
value,
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dispatch(saveSettingsImmediate());
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export function changeSetting(path, value) {
|
|
|
|
export function changeSetting(path, value) {
|
|
|
|
return dispatch => {
|
|
|
|
return dispatch => {
|
|
|
|
dispatch({
|
|
|
|
dispatch({
|
|
|
@ -177,7 +192,8 @@ export function changeSetting(path, value) {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const debouncedSave = debounce((dispatch, getState) => {
|
|
|
|
export function saveSettingsImmediate() {
|
|
|
|
|
|
|
|
return (dispatch, getState) => {
|
|
|
|
if (!isLoggedIn(getState)) return;
|
|
|
|
if (!isLoggedIn(getState)) return;
|
|
|
|
|
|
|
|
|
|
|
|
const state = getState();
|
|
|
|
const state = getState();
|
|
|
@ -194,6 +210,11 @@ const debouncedSave = debounce((dispatch, getState) => {
|
|
|
|
}).catch(error => {
|
|
|
|
}).catch(error => {
|
|
|
|
dispatch(showAlertForError(error));
|
|
|
|
dispatch(showAlertForError(error));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const debouncedSave = debounce((dispatch, getState) => {
|
|
|
|
|
|
|
|
dispatch(saveSettingsImmediate());
|
|
|
|
}, 5000, { trailing: true });
|
|
|
|
}, 5000, { trailing: true });
|
|
|
|
|
|
|
|
|
|
|
|
export function saveSettings() {
|
|
|
|
export function saveSettings() {
|
|
|
|