Don't persist default settings

Only persist settings if they've been overridden by the user
This commit is contained in:
Alex Gleason 2020-04-28 13:49:39 -05:00
parent 178fdf8818
commit a60c47bb19
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7
31 changed files with 86 additions and 57 deletions

View file

@ -11,6 +11,7 @@ import { showAlertForError } from './alerts';
import { showAlert } from './alerts'; import { showAlert } from './alerts';
import { defineMessages } from 'react-intl'; import { defineMessages } from 'react-intl';
import { openModal, closeModal } from './modal'; import { openModal, closeModal } from './modal';
import { getSettings } from './settings';
let cancelFetchComposeSuggestionsAccounts; let cancelFetchComposeSuggestionsAccounts;
@ -136,7 +137,7 @@ export function handleComposeSubmit(dispatch, getState, response, status) {
if (timeline && timeline.get('items').size > 0 && timeline.getIn(['items', 0]) !== null && timeline.get('online')) { if (timeline && timeline.get('items').size > 0 && timeline.getIn(['items', 0]) !== null && timeline.get('online')) {
let dequeueArgs = {}; let dequeueArgs = {};
if (timelineId === 'community') dequeueArgs.onlyMedia = getState().getIn(['settings', 'community', 'other', 'onlyMedia']); if (timelineId === 'community') dequeueArgs.onlyMedia = getSettings(getState()).getIn(['community', 'other', 'onlyMedia']);
dispatch(dequeueTimeline(timelineId, null, dequeueArgs)); dispatch(dequeueTimeline(timelineId, null, dequeueArgs));
dispatch(updateTimeline(timelineId, { ...response.data })); dispatch(updateTimeline(timelineId, { ...response.data }));
} }

View file

@ -1,3 +1,4 @@
import { getSettings } from '../settings';
import { normalizeAccount, normalizeStatus, normalizePoll } from './normalizer'; import { normalizeAccount, normalizeStatus, normalizePoll } from './normalizer';
export const ACCOUNT_IMPORT = 'ACCOUNT_IMPORT'; export const ACCOUNT_IMPORT = 'ACCOUNT_IMPORT';
@ -65,7 +66,7 @@ export function importFetchedStatuses(statuses) {
function processStatus(status) { function processStatus(status) {
const normalOldStatus = getState().getIn(['statuses', status.id]); const normalOldStatus = getState().getIn(['statuses', status.id]);
const expandSpoilers = getState().getIn(['settings', 'expandSpoilers']); const expandSpoilers = getSettings(getState()).get('expandSpoilers');
pushUnique(normalStatuses, normalizeStatus(status, normalOldStatus, expandSpoilers)); pushUnique(normalStatuses, normalizeStatus(status, normalOldStatus, expandSpoilers));
pushUnique(accounts, status.account); pushUnique(accounts, status.account);

View file

@ -8,7 +8,7 @@ import {
importFetchedStatus, importFetchedStatus,
importFetchedStatuses, importFetchedStatuses,
} from './importer'; } from './importer';
import { saveSettings } from './settings'; import { getSettings, saveSettings } from './settings';
import { defineMessages } from 'react-intl'; import { defineMessages } from 'react-intl';
import { List as ImmutableList } from 'immutable'; import { List as ImmutableList } from 'immutable';
import { unescapeHTML } from '../utils/html'; import { unescapeHTML } from '../utils/html';
@ -50,7 +50,7 @@ const fetchRelatedRelationships = (dispatch, notifications) => {
export function updateNotifications(notification, intlMessages, intlLocale) { export function updateNotifications(notification, intlMessages, intlLocale) {
return (dispatch, getState) => { return (dispatch, getState) => {
const showInColumn = getState().getIn(['settings', 'notifications', 'shows', notification.type], true); const showInColumn = getSettings(getState()).getIn(['notifications', 'shows', notification.type], true);
if (showInColumn) { if (showInColumn) {
dispatch(importFetchedAccount(notification.account)); dispatch(importFetchedAccount(notification.account));
@ -71,9 +71,9 @@ export function updateNotifications(notification, intlMessages, intlLocale) {
export function updateNotificationsQueue(notification, intlMessages, intlLocale, curPath) { export function updateNotificationsQueue(notification, intlMessages, intlLocale, curPath) {
return (dispatch, getState) => { return (dispatch, getState) => {
const showAlert = getState().getIn(['settings', 'notifications', 'alerts', notification.type], true); const showAlert = getSettings(getState()).getIn(['notifications', 'alerts', notification.type], true);
const filters = getFilters(getState(), { contextType: 'notifications' }); const filters = getFilters(getState(), { contextType: 'notifications' });
const playSound = getState().getIn(['settings', 'notifications', 'sounds', notification.type], true); const playSound = getSettings(getState()).getIn(['notifications', 'sounds', notification.type], true);
let filtered = false; let filtered = false;
@ -140,7 +140,7 @@ export function dequeueNotifications() {
}; };
}; };
const excludeTypesFromSettings = state => state.getIn(['settings', 'notifications', 'shows']).filter(enabled => !enabled).keySeq().toJS(); const excludeTypesFromSettings = getState => getSettings(getState()).getIn(['notifications', 'shows']).filter(enabled => !enabled).keySeq().toJS();
const excludeTypesFromFilter = filter => { const excludeTypesFromFilter = filter => {
const allTypes = ImmutableList(['follow', 'favourite', 'reblog', 'mention', 'poll']); const allTypes = ImmutableList(['follow', 'favourite', 'reblog', 'mention', 'poll']);
@ -153,7 +153,7 @@ export function expandNotifications({ maxId } = {}, done = noOp) {
return (dispatch, getState) => { return (dispatch, getState) => {
if (!getState().get('me')) return; if (!getState().get('me')) return;
const activeFilter = getState().getIn(['settings', 'notifications', 'quickFilter', 'active']); const activeFilter = getSettings(getState()).getIn(['notifications', 'quickFilter', 'active']);
const notifications = getState().get('notifications'); const notifications = getState().get('notifications');
const isLoadingMore = !!maxId; const isLoadingMore = !!maxId;
@ -165,7 +165,7 @@ export function expandNotifications({ maxId } = {}, done = noOp) {
const params = { const params = {
max_id: maxId, max_id: maxId,
exclude_types: activeFilter === 'all' exclude_types: activeFilter === 'all'
? excludeTypesFromSettings(getState()) ? excludeTypesFromSettings(getState)
: excludeTypesFromFilter(activeFilter), : excludeTypesFromFilter(activeFilter),
}; };

View file

@ -98,9 +98,7 @@ const defaultSettings = ImmutableMap({
}), }),
}); });
export function getSettings(state) {
export function getSettings(getState) {
const state = getState();
const soapboxSettings = state.getIn(['soapbox', 'defaultSettings']); const soapboxSettings = state.getIn(['soapbox', 'defaultSettings']);
return defaultSettings return defaultSettings
.mergeDeep(soapboxSettings) .mergeDeep(soapboxSettings)
@ -122,7 +120,7 @@ export function changeSetting(path, value) {
const debouncedSave = debounce((dispatch, getState) => { const debouncedSave = debounce((dispatch, getState) => {
const state = getState(); const state = getState();
if (!state.get('me')) return; if (!state.get('me')) return;
if (state.getIn(['settings', 'saved'])) return; if (getSettings(state).getIn(['saved'])) return;
const data = state.get('settings').delete('saved').toJS(); const data = state.get('settings').delete('saved').toJS();

View file

@ -2,9 +2,10 @@ import React from 'react';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import ImmutablePropTypes from 'react-immutable-proptypes'; import ImmutablePropTypes from 'react-immutable-proptypes';
import { getSettings } from 'gabsocial/actions/settings';
const mapStateToProps = state => ({ const mapStateToProps = state => ({
animate: state.getIn(['settings', 'autoPlayGif']), animate: getSettings(state).get('autoPlayGif'),
}); });
export default @connect(mapStateToProps) export default @connect(mapStateToProps)

View file

@ -2,9 +2,10 @@ import React from 'react';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import ImmutablePropTypes from 'react-immutable-proptypes'; import ImmutablePropTypes from 'react-immutable-proptypes';
import { getSettings } from 'gabsocial/actions/settings';
const mapStateToProps = state => ({ const mapStateToProps = state => ({
animate: state.getIn(['settings', 'autoPlayGif']), animate: getSettings(state).get('autoPlayGif'),
}); });
export default @connect(mapStateToProps) export default @connect(mapStateToProps)

View file

@ -2,9 +2,10 @@ import React from 'react';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import ImmutablePropTypes from 'react-immutable-proptypes'; import ImmutablePropTypes from 'react-immutable-proptypes';
import { getSettings } from 'gabsocial/actions/settings';
const mapStateToProps = state => ({ const mapStateToProps = state => ({
animate: state.getIn(['settings', 'autoPlayGif']), animate: getSettings(state).get('autoPlayGif'),
}); });
export default @connect(mapStateToProps) export default @connect(mapStateToProps)

View file

@ -11,13 +11,14 @@ import { displayMedia } from '../initial_state';
import { decode } from 'blurhash'; import { decode } from 'blurhash';
import { isPanoramic, isPortrait, isNonConformingRatio, minimumAspectRatio, maximumAspectRatio } from '../utils/media_aspect_ratio'; import { isPanoramic, isPortrait, isNonConformingRatio, minimumAspectRatio, maximumAspectRatio } from '../utils/media_aspect_ratio';
import { Map as ImmutableMap } from 'immutable'; import { Map as ImmutableMap } from 'immutable';
import { getSettings } from 'gabsocial/actions/settings';
const messages = defineMessages({ const messages = defineMessages({
toggle_visible: { id: 'media_gallery.toggle_visible', defaultMessage: 'Toggle visibility' }, toggle_visible: { id: 'media_gallery.toggle_visible', defaultMessage: 'Toggle visibility' },
}); });
const mapStateToProps = state => ({ const mapStateToProps = state => ({
autoPlayGif: state.getIn(['settings', 'autoPlayGif']), autoPlayGif: getSettings(state).get('autoPlayGif'),
}); });
@connect(mapStateToProps) @connect(mapStateToProps)

View file

@ -13,6 +13,7 @@ import {
} from '../actions/accounts'; } from '../actions/accounts';
import { openModal } from '../actions/modal'; import { openModal } from '../actions/modal';
import { initMuteModal } from '../actions/mutes'; import { initMuteModal } from '../actions/mutes';
import { getSettings } from '../actions/settings';
const messages = defineMessages({ const messages = defineMessages({
unfollowConfirm: { id: 'confirmations.unfollow.confirm', defaultMessage: 'Unfollow' }, unfollowConfirm: { id: 'confirmations.unfollow.confirm', defaultMessage: 'Unfollow' },
@ -32,7 +33,7 @@ const mapDispatchToProps = (dispatch, { intl }) => ({
onFollow(account) { onFollow(account) {
dispatch((_, getState) => { dispatch((_, getState) => {
const unfollowModal = getState().getIn(['settings', 'unfollowModal']); const unfollowModal = getSettings(getState()).get('unfollowModal');
if (account.getIn(['relationship', 'following']) || account.getIn(['relationship', 'requested'])) { if (account.getIn(['relationship', 'following']) || account.getIn(['relationship', 'requested'])) {
if (unfollowModal) { if (unfollowModal) {
dispatch(openModal('CONFIRM', { dispatch(openModal('CONFIRM', {

View file

@ -22,6 +22,7 @@ import { fetchInstance } from 'gabsocial/actions/instance';
import { fetchSoapboxConfig } from 'gabsocial/actions/soapbox'; import { fetchSoapboxConfig } from 'gabsocial/actions/soapbox';
import { fetchMe } from 'gabsocial/actions/me'; import { fetchMe } from 'gabsocial/actions/me';
import PublicLayout from 'gabsocial/features/public_layout'; import PublicLayout from 'gabsocial/features/public_layout';
import { getSettings } from 'gabsocial/actions/settings';
const { localeData, messages } = getLocale(); const { localeData, messages } = getLocale();
addLocaleData(localeData); addLocaleData(localeData);
@ -39,15 +40,16 @@ const mapStateToProps = (state) => {
const me = state.get('me'); const me = state.get('me');
const account = state.getIn(['accounts', me]); const account = state.getIn(['accounts', me]);
const showIntroduction = account ? state.getIn(['settings', 'introductionVersion'], 0) < INTRODUCTION_VERSION : false; const showIntroduction = account ? state.getIn(['settings', 'introductionVersion'], 0) < INTRODUCTION_VERSION : false;
const settings = getSettings(state);
return { return {
showIntroduction, showIntroduction,
me, me,
theme: state.getIn(['settings', 'theme']), theme: settings.get('theme'),
reduceMotion: state.getIn(['settings', 'reduceMotion']), reduceMotion: settings.get('reduceMotion'),
systemFont: state.getIn(['settings', 'systemFont']), systemFont: settings.get('systemFont'),
dyslexicFont: state.getIn(['settings', 'dyslexicFont']), dyslexicFont: settings.get('dyslexicFont'),
demetricator: state.getIn(['settings', 'demetricator']), demetricator: settings.get('demetricator'),
}; };
}; };

View file

@ -32,6 +32,7 @@ import {
createRemovedAccount, createRemovedAccount,
groupRemoveStatus, groupRemoveStatus,
} from '../actions/groups'; } from '../actions/groups';
import { getSettings } from '../actions/settings';
const messages = defineMessages({ const messages = defineMessages({
deleteConfirm: { id: 'confirmations.delete.confirm', defaultMessage: 'Delete' }, deleteConfirm: { id: 'confirmations.delete.confirm', defaultMessage: 'Delete' },
@ -81,7 +82,7 @@ const mapDispatchToProps = (dispatch, { intl }) => ({
onReblog(status, e) { onReblog(status, e) {
dispatch((_, getState) => { dispatch((_, getState) => {
const boostModal = getState().getIn(['settings', 'boostModal']); const boostModal = getSettings(getState()).get('boostModal');
if (e.shiftKey || !boostModal) { if (e.shiftKey || !boostModal) {
this.onModalReblog(status); this.onModalReblog(status);
} else { } else {
@ -115,7 +116,7 @@ const mapDispatchToProps = (dispatch, { intl }) => ({
onDelete(status, history, withRedraft = false) { onDelete(status, history, withRedraft = false) {
dispatch((_, getState) => { dispatch((_, getState) => {
const deleteModal = getState().getIn(['settings', 'deleteModal']); const deleteModal = getSettings(getState()).get('deleteModal');
if (!deleteModal) { if (!deleteModal) {
dispatch(deleteStatus(status.get('id'), history, withRedraft)); dispatch(deleteStatus(status.get('id'), history, withRedraft));
} else { } else {

View file

@ -15,6 +15,7 @@ import { NavLink } from 'react-router-dom';
import DropdownMenuContainer from 'gabsocial/containers/dropdown_menu_container'; import DropdownMenuContainer from 'gabsocial/containers/dropdown_menu_container';
import ProfileInfoPanel from '../../ui/components/profile_info_panel'; import ProfileInfoPanel from '../../ui/components/profile_info_panel';
import { debounce } from 'lodash'; import { debounce } from 'lodash';
import { getSettings } from 'gabsocial/actions/settings';
const messages = defineMessages({ const messages = defineMessages({
unfollow: { id: 'account.unfollow', defaultMessage: 'Unfollow' }, unfollow: { id: 'account.unfollow', defaultMessage: 'Unfollow' },
@ -52,7 +53,7 @@ const mapStateToProps = state => {
return { return {
me, me,
isStaff: isStaff(state.getIn(['accounts', me])), isStaff: isStaff(state.getIn(['accounts', me])),
autoPlayGif: state.getIn(['settings', 'autoPlayGif']), autoPlayGif: getSettings(state).get('autoPlayGif'),
}; };
}; };

View file

@ -8,9 +8,10 @@ import { displayMedia } from 'gabsocial/initial_state';
import classNames from 'classnames'; import classNames from 'classnames';
import { decode } from 'blurhash'; import { decode } from 'blurhash';
import { isIOS } from 'gabsocial/is_mobile'; import { isIOS } from 'gabsocial/is_mobile';
import { getSettings } from 'gabsocial/actions/settings';
const mapStateToProps = state => ({ const mapStateToProps = state => ({
autoPlayGif: state.getIn(['settings', 'autoPlayGif']), autoPlayGif: getSettings(state).get('autoPlayGif'),
}); });
export default @connect(mapStateToProps) export default @connect(mapStateToProps)

View file

@ -21,6 +21,7 @@ import { openModal } from '../../../actions/modal';
import { blockDomain, unblockDomain } from '../../../actions/domain_blocks'; import { blockDomain, unblockDomain } from '../../../actions/domain_blocks';
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl'; import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
import { List as ImmutableList } from 'immutable'; import { List as ImmutableList } from 'immutable';
import { getSettings } from 'gabsocial/actions/settings';
const messages = defineMessages({ const messages = defineMessages({
unfollowConfirm: { id: 'confirmations.unfollow.confirm', defaultMessage: 'Unfollow' }, unfollowConfirm: { id: 'confirmations.unfollow.confirm', defaultMessage: 'Unfollow' },
@ -44,7 +45,7 @@ const mapDispatchToProps = (dispatch, { intl }) => ({
onFollow(account) { onFollow(account) {
dispatch((_, getState) => { dispatch((_, getState) => {
const unfollowModal = getState().getIn(['settings', 'unfollowModal']); const unfollowModal = getSettings(getState()).get('unfollowModal');
if (account.getIn(['relationship', 'following']) || account.getIn(['relationship', 'requested'])) { if (account.getIn(['relationship', 'following']) || account.getIn(['relationship', 'requested'])) {
if (unfollowModal) { if (unfollowModal) {
dispatch(openModal('CONFIRM', { dispatch(openModal('CONFIRM', {

View file

@ -1,9 +1,9 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import ColumnSettings from '../components/column_settings'; import ColumnSettings from '../components/column_settings';
import { changeSetting } from '../../../actions/settings'; import { getSettings, changeSetting } from '../../../actions/settings';
const mapStateToProps = state => ({ const mapStateToProps = state => ({
settings: state.getIn(['settings', 'community']), settings: getSettings(state).get('community'),
}); });
const mapDispatchToProps = (dispatch) => { const mapDispatchToProps = (dispatch) => {

View file

@ -8,13 +8,14 @@ import ColumnSettingsContainer from './containers/column_settings_container';
import HomeColumnHeader from '../../components/home_column_header'; import HomeColumnHeader from '../../components/home_column_header';
import { expandCommunityTimeline } from '../../actions/timelines'; import { expandCommunityTimeline } from '../../actions/timelines';
import { connectCommunityStream } from '../../actions/streaming'; import { connectCommunityStream } from '../../actions/streaming';
import { getSettings } from 'gabsocial/actions/settings';
const messages = defineMessages({ const messages = defineMessages({
title: { id: 'column.community', defaultMessage: 'Local timeline' }, title: { id: 'column.community', defaultMessage: 'Local timeline' },
}); });
const mapStateToProps = state => { const mapStateToProps = state => {
const onlyMedia = state.getIn(['settings', 'community', 'other', 'onlyMedia']); const onlyMedia = getSettings(state).getIn(['community', 'other', 'onlyMedia']);
const timelineId = 'community'; const timelineId = 'community';

View file

@ -1,6 +1,6 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import EmojiPickerDropdown from '../components/emoji_picker_dropdown'; import EmojiPickerDropdown from '../components/emoji_picker_dropdown';
import { changeSetting } from '../../../actions/settings'; import { getSettings, changeSetting } from '../../../actions/settings';
import { createSelector } from 'reselect'; import { createSelector } from 'reselect';
import { Map as ImmutableMap } from 'immutable'; import { Map as ImmutableMap } from 'immutable';
import { useEmoji } from '../../../actions/emojis'; import { useEmoji } from '../../../actions/emojis';
@ -62,7 +62,7 @@ const getCustomEmojis = createSelector([
const mapStateToProps = state => ({ const mapStateToProps = state => ({
custom_emojis: getCustomEmojis(state), custom_emojis: getCustomEmojis(state),
skinTone: state.getIn(['settings', 'skinTone']), skinTone: getSettings(state).get('skinTone'),
frequentlyUsedEmojis: getFrequentlyUsedEmojis(state), frequentlyUsedEmojis: getFrequentlyUsedEmojis(state),
}); });

View file

@ -13,6 +13,7 @@ import spring from 'react-motion/lib/spring';
import SearchResultsContainer from './containers/search_results_container'; import SearchResultsContainer from './containers/search_results_container';
import { changeComposing } from '../../actions/compose'; import { changeComposing } from '../../actions/compose';
import Icon from 'gabsocial/components/icon'; import Icon from 'gabsocial/components/icon';
import { getSettings } from 'gabsocial/actions/settings';
const messages = defineMessages({ const messages = defineMessages({
start: { id: 'getting_started.heading', defaultMessage: 'Getting started' }, start: { id: 'getting_started.heading', defaultMessage: 'Getting started' },
@ -26,7 +27,7 @@ const messages = defineMessages({
}); });
const mapStateToProps = (state, ownProps) => ({ const mapStateToProps = (state, ownProps) => ({
columns: state.getIn(['settings', 'columns']), columns: getSettings(state).get('columns'),
showSearch: ownProps.multiColumn ? state.getIn(['search', 'submitted']) && !state.getIn(['search', 'hidden']) : ownProps.isSearchPage, showSearch: ownProps.multiColumn ? state.getIn(['search', 'submitted']) && !state.getIn(['search', 'hidden']) : ownProps.isSearchPage,
}); });

View file

@ -1,9 +1,13 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import ColumnSettings from '../components/column_settings'; import ColumnSettings from '../components/column_settings';
import { changeSetting, saveSettings } from '../../../actions/settings'; import {
getSettings,
changeSetting,
saveSettings,
} from '../../../actions/settings';
const mapStateToProps = state => ({ const mapStateToProps = state => ({
settings: state.getIn(['settings', 'home']), settings: getSettings(state).get('home'),
}); });
const mapDispatchToProps = dispatch => ({ const mapDispatchToProps = dispatch => ({

View file

@ -1,7 +1,7 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { defineMessages, injectIntl } from 'react-intl'; import { defineMessages, injectIntl } from 'react-intl';
import ColumnSettings from '../components/column_settings'; import ColumnSettings from '../components/column_settings';
import { changeSetting } from '../../../actions/settings'; import { getSettings, changeSetting } from '../../../actions/settings';
import { setFilter } from '../../../actions/notifications'; import { setFilter } from '../../../actions/notifications';
import { clearNotifications } from '../../../actions/notifications'; import { clearNotifications } from '../../../actions/notifications';
import { changeAlerts as changePushNotifications } from '../../../actions/push_notifications'; import { changeAlerts as changePushNotifications } from '../../../actions/push_notifications';
@ -13,7 +13,7 @@ const messages = defineMessages({
}); });
const mapStateToProps = state => ({ const mapStateToProps = state => ({
settings: state.getIn(['settings', 'notifications']), settings: getSettings(state).get('notifications'),
pushSettings: state.get('push_notifications'), pushSettings: state.get('push_notifications'),
}); });

View file

@ -1,11 +1,15 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import FilterBar from '../components/filter_bar'; import FilterBar from '../components/filter_bar';
import { setFilter } from '../../../actions/notifications'; import { setFilter } from '../../../actions/notifications';
import { getSettings } from 'gabsocial/actions/settings';
const makeMapStateToProps = state => ({ const makeMapStateToProps = state => {
selectedFilter: state.getIn(['settings', 'notifications', 'quickFilter', 'active']), const settings = getSettings(state);
advancedMode: state.getIn(['settings', 'notifications', 'quickFilter', 'advanced']), return {
}); selectedFilter: settings.getIn(['notifications', 'quickFilter', 'active']),
advancedMode: settings.getIn(['notifications', 'quickFilter', 'advanced']),
};
};
const mapDispatchToProps = (dispatch) => ({ const mapDispatchToProps = (dispatch) => ({
selectFilter(newActiveFilter) { selectFilter(newActiveFilter) {

View file

@ -13,6 +13,7 @@ import {
hideStatus, hideStatus,
revealStatus, revealStatus,
} from '../../../actions/statuses'; } from '../../../actions/statuses';
import { getSettings } from 'gabsocial/actions/settings';
const makeMapStateToProps = () => { const makeMapStateToProps = () => {
const getNotification = makeGetNotification(); const getNotification = makeGetNotification();
@ -40,7 +41,7 @@ const mapDispatchToProps = dispatch => ({
onReblog(status, e) { onReblog(status, e) {
dispatch((_, getState) => { dispatch((_, getState) => {
const boostModal = getState().getIn(['settings', 'boostModal']); const boostModal = getSettings(getState()).get('boostModal');
if (status.get('reblogged')) { if (status.get('reblogged')) {
dispatch(unreblog(status)); dispatch(unreblog(status));
} else { } else {

View file

@ -19,15 +19,16 @@ import { debounce } from 'lodash';
import ScrollableList from '../../components/scrollable_list'; import ScrollableList from '../../components/scrollable_list';
import LoadGap from '../../components/load_gap'; import LoadGap from '../../components/load_gap';
import TimelineQueueButtonHeader from '../../components/timeline_queue_button_header'; import TimelineQueueButtonHeader from '../../components/timeline_queue_button_header';
import { getSettings } from 'gabsocial/actions/settings';
const messages = defineMessages({ const messages = defineMessages({
title: { id: 'column.notifications', defaultMessage: 'Notifications' }, title: { id: 'column.notifications', defaultMessage: 'Notifications' },
}); });
const getNotifications = createSelector([ const getNotifications = createSelector([
state => state.getIn(['settings', 'notifications', 'quickFilter', 'show']), state => getSettings(state).getIn(['notifications', 'quickFilter', 'show']),
state => state.getIn(['settings', 'notifications', 'quickFilter', 'active']), state => getSettings(state).getIn(['notifications', 'quickFilter', 'active']),
state => ImmutableList(state.getIn(['settings', 'notifications', 'shows']).filter(item => !item).keys()), state => ImmutableList(getSettings(state).getIn(['notifications', 'shows']).filter(item => !item).keys()),
state => state.getIn(['notifications', 'items']), state => state.getIn(['notifications', 'items']),
], (showFilterBar, allowedType, excludedTypes, notifications) => { ], (showFilterBar, allowedType, excludedTypes, notifications) => {
if (!showFilterBar || allowedType === 'all') { if (!showFilterBar || allowedType === 'all') {
@ -40,7 +41,7 @@ const getNotifications = createSelector([
}); });
const mapStateToProps = state => ({ const mapStateToProps = state => ({
showFilterBar: state.getIn(['settings', 'notifications', 'quickFilter', 'show']), showFilterBar: getSettings(state).getIn(['notifications', 'quickFilter', 'show']),
notifications: getNotifications(state), notifications: getNotifications(state),
isLoading: state.getIn(['notifications', 'isLoading'], true), isLoading: state.getIn(['notifications', 'isLoading'], true),
isUnread: state.getIn(['notifications', 'unread']) > 0, isUnread: state.getIn(['notifications', 'unread']) > 0,

View file

@ -1,9 +1,9 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import ColumnSettings from '../components/column_settings'; import ColumnSettings from '../components/column_settings';
import { changeSetting } from '../../../actions/settings'; import { getSettings, changeSetting } from '../../../actions/settings';
const mapStateToProps = state => ({ const mapStateToProps = state => ({
settings: state.getIn(['settings', 'public']), settings: getSettings(state).get('public'),
}); });
const mapDispatchToProps = (dispatch) => { const mapDispatchToProps = (dispatch) => {

View file

@ -10,13 +10,14 @@ import ExplanationBox from '../ui/components/explanation_box';
import { expandPublicTimeline } from '../../actions/timelines'; import { expandPublicTimeline } from '../../actions/timelines';
import { connectPublicStream } from '../../actions/streaming'; import { connectPublicStream } from '../../actions/streaming';
import { Link } from 'react-router-dom'; import { Link } from 'react-router-dom';
import { getSettings } from 'gabsocial/actions/settings';
const messages = defineMessages({ const messages = defineMessages({
title: { id: 'column.public', defaultMessage: 'Federated timeline' }, title: { id: 'column.public', defaultMessage: 'Federated timeline' },
}); });
const mapStateToProps = state => { const mapStateToProps = state => {
const onlyMedia = state.getIn(['settings', 'public', 'other', 'onlyMedia']); const onlyMedia = getSettings(state).getIn(['public', 'other', 'onlyMedia']);
const timelineId = 'public'; const timelineId = 'public';

View file

@ -28,6 +28,7 @@ import { initReport } from '../../../actions/reports';
import { openModal } from '../../../actions/modal'; import { openModal } from '../../../actions/modal';
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl'; import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
import { showAlertForError } from '../../../actions/alerts'; import { showAlertForError } from '../../../actions/alerts';
import { getSettings } from 'gabsocial/actions/settings';
const messages = defineMessages({ const messages = defineMessages({
deleteConfirm: { id: 'confirmations.delete.confirm', defaultMessage: 'Delete' }, deleteConfirm: { id: 'confirmations.delete.confirm', defaultMessage: 'Delete' },
@ -74,7 +75,7 @@ const mapDispatchToProps = (dispatch, { intl }) => ({
onReblog(status, e) { onReblog(status, e) {
dispatch((_, getState) => { dispatch((_, getState) => {
const boostModal = getState().getIn(['settings', 'boostModal']); const boostModal = getSettings(getState()).get('boostModal');
if (status.get('reblogged')) { if (status.get('reblogged')) {
dispatch(unreblog(status)); dispatch(unreblog(status));
} else { } else {
@ -112,7 +113,7 @@ const mapDispatchToProps = (dispatch, { intl }) => ({
onDelete(status, history, withRedraft = false) { onDelete(status, history, withRedraft = false) {
dispatch((_, getState) => { dispatch((_, getState) => {
const deleteModal = getState().getIn(['settings', 'deleteModal']); const deleteModal = getSettings(getState()).get('deleteModal');
if (!deleteModal) { if (!deleteModal) {
dispatch(deleteStatus(status.get('id'), history, withRedraft)); dispatch(deleteStatus(status.get('id'), history, withRedraft));
} else { } else {

View file

@ -42,6 +42,7 @@ import { HotKeys } from 'react-hotkeys';
import { attachFullscreenListener, detachFullscreenListener, isFullscreen } from '../ui/util/fullscreen'; import { attachFullscreenListener, detachFullscreenListener, isFullscreen } from '../ui/util/fullscreen';
import { textForScreenReader, defaultMediaVisibility } from '../../components/status'; import { textForScreenReader, defaultMediaVisibility } from '../../components/status';
import Icon from 'gabsocial/components/icon'; import Icon from 'gabsocial/components/icon';
import { getSettings } from 'gabsocial/actions/settings';
const messages = defineMessages({ const messages = defineMessages({
deleteConfirm: { id: 'confirmations.delete.confirm', defaultMessage: 'Delete' }, deleteConfirm: { id: 'confirmations.delete.confirm', defaultMessage: 'Delete' },
@ -195,7 +196,7 @@ class Status extends ImmutablePureComponent {
handleReblogClick = (status, e) => { handleReblogClick = (status, e) => {
this.props.dispatch((_, getState) => { this.props.dispatch((_, getState) => {
const boostModal = getState().getIn(['settings', 'boostModal']); const boostModal = getSettings(getState()).get('boostModal');
if (status.get('reblogged')) { if (status.get('reblogged')) {
this.props.dispatch(unreblog(status)); this.props.dispatch(unreblog(status));
} else { } else {
@ -212,7 +213,7 @@ class Status extends ImmutablePureComponent {
const { dispatch, intl } = this.props; const { dispatch, intl } = this.props;
this.props.dispatch((_, getState) => { this.props.dispatch((_, getState) => {
const deleteModal = getState().getIn(['settings', 'deleteModal']); const deleteModal = getSettings(getState()).get('deleteModal');
if (!deleteModal) { if (!deleteModal) {
dispatch(deleteStatus(status.get('id'), history, withRedraft)); dispatch(deleteStatus(status.get('id'), history, withRedraft));
} else { } else {

View file

@ -9,6 +9,7 @@ import ImmutablePureComponent from 'react-immutable-pure-component';
import Avatar from 'gabsocial/components/avatar'; import Avatar from 'gabsocial/components/avatar';
import { shortNumberFormat } from 'gabsocial/utils/numbers'; import { shortNumberFormat } from 'gabsocial/utils/numbers';
import { acctFull } from 'gabsocial/utils/accounts'; import { acctFull } from 'gabsocial/utils/accounts';
import { getSettings } from 'gabsocial/actions/settings';
class UserPanel extends ImmutablePureComponent { class UserPanel extends ImmutablePureComponent {
@ -90,7 +91,7 @@ const mapStateToProps = state => {
return { return {
account: getAccount(state, me), account: getAccount(state, me),
autoPlayGif: state.getIn(['settings', 'autoPlayGif']), autoPlayGif: getSettings(state).get('autoPlayGif'),
}; };
}; };

View file

@ -1,8 +1,9 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import ColumnsArea from '../components/columns_area'; import ColumnsArea from '../components/columns_area';
import { getSettings } from 'gabsocial/actions/settings';
const mapStateToProps = state => ({ const mapStateToProps = state => ({
columns: state.getIn(['settings', 'columns']), columns: getSettings(state).get('columns'),
}); });
export default connect(mapStateToProps, null, null, { forwardRef: true })(ColumnsArea); export default connect(mapStateToProps, null, null, { forwardRef: true })(ColumnsArea);

View file

@ -9,7 +9,7 @@ import uuid from '../uuid';
// Default settings are in action/settings.js // Default settings are in action/settings.js
// //
// Settings should be accessed with `getSettings(getState).getIn(...)` // Settings should be accessed with `getSettings(getState()).getIn(...)`
// instead of directly from the state. // instead of directly from the state.
const initialState = ImmutableMap({ const initialState = ImmutableMap({
saved: true, saved: true,

View file

@ -16,5 +16,6 @@
}, },
"defaultSettings": { "defaultSettings": {
"autoPlayGif": false, "autoPlayGif": false,
"theme": "lime"
}, },
} }