Composer: Don't force scope change after settings save, fixes #122

stable/1.0.x^2
Alex Gleason 2020-06-16 17:55:41 -05:00
rodzic 4720ccc57d
commit 7fbcf3ca57
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
3 zmienionych plików z 30 dodań i 4 usunięć

Wyświetl plik

@ -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

Wyświetl plik

@ -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',
});
});
});

Wyświetl plik

@ -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')