Add getSettings() function

stable/1.0.x
Alex Gleason 2020-04-28 12:59:15 -05:00
rodzic ffb1804c59
commit 178fdf8818
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
3 zmienionych plików z 108 dodań i 88 usunięć

Wyświetl plik

@ -1,12 +1,112 @@
import { debounce } from 'lodash';
import { showAlertForError } from './alerts';
import { patchMe } from 'gabsocial/actions/me';
import { Map as ImmutableMap } from 'immutable';
export const SETTING_CHANGE = 'SETTING_CHANGE';
export const SETTING_SAVE = 'SETTING_SAVE';
export const FE_NAME = 'soapbox_fe';
const defaultSettings = ImmutableMap({
onboarded: false,
skinTone: 1,
reduceMotion: false,
autoPlayGif: false,
displayMedia: true,
expandSpoilers: false,
unfollowModal: false,
boostModal: false,
deleteModal: true,
defaultPrivacy: 'public',
theme: 'lime',
systemFont: false,
dyslexicFont: false,
demetricator: false,
home: ImmutableMap({
shows: ImmutableMap({
reblog: true,
reply: true,
}),
regex: ImmutableMap({
body: '',
}),
}),
notifications: ImmutableMap({
alerts: ImmutableMap({
follow: true,
favourite: true,
reblog: true,
mention: true,
poll: true,
}),
quickFilter: ImmutableMap({
active: 'all',
show: true,
advanced: false,
}),
shows: ImmutableMap({
follow: true,
favourite: true,
reblog: true,
mention: true,
poll: true,
}),
sounds: ImmutableMap({
follow: true,
favourite: true,
reblog: true,
mention: true,
poll: true,
}),
}),
community: ImmutableMap({
other: ImmutableMap({
onlyMedia: false,
}),
regex: ImmutableMap({
body: '',
}),
}),
public: ImmutableMap({
other: ImmutableMap({
onlyMedia: false,
}),
regex: ImmutableMap({
body: '',
}),
}),
direct: ImmutableMap({
regex: ImmutableMap({
body: '',
}),
}),
trends: ImmutableMap({
show: true,
}),
});
export function getSettings(getState) {
const state = getState();
const soapboxSettings = state.getIn(['soapbox', 'defaultSettings']);
return defaultSettings
.mergeDeep(soapboxSettings)
.mergeDeep(state.get('settings'));
}
export function changeSetting(path, value) {
return dispatch => {
dispatch({

Wyświetl plik

@ -7,95 +7,12 @@ import { ME_FETCH_SUCCESS } from 'gabsocial/actions/me';
import { Map as ImmutableMap, fromJS } from 'immutable';
import uuid from '../uuid';
// Default settings are in action/settings.js
//
// Settings should be accessed with `getSettings(getState).getIn(...)`
// instead of directly from the state.
const initialState = ImmutableMap({
saved: true,
onboarded: false,
skinTone: 1,
reduceMotion: false,
autoPlayGif: false,
displayMedia: true,
expandSpoilers: false,
unfollowModal: false,
boostModal: false,
deleteModal: true,
defaultPrivacy: 'public',
theme: 'lime',
systemFont: false,
dyslexicFont: false,
demetricator: false,
home: ImmutableMap({
shows: ImmutableMap({
reblog: true,
reply: true,
}),
regex: ImmutableMap({
body: '',
}),
}),
notifications: ImmutableMap({
alerts: ImmutableMap({
follow: true,
favourite: true,
reblog: true,
mention: true,
poll: true,
}),
quickFilter: ImmutableMap({
active: 'all',
show: true,
advanced: false,
}),
shows: ImmutableMap({
follow: true,
favourite: true,
reblog: true,
mention: true,
poll: true,
}),
sounds: ImmutableMap({
follow: true,
favourite: true,
reblog: true,
mention: true,
poll: true,
}),
}),
community: ImmutableMap({
other: ImmutableMap({
onlyMedia: false,
}),
regex: ImmutableMap({
body: '',
}),
}),
public: ImmutableMap({
other: ImmutableMap({
onlyMedia: false,
}),
regex: ImmutableMap({
body: '',
}),
}),
direct: ImmutableMap({
regex: ImmutableMap({
body: '',
}),
}),
trends: ImmutableMap({
show: true,
}),
});
const defaultColumns = fromJS([

Wyświetl plik

@ -13,5 +13,8 @@
},
"extensions": {
"patron": false
}
},
"defaultSettings": {
"autoPlayGif": false,
},
}