diff --git a/CHANGELOG.md b/CHANGELOG.md index 97ace82fc..a774ec4b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] + +## [Unreleased patch] +### Fixed +- Composer: Forcing the scope to default after settings save. + ## [1.0.0] - 2020-06-15 ### Added - Emoji reactions. @@ -43,5 +49,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Initial beta release. +[Unreleased]: https://gitlab.com/soapbox-pub/soapbox-fe/-/compare/v1.0.0...develop +[Unreleased patch]: https://gitlab.com/soapbox-pub/soapbox-fe/-/compare/v1.0.0...stable/1.0.x [1.0.0]: https://gitlab.com/soapbox-pub/soapbox-fe/-/compare/v0.9.0...v1.0.0 [0.9.0]: https://gitlab.com/soapbox-pub/soapbox-fe/-/tags/v0.9.0 diff --git a/app/soapbox/reducers/__tests__/compose-test.js b/app/soapbox/reducers/__tests__/compose-test.js index 9270aa25f..a31bab857 100644 --- a/app/soapbox/reducers/__tests__/compose-test.js +++ b/app/soapbox/reducers/__tests__/compose-test.js @@ -1,7 +1,7 @@ import reducer from '../compose'; import { Map as ImmutableMap } from 'immutable'; import { COMPOSE_REPLY } from 'soapbox/actions/compose'; -import { ME_FETCH_SUCCESS } from 'soapbox/actions/me'; +import { ME_FETCH_SUCCESS, ME_PATCH_SUCCESS } from 'soapbox/actions/me'; import { SETTING_CHANGE } from 'soapbox/actions/settings'; describe('compose reducer', () => { @@ -115,4 +115,16 @@ describe('compose reducer', () => { privacy: 'unlisted', }); }); + + it('sets default scope on settings save (but retains current scope)', () => { + const state = ImmutableMap({ default_privacy: 'public', privacy: 'public' }); + const action = { + type: ME_PATCH_SUCCESS, + me: { pleroma: { settings_store: { soapbox_fe: { defaultPrivacy: 'unlisted' } } } }, + }; + expect(reducer(state, action).toJS()).toMatchObject({ + default_privacy: 'unlisted', + privacy: 'public', + }); + }); }); diff --git a/app/soapbox/reducers/compose.js b/app/soapbox/reducers/compose.js index 5ef9842ab..d9d554d47 100644 --- a/app/soapbox/reducers/compose.js +++ b/app/soapbox/reducers/compose.js @@ -39,7 +39,7 @@ import { import { TIMELINE_DELETE } from '../actions/timelines'; import { STORE_HYDRATE } from '../actions/store'; import { REDRAFT } from '../actions/statuses'; -import { ME_FETCH_SUCCESS } from '../actions/me'; +import { ME_FETCH_SUCCESS, ME_PATCH_SUCCESS } from '../actions/me'; import { SETTING_CHANGE, FE_NAME } from '../actions/settings'; import { Map as ImmutableMap, List as ImmutableList, OrderedSet as ImmutableOrderedSet, fromJS } from 'immutable'; import uuid from '../uuid'; @@ -199,6 +199,7 @@ const expandMentions = status => { }; export default function compose(state = initialState, action) { + let me, defaultPrivacy; switch(action.type) { case STORE_HYDRATE: return hydrate(state, action.state.get('compose')); @@ -361,10 +362,15 @@ export default function compose(state = initialState, action) { case COMPOSE_POLL_SETTINGS_CHANGE: return state.update('poll', poll => poll.set('expires_in', action.expiresIn).set('multiple', action.isMultiple)); case ME_FETCH_SUCCESS: - const me = fromJS(action.me); - const defaultPrivacy = me.getIn(['pleroma', 'settings_store', FE_NAME, 'defaultPrivacy']); + me = fromJS(action.me); + defaultPrivacy = me.getIn(['pleroma', 'settings_store', FE_NAME, 'defaultPrivacy']); if (!defaultPrivacy) return state; return state.set('default_privacy', defaultPrivacy).set('privacy', defaultPrivacy); + case ME_PATCH_SUCCESS: + me = fromJS(action.me); + defaultPrivacy = me.getIn(['pleroma', 'settings_store', FE_NAME, 'defaultPrivacy']); + if (!defaultPrivacy) return state; + return state.set('default_privacy', defaultPrivacy); case SETTING_CHANGE: const pathString = action.path.join(','); if (pathString === 'defaultPrivacy')