From a60c47bb19491ed6dfca4efcba044b597880d41f Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Tue, 28 Apr 2020 13:49:39 -0500 Subject: [PATCH] Don't persist default settings Only persist settings if they've been overridden by the user --- app/gabsocial/actions/compose.js | 3 ++- app/gabsocial/actions/importer/index.js | 3 ++- app/gabsocial/actions/notifications.js | 14 +++++++------- app/gabsocial/actions/settings.js | 6 ++---- app/gabsocial/components/avatar.js | 3 ++- app/gabsocial/components/avatar_composite.js | 3 ++- app/gabsocial/components/avatar_overlay.js | 3 ++- app/gabsocial/components/media_gallery.js | 3 ++- app/gabsocial/containers/account_container.js | 3 ++- app/gabsocial/containers/gabsocial.js | 12 +++++++----- app/gabsocial/containers/status_container.js | 5 +++-- .../features/account/components/header.js | 3 ++- .../account_gallery/components/media_item.js | 3 ++- .../containers/header_container.js | 3 ++- .../containers/column_settings_container.js | 4 ++-- app/gabsocial/features/community_timeline/index.js | 3 ++- .../containers/emoji_picker_dropdown_container.js | 4 ++-- app/gabsocial/features/compose/index.js | 3 ++- .../containers/column_settings_container.js | 8 ++++++-- .../containers/column_settings_container.js | 4 ++-- .../containers/filter_bar_container.js | 12 ++++++++---- .../containers/notification_container.js | 3 ++- app/gabsocial/features/notifications/index.js | 9 +++++---- .../containers/column_settings_container.js | 4 ++-- app/gabsocial/features/public_timeline/index.js | 3 ++- .../status/containers/detailed_status_container.js | 5 +++-- app/gabsocial/features/status/index.js | 5 +++-- app/gabsocial/features/ui/components/user_panel.js | 3 ++- .../ui/containers/columns_area_container.js | 3 ++- app/gabsocial/reducers/settings.js | 2 +- static/instance/soapbox.example.json | 1 + 31 files changed, 86 insertions(+), 57 deletions(-) diff --git a/app/gabsocial/actions/compose.js b/app/gabsocial/actions/compose.js index 45dab4bfe..5a9de9051 100644 --- a/app/gabsocial/actions/compose.js +++ b/app/gabsocial/actions/compose.js @@ -11,6 +11,7 @@ import { showAlertForError } from './alerts'; import { showAlert } from './alerts'; import { defineMessages } from 'react-intl'; import { openModal, closeModal } from './modal'; +import { getSettings } from './settings'; 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')) { 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(updateTimeline(timelineId, { ...response.data })); } diff --git a/app/gabsocial/actions/importer/index.js b/app/gabsocial/actions/importer/index.js index db808d3e2..aaf603608 100644 --- a/app/gabsocial/actions/importer/index.js +++ b/app/gabsocial/actions/importer/index.js @@ -1,3 +1,4 @@ +import { getSettings } from '../settings'; import { normalizeAccount, normalizeStatus, normalizePoll } from './normalizer'; export const ACCOUNT_IMPORT = 'ACCOUNT_IMPORT'; @@ -65,7 +66,7 @@ export function importFetchedStatuses(statuses) { function processStatus(status) { 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(accounts, status.account); diff --git a/app/gabsocial/actions/notifications.js b/app/gabsocial/actions/notifications.js index 09fb7ebeb..56769210b 100644 --- a/app/gabsocial/actions/notifications.js +++ b/app/gabsocial/actions/notifications.js @@ -8,7 +8,7 @@ import { importFetchedStatus, importFetchedStatuses, } from './importer'; -import { saveSettings } from './settings'; +import { getSettings, saveSettings } from './settings'; import { defineMessages } from 'react-intl'; import { List as ImmutableList } from 'immutable'; import { unescapeHTML } from '../utils/html'; @@ -50,7 +50,7 @@ const fetchRelatedRelationships = (dispatch, notifications) => { export function updateNotifications(notification, intlMessages, intlLocale) { 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) { dispatch(importFetchedAccount(notification.account)); @@ -71,9 +71,9 @@ export function updateNotifications(notification, intlMessages, intlLocale) { export function updateNotificationsQueue(notification, intlMessages, intlLocale, curPath) { 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 playSound = getState().getIn(['settings', 'notifications', 'sounds', notification.type], true); + const playSound = getSettings(getState()).getIn(['notifications', 'sounds', notification.type], true); 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 allTypes = ImmutableList(['follow', 'favourite', 'reblog', 'mention', 'poll']); @@ -153,7 +153,7 @@ export function expandNotifications({ maxId } = {}, done = noOp) { return (dispatch, getState) => { 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 isLoadingMore = !!maxId; @@ -165,7 +165,7 @@ export function expandNotifications({ maxId } = {}, done = noOp) { const params = { max_id: maxId, exclude_types: activeFilter === 'all' - ? excludeTypesFromSettings(getState()) + ? excludeTypesFromSettings(getState) : excludeTypesFromFilter(activeFilter), }; diff --git a/app/gabsocial/actions/settings.js b/app/gabsocial/actions/settings.js index 768625b5e..775756f84 100644 --- a/app/gabsocial/actions/settings.js +++ b/app/gabsocial/actions/settings.js @@ -98,9 +98,7 @@ const defaultSettings = ImmutableMap({ }), }); - -export function getSettings(getState) { - const state = getState(); +export function getSettings(state) { const soapboxSettings = state.getIn(['soapbox', 'defaultSettings']); return defaultSettings .mergeDeep(soapboxSettings) @@ -122,7 +120,7 @@ export function changeSetting(path, value) { const debouncedSave = debounce((dispatch, getState) => { const state = getState(); 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(); diff --git a/app/gabsocial/components/avatar.js b/app/gabsocial/components/avatar.js index c3c8bb49f..786bef61d 100644 --- a/app/gabsocial/components/avatar.js +++ b/app/gabsocial/components/avatar.js @@ -2,9 +2,10 @@ import React from 'react'; import { connect } from 'react-redux'; import PropTypes from 'prop-types'; import ImmutablePropTypes from 'react-immutable-proptypes'; +import { getSettings } from 'gabsocial/actions/settings'; const mapStateToProps = state => ({ - animate: state.getIn(['settings', 'autoPlayGif']), + animate: getSettings(state).get('autoPlayGif'), }); export default @connect(mapStateToProps) diff --git a/app/gabsocial/components/avatar_composite.js b/app/gabsocial/components/avatar_composite.js index a483cfed0..6e0045704 100644 --- a/app/gabsocial/components/avatar_composite.js +++ b/app/gabsocial/components/avatar_composite.js @@ -2,9 +2,10 @@ import React from 'react'; import { connect } from 'react-redux'; import PropTypes from 'prop-types'; import ImmutablePropTypes from 'react-immutable-proptypes'; +import { getSettings } from 'gabsocial/actions/settings'; const mapStateToProps = state => ({ - animate: state.getIn(['settings', 'autoPlayGif']), + animate: getSettings(state).get('autoPlayGif'), }); export default @connect(mapStateToProps) diff --git a/app/gabsocial/components/avatar_overlay.js b/app/gabsocial/components/avatar_overlay.js index 7c93cad1a..13144df40 100644 --- a/app/gabsocial/components/avatar_overlay.js +++ b/app/gabsocial/components/avatar_overlay.js @@ -2,9 +2,10 @@ import React from 'react'; import { connect } from 'react-redux'; import PropTypes from 'prop-types'; import ImmutablePropTypes from 'react-immutable-proptypes'; +import { getSettings } from 'gabsocial/actions/settings'; const mapStateToProps = state => ({ - animate: state.getIn(['settings', 'autoPlayGif']), + animate: getSettings(state).get('autoPlayGif'), }); export default @connect(mapStateToProps) diff --git a/app/gabsocial/components/media_gallery.js b/app/gabsocial/components/media_gallery.js index d9d9e976a..2b35b81db 100644 --- a/app/gabsocial/components/media_gallery.js +++ b/app/gabsocial/components/media_gallery.js @@ -11,13 +11,14 @@ import { displayMedia } from '../initial_state'; import { decode } from 'blurhash'; import { isPanoramic, isPortrait, isNonConformingRatio, minimumAspectRatio, maximumAspectRatio } from '../utils/media_aspect_ratio'; import { Map as ImmutableMap } from 'immutable'; +import { getSettings } from 'gabsocial/actions/settings'; const messages = defineMessages({ toggle_visible: { id: 'media_gallery.toggle_visible', defaultMessage: 'Toggle visibility' }, }); const mapStateToProps = state => ({ - autoPlayGif: state.getIn(['settings', 'autoPlayGif']), + autoPlayGif: getSettings(state).get('autoPlayGif'), }); @connect(mapStateToProps) diff --git a/app/gabsocial/containers/account_container.js b/app/gabsocial/containers/account_container.js index e6d20b804..8e1f067de 100644 --- a/app/gabsocial/containers/account_container.js +++ b/app/gabsocial/containers/account_container.js @@ -13,6 +13,7 @@ import { } from '../actions/accounts'; import { openModal } from '../actions/modal'; import { initMuteModal } from '../actions/mutes'; +import { getSettings } from '../actions/settings'; const messages = defineMessages({ unfollowConfirm: { id: 'confirmations.unfollow.confirm', defaultMessage: 'Unfollow' }, @@ -32,7 +33,7 @@ const mapDispatchToProps = (dispatch, { intl }) => ({ onFollow(account) { dispatch((_, getState) => { - const unfollowModal = getState().getIn(['settings', 'unfollowModal']); + const unfollowModal = getSettings(getState()).get('unfollowModal'); if (account.getIn(['relationship', 'following']) || account.getIn(['relationship', 'requested'])) { if (unfollowModal) { dispatch(openModal('CONFIRM', { diff --git a/app/gabsocial/containers/gabsocial.js b/app/gabsocial/containers/gabsocial.js index 4319d10e4..7c383fe7f 100644 --- a/app/gabsocial/containers/gabsocial.js +++ b/app/gabsocial/containers/gabsocial.js @@ -22,6 +22,7 @@ import { fetchInstance } from 'gabsocial/actions/instance'; import { fetchSoapboxConfig } from 'gabsocial/actions/soapbox'; import { fetchMe } from 'gabsocial/actions/me'; import PublicLayout from 'gabsocial/features/public_layout'; +import { getSettings } from 'gabsocial/actions/settings'; const { localeData, messages } = getLocale(); addLocaleData(localeData); @@ -39,15 +40,16 @@ const mapStateToProps = (state) => { const me = state.get('me'); const account = state.getIn(['accounts', me]); const showIntroduction = account ? state.getIn(['settings', 'introductionVersion'], 0) < INTRODUCTION_VERSION : false; + const settings = getSettings(state); return { showIntroduction, me, - theme: state.getIn(['settings', 'theme']), - reduceMotion: state.getIn(['settings', 'reduceMotion']), - systemFont: state.getIn(['settings', 'systemFont']), - dyslexicFont: state.getIn(['settings', 'dyslexicFont']), - demetricator: state.getIn(['settings', 'demetricator']), + theme: settings.get('theme'), + reduceMotion: settings.get('reduceMotion'), + systemFont: settings.get('systemFont'), + dyslexicFont: settings.get('dyslexicFont'), + demetricator: settings.get('demetricator'), }; }; diff --git a/app/gabsocial/containers/status_container.js b/app/gabsocial/containers/status_container.js index 264380be8..fae063ce4 100644 --- a/app/gabsocial/containers/status_container.js +++ b/app/gabsocial/containers/status_container.js @@ -32,6 +32,7 @@ import { createRemovedAccount, groupRemoveStatus, } from '../actions/groups'; +import { getSettings } from '../actions/settings'; const messages = defineMessages({ deleteConfirm: { id: 'confirmations.delete.confirm', defaultMessage: 'Delete' }, @@ -81,7 +82,7 @@ const mapDispatchToProps = (dispatch, { intl }) => ({ onReblog(status, e) { dispatch((_, getState) => { - const boostModal = getState().getIn(['settings', 'boostModal']); + const boostModal = getSettings(getState()).get('boostModal'); if (e.shiftKey || !boostModal) { this.onModalReblog(status); } else { @@ -115,7 +116,7 @@ const mapDispatchToProps = (dispatch, { intl }) => ({ onDelete(status, history, withRedraft = false) { dispatch((_, getState) => { - const deleteModal = getState().getIn(['settings', 'deleteModal']); + const deleteModal = getSettings(getState()).get('deleteModal'); if (!deleteModal) { dispatch(deleteStatus(status.get('id'), history, withRedraft)); } else { diff --git a/app/gabsocial/features/account/components/header.js b/app/gabsocial/features/account/components/header.js index 178c00932..c640e628e 100644 --- a/app/gabsocial/features/account/components/header.js +++ b/app/gabsocial/features/account/components/header.js @@ -15,6 +15,7 @@ import { NavLink } from 'react-router-dom'; import DropdownMenuContainer from 'gabsocial/containers/dropdown_menu_container'; import ProfileInfoPanel from '../../ui/components/profile_info_panel'; import { debounce } from 'lodash'; +import { getSettings } from 'gabsocial/actions/settings'; const messages = defineMessages({ unfollow: { id: 'account.unfollow', defaultMessage: 'Unfollow' }, @@ -52,7 +53,7 @@ const mapStateToProps = state => { return { me, isStaff: isStaff(state.getIn(['accounts', me])), - autoPlayGif: state.getIn(['settings', 'autoPlayGif']), + autoPlayGif: getSettings(state).get('autoPlayGif'), }; }; diff --git a/app/gabsocial/features/account_gallery/components/media_item.js b/app/gabsocial/features/account_gallery/components/media_item.js index eda1ebe33..7667073c6 100644 --- a/app/gabsocial/features/account_gallery/components/media_item.js +++ b/app/gabsocial/features/account_gallery/components/media_item.js @@ -8,9 +8,10 @@ import { displayMedia } from 'gabsocial/initial_state'; import classNames from 'classnames'; import { decode } from 'blurhash'; import { isIOS } from 'gabsocial/is_mobile'; +import { getSettings } from 'gabsocial/actions/settings'; const mapStateToProps = state => ({ - autoPlayGif: state.getIn(['settings', 'autoPlayGif']), + autoPlayGif: getSettings(state).get('autoPlayGif'), }); export default @connect(mapStateToProps) diff --git a/app/gabsocial/features/account_timeline/containers/header_container.js b/app/gabsocial/features/account_timeline/containers/header_container.js index d7b2ccc24..64491d26c 100644 --- a/app/gabsocial/features/account_timeline/containers/header_container.js +++ b/app/gabsocial/features/account_timeline/containers/header_container.js @@ -21,6 +21,7 @@ import { openModal } from '../../../actions/modal'; import { blockDomain, unblockDomain } from '../../../actions/domain_blocks'; import { defineMessages, injectIntl, FormattedMessage } from 'react-intl'; import { List as ImmutableList } from 'immutable'; +import { getSettings } from 'gabsocial/actions/settings'; const messages = defineMessages({ unfollowConfirm: { id: 'confirmations.unfollow.confirm', defaultMessage: 'Unfollow' }, @@ -44,7 +45,7 @@ const mapDispatchToProps = (dispatch, { intl }) => ({ onFollow(account) { dispatch((_, getState) => { - const unfollowModal = getState().getIn(['settings', 'unfollowModal']); + const unfollowModal = getSettings(getState()).get('unfollowModal'); if (account.getIn(['relationship', 'following']) || account.getIn(['relationship', 'requested'])) { if (unfollowModal) { dispatch(openModal('CONFIRM', { diff --git a/app/gabsocial/features/community_timeline/containers/column_settings_container.js b/app/gabsocial/features/community_timeline/containers/column_settings_container.js index d625f6167..1278eac33 100644 --- a/app/gabsocial/features/community_timeline/containers/column_settings_container.js +++ b/app/gabsocial/features/community_timeline/containers/column_settings_container.js @@ -1,9 +1,9 @@ import { connect } from 'react-redux'; import ColumnSettings from '../components/column_settings'; -import { changeSetting } from '../../../actions/settings'; +import { getSettings, changeSetting } from '../../../actions/settings'; const mapStateToProps = state => ({ - settings: state.getIn(['settings', 'community']), + settings: getSettings(state).get('community'), }); const mapDispatchToProps = (dispatch) => { diff --git a/app/gabsocial/features/community_timeline/index.js b/app/gabsocial/features/community_timeline/index.js index 78a95cca3..35dae7056 100644 --- a/app/gabsocial/features/community_timeline/index.js +++ b/app/gabsocial/features/community_timeline/index.js @@ -8,13 +8,14 @@ import ColumnSettingsContainer from './containers/column_settings_container'; import HomeColumnHeader from '../../components/home_column_header'; import { expandCommunityTimeline } from '../../actions/timelines'; import { connectCommunityStream } from '../../actions/streaming'; +import { getSettings } from 'gabsocial/actions/settings'; const messages = defineMessages({ title: { id: 'column.community', defaultMessage: 'Local timeline' }, }); const mapStateToProps = state => { - const onlyMedia = state.getIn(['settings', 'community', 'other', 'onlyMedia']); + const onlyMedia = getSettings(state).getIn(['community', 'other', 'onlyMedia']); const timelineId = 'community'; diff --git a/app/gabsocial/features/compose/containers/emoji_picker_dropdown_container.js b/app/gabsocial/features/compose/containers/emoji_picker_dropdown_container.js index 754c29876..d9dd60bbc 100644 --- a/app/gabsocial/features/compose/containers/emoji_picker_dropdown_container.js +++ b/app/gabsocial/features/compose/containers/emoji_picker_dropdown_container.js @@ -1,6 +1,6 @@ import { connect } from 'react-redux'; import EmojiPickerDropdown from '../components/emoji_picker_dropdown'; -import { changeSetting } from '../../../actions/settings'; +import { getSettings, changeSetting } from '../../../actions/settings'; import { createSelector } from 'reselect'; import { Map as ImmutableMap } from 'immutable'; import { useEmoji } from '../../../actions/emojis'; @@ -62,7 +62,7 @@ const getCustomEmojis = createSelector([ const mapStateToProps = state => ({ custom_emojis: getCustomEmojis(state), - skinTone: state.getIn(['settings', 'skinTone']), + skinTone: getSettings(state).get('skinTone'), frequentlyUsedEmojis: getFrequentlyUsedEmojis(state), }); diff --git a/app/gabsocial/features/compose/index.js b/app/gabsocial/features/compose/index.js index 0c4f85682..e7b7cfa06 100644 --- a/app/gabsocial/features/compose/index.js +++ b/app/gabsocial/features/compose/index.js @@ -13,6 +13,7 @@ import spring from 'react-motion/lib/spring'; import SearchResultsContainer from './containers/search_results_container'; import { changeComposing } from '../../actions/compose'; import Icon from 'gabsocial/components/icon'; +import { getSettings } from 'gabsocial/actions/settings'; const messages = defineMessages({ start: { id: 'getting_started.heading', defaultMessage: 'Getting started' }, @@ -26,7 +27,7 @@ const messages = defineMessages({ }); 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, }); diff --git a/app/gabsocial/features/home_timeline/containers/column_settings_container.js b/app/gabsocial/features/home_timeline/containers/column_settings_container.js index bb0512d44..69217a54c 100644 --- a/app/gabsocial/features/home_timeline/containers/column_settings_container.js +++ b/app/gabsocial/features/home_timeline/containers/column_settings_container.js @@ -1,9 +1,13 @@ import { connect } from 'react-redux'; import ColumnSettings from '../components/column_settings'; -import { changeSetting, saveSettings } from '../../../actions/settings'; +import { + getSettings, + changeSetting, + saveSettings, +} from '../../../actions/settings'; const mapStateToProps = state => ({ - settings: state.getIn(['settings', 'home']), + settings: getSettings(state).get('home'), }); const mapDispatchToProps = dispatch => ({ diff --git a/app/gabsocial/features/notifications/containers/column_settings_container.js b/app/gabsocial/features/notifications/containers/column_settings_container.js index 072cb9090..6b1b24026 100644 --- a/app/gabsocial/features/notifications/containers/column_settings_container.js +++ b/app/gabsocial/features/notifications/containers/column_settings_container.js @@ -1,7 +1,7 @@ import { connect } from 'react-redux'; import { defineMessages, injectIntl } from 'react-intl'; import ColumnSettings from '../components/column_settings'; -import { changeSetting } from '../../../actions/settings'; +import { getSettings, changeSetting } from '../../../actions/settings'; import { setFilter } from '../../../actions/notifications'; import { clearNotifications } from '../../../actions/notifications'; import { changeAlerts as changePushNotifications } from '../../../actions/push_notifications'; @@ -13,7 +13,7 @@ const messages = defineMessages({ }); const mapStateToProps = state => ({ - settings: state.getIn(['settings', 'notifications']), + settings: getSettings(state).get('notifications'), pushSettings: state.get('push_notifications'), }); diff --git a/app/gabsocial/features/notifications/containers/filter_bar_container.js b/app/gabsocial/features/notifications/containers/filter_bar_container.js index 297067dd6..c35ee004e 100644 --- a/app/gabsocial/features/notifications/containers/filter_bar_container.js +++ b/app/gabsocial/features/notifications/containers/filter_bar_container.js @@ -1,11 +1,15 @@ import { connect } from 'react-redux'; import FilterBar from '../components/filter_bar'; import { setFilter } from '../../../actions/notifications'; +import { getSettings } from 'gabsocial/actions/settings'; -const makeMapStateToProps = state => ({ - selectedFilter: state.getIn(['settings', 'notifications', 'quickFilter', 'active']), - advancedMode: state.getIn(['settings', 'notifications', 'quickFilter', 'advanced']), -}); +const makeMapStateToProps = state => { + const settings = getSettings(state); + return { + selectedFilter: settings.getIn(['notifications', 'quickFilter', 'active']), + advancedMode: settings.getIn(['notifications', 'quickFilter', 'advanced']), + }; +}; const mapDispatchToProps = (dispatch) => ({ selectFilter(newActiveFilter) { diff --git a/app/gabsocial/features/notifications/containers/notification_container.js b/app/gabsocial/features/notifications/containers/notification_container.js index f2695e6d7..d1003ec18 100644 --- a/app/gabsocial/features/notifications/containers/notification_container.js +++ b/app/gabsocial/features/notifications/containers/notification_container.js @@ -13,6 +13,7 @@ import { hideStatus, revealStatus, } from '../../../actions/statuses'; +import { getSettings } from 'gabsocial/actions/settings'; const makeMapStateToProps = () => { const getNotification = makeGetNotification(); @@ -40,7 +41,7 @@ const mapDispatchToProps = dispatch => ({ onReblog(status, e) { dispatch((_, getState) => { - const boostModal = getState().getIn(['settings', 'boostModal']); + const boostModal = getSettings(getState()).get('boostModal'); if (status.get('reblogged')) { dispatch(unreblog(status)); } else { diff --git a/app/gabsocial/features/notifications/index.js b/app/gabsocial/features/notifications/index.js index d0eeafc0d..607708f2f 100644 --- a/app/gabsocial/features/notifications/index.js +++ b/app/gabsocial/features/notifications/index.js @@ -19,15 +19,16 @@ import { debounce } from 'lodash'; import ScrollableList from '../../components/scrollable_list'; import LoadGap from '../../components/load_gap'; import TimelineQueueButtonHeader from '../../components/timeline_queue_button_header'; +import { getSettings } from 'gabsocial/actions/settings'; const messages = defineMessages({ title: { id: 'column.notifications', defaultMessage: 'Notifications' }, }); const getNotifications = createSelector([ - state => state.getIn(['settings', 'notifications', 'quickFilter', 'show']), - state => state.getIn(['settings', 'notifications', 'quickFilter', 'active']), - state => ImmutableList(state.getIn(['settings', 'notifications', 'shows']).filter(item => !item).keys()), + state => getSettings(state).getIn(['notifications', 'quickFilter', 'show']), + state => getSettings(state).getIn(['notifications', 'quickFilter', 'active']), + state => ImmutableList(getSettings(state).getIn(['notifications', 'shows']).filter(item => !item).keys()), state => state.getIn(['notifications', 'items']), ], (showFilterBar, allowedType, excludedTypes, notifications) => { if (!showFilterBar || allowedType === 'all') { @@ -40,7 +41,7 @@ const getNotifications = createSelector([ }); const mapStateToProps = state => ({ - showFilterBar: state.getIn(['settings', 'notifications', 'quickFilter', 'show']), + showFilterBar: getSettings(state).getIn(['notifications', 'quickFilter', 'show']), notifications: getNotifications(state), isLoading: state.getIn(['notifications', 'isLoading'], true), isUnread: state.getIn(['notifications', 'unread']) > 0, diff --git a/app/gabsocial/features/public_timeline/containers/column_settings_container.js b/app/gabsocial/features/public_timeline/containers/column_settings_container.js index 93ef2c4df..ac001bcab 100644 --- a/app/gabsocial/features/public_timeline/containers/column_settings_container.js +++ b/app/gabsocial/features/public_timeline/containers/column_settings_container.js @@ -1,9 +1,9 @@ import { connect } from 'react-redux'; import ColumnSettings from '../components/column_settings'; -import { changeSetting } from '../../../actions/settings'; +import { getSettings, changeSetting } from '../../../actions/settings'; const mapStateToProps = state => ({ - settings: state.getIn(['settings', 'public']), + settings: getSettings(state).get('public'), }); const mapDispatchToProps = (dispatch) => { diff --git a/app/gabsocial/features/public_timeline/index.js b/app/gabsocial/features/public_timeline/index.js index 79e5d01ce..68ce0878a 100644 --- a/app/gabsocial/features/public_timeline/index.js +++ b/app/gabsocial/features/public_timeline/index.js @@ -10,13 +10,14 @@ import ExplanationBox from '../ui/components/explanation_box'; import { expandPublicTimeline } from '../../actions/timelines'; import { connectPublicStream } from '../../actions/streaming'; import { Link } from 'react-router-dom'; +import { getSettings } from 'gabsocial/actions/settings'; const messages = defineMessages({ title: { id: 'column.public', defaultMessage: 'Federated timeline' }, }); const mapStateToProps = state => { - const onlyMedia = state.getIn(['settings', 'public', 'other', 'onlyMedia']); + const onlyMedia = getSettings(state).getIn(['public', 'other', 'onlyMedia']); const timelineId = 'public'; diff --git a/app/gabsocial/features/status/containers/detailed_status_container.js b/app/gabsocial/features/status/containers/detailed_status_container.js index 684614532..572eca926 100644 --- a/app/gabsocial/features/status/containers/detailed_status_container.js +++ b/app/gabsocial/features/status/containers/detailed_status_container.js @@ -28,6 +28,7 @@ import { initReport } from '../../../actions/reports'; import { openModal } from '../../../actions/modal'; import { defineMessages, injectIntl, FormattedMessage } from 'react-intl'; import { showAlertForError } from '../../../actions/alerts'; +import { getSettings } from 'gabsocial/actions/settings'; const messages = defineMessages({ deleteConfirm: { id: 'confirmations.delete.confirm', defaultMessage: 'Delete' }, @@ -74,7 +75,7 @@ const mapDispatchToProps = (dispatch, { intl }) => ({ onReblog(status, e) { dispatch((_, getState) => { - const boostModal = getState().getIn(['settings', 'boostModal']); + const boostModal = getSettings(getState()).get('boostModal'); if (status.get('reblogged')) { dispatch(unreblog(status)); } else { @@ -112,7 +113,7 @@ const mapDispatchToProps = (dispatch, { intl }) => ({ onDelete(status, history, withRedraft = false) { dispatch((_, getState) => { - const deleteModal = getState().getIn(['settings', 'deleteModal']); + const deleteModal = getSettings(getState()).get('deleteModal'); if (!deleteModal) { dispatch(deleteStatus(status.get('id'), history, withRedraft)); } else { diff --git a/app/gabsocial/features/status/index.js b/app/gabsocial/features/status/index.js index ce431c5b4..a5f5ec66c 100644 --- a/app/gabsocial/features/status/index.js +++ b/app/gabsocial/features/status/index.js @@ -42,6 +42,7 @@ import { HotKeys } from 'react-hotkeys'; import { attachFullscreenListener, detachFullscreenListener, isFullscreen } from '../ui/util/fullscreen'; import { textForScreenReader, defaultMediaVisibility } from '../../components/status'; import Icon from 'gabsocial/components/icon'; +import { getSettings } from 'gabsocial/actions/settings'; const messages = defineMessages({ deleteConfirm: { id: 'confirmations.delete.confirm', defaultMessage: 'Delete' }, @@ -195,7 +196,7 @@ class Status extends ImmutablePureComponent { handleReblogClick = (status, e) => { this.props.dispatch((_, getState) => { - const boostModal = getState().getIn(['settings', 'boostModal']); + const boostModal = getSettings(getState()).get('boostModal'); if (status.get('reblogged')) { this.props.dispatch(unreblog(status)); } else { @@ -212,7 +213,7 @@ class Status extends ImmutablePureComponent { const { dispatch, intl } = this.props; this.props.dispatch((_, getState) => { - const deleteModal = getState().getIn(['settings', 'deleteModal']); + const deleteModal = getSettings(getState()).get('deleteModal'); if (!deleteModal) { dispatch(deleteStatus(status.get('id'), history, withRedraft)); } else { diff --git a/app/gabsocial/features/ui/components/user_panel.js b/app/gabsocial/features/ui/components/user_panel.js index 407952386..8b86107ad 100644 --- a/app/gabsocial/features/ui/components/user_panel.js +++ b/app/gabsocial/features/ui/components/user_panel.js @@ -9,6 +9,7 @@ import ImmutablePureComponent from 'react-immutable-pure-component'; import Avatar from 'gabsocial/components/avatar'; import { shortNumberFormat } from 'gabsocial/utils/numbers'; import { acctFull } from 'gabsocial/utils/accounts'; +import { getSettings } from 'gabsocial/actions/settings'; class UserPanel extends ImmutablePureComponent { @@ -90,7 +91,7 @@ const mapStateToProps = state => { return { account: getAccount(state, me), - autoPlayGif: state.getIn(['settings', 'autoPlayGif']), + autoPlayGif: getSettings(state).get('autoPlayGif'), }; }; diff --git a/app/gabsocial/features/ui/containers/columns_area_container.js b/app/gabsocial/features/ui/containers/columns_area_container.js index 4e26f3017..5a9922b4c 100644 --- a/app/gabsocial/features/ui/containers/columns_area_container.js +++ b/app/gabsocial/features/ui/containers/columns_area_container.js @@ -1,8 +1,9 @@ import { connect } from 'react-redux'; import ColumnsArea from '../components/columns_area'; +import { getSettings } from 'gabsocial/actions/settings'; const mapStateToProps = state => ({ - columns: state.getIn(['settings', 'columns']), + columns: getSettings(state).get('columns'), }); export default connect(mapStateToProps, null, null, { forwardRef: true })(ColumnsArea); diff --git a/app/gabsocial/reducers/settings.js b/app/gabsocial/reducers/settings.js index 1eec3151d..65b785091 100644 --- a/app/gabsocial/reducers/settings.js +++ b/app/gabsocial/reducers/settings.js @@ -9,7 +9,7 @@ import uuid from '../uuid'; // 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. const initialState = ImmutableMap({ saved: true, diff --git a/static/instance/soapbox.example.json b/static/instance/soapbox.example.json index 95122252d..5b4c3fca0 100644 --- a/static/instance/soapbox.example.json +++ b/static/instance/soapbox.example.json @@ -16,5 +16,6 @@ }, "defaultSettings": { "autoPlayGif": false, + "theme": "lime" }, }