Use distinct `ME_PATCH_SUCCESS` action for responding to account updates

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

Wyświetl plik

@ -7,6 +7,7 @@ export const ME_FETCH_FAIL = 'ME_FETCH_FAIL';
export const ME_FETCH_SKIP = 'ME_FETCH_SKIP';
export const ME_PATCH_REQUEST = 'ME_PATCH_REQUEST';
export const ME_PATCH_SUCCESS = 'ME_PATCH_SUCCESS';
export const ME_PATCH_FAIL = 'ME_PATCH_FAIL';
const hasToken = getState => getState().hasIn(['auth', 'user', 'access_token']);
@ -35,7 +36,7 @@ export function patchMe(params) {
return api(getState)
.patch('/api/v1/accounts/update_credentials', params)
.then(response => {
dispatch(fetchMeSuccess(response.data));
dispatch(patchMeSuccess(response.data));
}).catch(error => {
dispatch(patchMeFail(error));
});
@ -72,6 +73,16 @@ export function patchMeRequest() {
};
}
export function patchMeSuccess(me) {
return (dispatch, getState) => {
dispatch(importFetchedAccount(me));
dispatch({
type: ME_PATCH_SUCCESS,
me,
});
};
}
export function patchMeFail(error) {
return {
type: ME_PATCH_FAIL,

Wyświetl plik

@ -1,4 +1,9 @@
import { ME_FETCH_SUCCESS, ME_FETCH_FAIL, ME_FETCH_SKIP } from '../actions/me';
import {
ME_FETCH_SUCCESS,
ME_FETCH_FAIL,
ME_FETCH_SKIP,
ME_PATCH_SUCCESS,
} from '../actions/me';
import { AUTH_LOGGED_OUT } from '../actions/auth';
const initialState = null;
@ -6,6 +11,7 @@ const initialState = null;
export default function me(state = initialState, action) {
switch(action.type) {
case ME_FETCH_SUCCESS:
case ME_PATCH_SUCCESS:
return action.me.id;
case ME_FETCH_FAIL:
case ME_FETCH_SKIP:

Wyświetl plik

@ -1,7 +1,7 @@
'use strict';
import { STORE_HYDRATE } from '../actions/store';
import { ME_FETCH_SUCCESS } from 'soapbox/actions/me';
import { ME_FETCH_SUCCESS, ME_PATCH_SUCCESS } from 'soapbox/actions/me';
import { Map as ImmutableMap, fromJS } from 'immutable';
const initialState = ImmutableMap();
@ -11,6 +11,7 @@ export default function meta(state = initialState, action) {
case STORE_HYDRATE:
return state.merge(action.state.get('meta'));
case ME_FETCH_SUCCESS:
case ME_PATCH_SUCCESS:
const me = fromJS(action.me);
if (me.has('pleroma')) {
const pleroPrefs = me.get('pleroma').delete('settings_store');

Wyświetl plik

@ -3,7 +3,7 @@ import { NOTIFICATIONS_FILTER_SET } from '../actions/notifications';
import { STORE_HYDRATE } from '../actions/store';
import { EMOJI_USE } from '../actions/emojis';
import { LIST_DELETE_SUCCESS, LIST_FETCH_FAIL } from '../actions/lists';
import { ME_FETCH_SUCCESS } from 'soapbox/actions/me';
import { ME_FETCH_SUCCESS, ME_PATCH_SUCCESS } from 'soapbox/actions/me';
import { Map as ImmutableMap, fromJS } from 'immutable';
import uuid from '../uuid';
@ -32,6 +32,7 @@ export default function settings(state = initialState, action) {
case STORE_HYDRATE:
return hydrate(state, action.state.get('settings'));
case ME_FETCH_SUCCESS:
case ME_PATCH_SUCCESS:
const me = fromJS(action.me);
const fePrefs = me.getIn(['pleroma', 'settings_store', FE_NAME]);
return state.merge(fePrefs);