Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix when favourite_tag unlock to set visibility #94

Merged
merged 3 commits into from
Oct 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,18 @@ class FavouriteTags extends React.PureComponent {
}

componentWillUpdate (nextProps, nextState) {
const icon = icons.concat().reverse().find(icon => nextState.lockedVisibility.includes(icon.key));
this.props.onLockTag(
nextState.lockedTag.join(' '),
typeof icon === 'undefined' ? '' : icon.key
);
// タグ操作に変更があった場合
if (!this.state.lockedTag.equals(nextState.lockedTag)) {
const icon = icons.concat().reverse().find(icon => nextState.lockedVisibility.includes(icon.key));
this.execLockTag(
nextState.lockedTag.join(' '),
typeof icon === 'undefined' ? '' : icon.key
);
}
}

execLockTag (tag, icon) {
this.props.onLockTag(tag, icon);
}

handleLockTag (tag, visibility) {
Expand Down
19 changes: 13 additions & 6 deletions app/javascript/mastodon/reducers/compose.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const initialState = ImmutableMap({
resetFileKey: Math.floor((Math.random() * 0x10000)),
idempotencyKey: null,
defaultText: '',
reply_privacy: '',
tag_privacy: '',
});

Expand All @@ -74,13 +75,17 @@ function clearAll(state) {
map.set('spoiler_text', '');
map.set('is_submitting', false);
map.set('in_reply_to', null);
map.set('privacy', state.get('tag_privacy') === '' ? state.get('default_privacy') : state.get('tag_privacy'));
map.set('privacy', getPrivacy(state));
map.set('sensitive', false);
map.update('media_attachments', list => list.clear());
map.set('idempotencyKey', uuid());
});
};

function getPrivacy(state) {
return state.get('tag_privacy') || state.get('default_privacy');
};

function appendMedia(state, media) {
const prevSize = state.get('media_attachments').size;

Expand Down Expand Up @@ -135,13 +140,12 @@ const insertEmoji = (state, position, emojiData) => {

const setDefaultTag = (state, text, visibility) => {
const replaceRE = new RegExp(` *${state.get('defaultText')}`);
const privacy = state.get('privacy') || state.get('default_privacy');
return state.withMutations(map => {
map.update('text', oldText => oldText.replace(replaceRE, '') + (text === '' ? '' : ` ${text}`));
map.set('defaultText', text);
if (visibility !== '') {
map.set('privacy', visibility);
}
map.set('tag_privacy', visibility);
map.set('privacy', visibility === '' ? state.get('reply_privacy') || state.get('default_privacy') : privacyPreference(privacy, visibility));
});
};

Expand Down Expand Up @@ -210,10 +214,12 @@ export default function compose(state = initialState, action) {
case COMPOSE_COMPOSING_CHANGE:
return state.set('is_composing', action.value);
case COMPOSE_REPLY:
const privacy = privacyPreference(action.status.get('visibility'), getPrivacy(state));
return state.withMutations(map => {
map.set('in_reply_to', action.status.get('id'));
map.set('text', statusToTextMentions(state, action.status));
map.set('privacy', privacyPreference(action.status.get('visibility'), state.get('default_privacy')));
map.set('privacy', privacy);
map.set('reply_privacy', privacy);
map.set('focusDate', new Date());
map.set('preselectDate', new Date());
map.set('idempotencyKey', uuid());
Expand All @@ -232,7 +238,8 @@ export default function compose(state = initialState, action) {
map.set('text', '');
map.set('spoiler', false);
map.set('spoiler_text', '');
map.set('privacy', state.get('default_privacy'));
map.set('privacy', getPrivacy(state));
map.set('reply_privacy', '');
map.set('idempotencyKey', uuid());
});
case COMPOSE_SUBMIT_REQUEST:
Expand Down