Fix default privacy setting on Mastodon

Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
marcin mikołajczak 2023-04-25 19:14:02 +02:00
parent fc6eba91ac
commit 929935fb19

View file

@ -245,25 +245,13 @@ const getAccountSettings = (account: ImmutableMap<string, any>) => {
const importAccount = (compose: Compose, account: APIEntity) => { const importAccount = (compose: Compose, account: APIEntity) => {
const settings = getAccountSettings(ImmutableMap(fromJS(account))); const settings = getAccountSettings(ImmutableMap(fromJS(account)));
const defaultPrivacy = settings.get('defaultPrivacy', 'public');
const defaultContentType = settings.get('defaultContentType', 'text/plain');
return compose.merge({
privacy: defaultPrivacy,
content_type: defaultContentType,
tagHistory: ImmutableList(tagHistory.get(account.id)),
});
};
const updateAccount = (compose: Compose, account: APIEntity) => {
const settings = getAccountSettings(ImmutableMap(fromJS(account)));
const defaultPrivacy = settings.get('defaultPrivacy'); const defaultPrivacy = settings.get('defaultPrivacy');
const defaultContentType = settings.get('defaultContentType'); const defaultContentType = settings.get('defaultContentType');
return compose.withMutations(compose => { return compose.withMutations(compose => {
if (defaultPrivacy) compose.set('privacy', defaultPrivacy); if (defaultPrivacy) compose.set('privacy', defaultPrivacy);
if (defaultContentType) compose.set('content_type', defaultContentType); if (defaultContentType) compose.set('content_type', defaultContentType);
compose.set('tagHistory', ImmutableList(tagHistory.get(account.id)));
}); });
}; };
@ -507,9 +495,8 @@ export default function compose(state = initialState, action: AnyAction) {
case COMPOSE_SET_GROUP_TIMELINE_VISIBLE: case COMPOSE_SET_GROUP_TIMELINE_VISIBLE:
return updateCompose(state, action.id, compose => compose.set('group_timeline_visible', action.groupTimelineVisible)); return updateCompose(state, action.id, compose => compose.set('group_timeline_visible', action.groupTimelineVisible));
case ME_FETCH_SUCCESS: case ME_FETCH_SUCCESS:
return updateCompose(state, 'default', compose => importAccount(compose, action.me));
case ME_PATCH_SUCCESS: case ME_PATCH_SUCCESS:
return updateCompose(state, 'default', compose => updateAccount(compose, action.me)); return updateCompose(state, 'default', compose => importAccount(compose, action.me));
case SETTING_CHANGE: case SETTING_CHANGE:
return updateCompose(state, 'default', compose => updateSetting(compose, action.path, action.value)); return updateCompose(state, 'default', compose => updateSetting(compose, action.path, action.value));
default: default: