mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-25 00:07:47 +01:00
fix: should not clear all stores on update user profile
This commit is contained in:
parent
61cd47a0e7
commit
9c009627ba
@ -1,6 +1,6 @@
|
|||||||
import { fromJS, List, Map } from 'immutable';
|
import { fromJS, List, Map } from 'immutable';
|
||||||
import { RECEIVE_ALL_APPLICATIONS, RECEIVE_APPLICATION } from './actions';
|
import { RECEIVE_ALL_APPLICATIONS, RECEIVE_APPLICATION } from './actions';
|
||||||
import { USER_LOGOUT, UPDATE_USER } from '../user/actions';
|
import { USER_LOGOUT, USER_LOGIN } from '../user/actions';
|
||||||
|
|
||||||
function getInitState() {
|
function getInitState() {
|
||||||
return fromJS({ list: [], apps: {} });
|
return fromJS({ list: [], apps: {} });
|
||||||
@ -13,7 +13,7 @@ const store = (state = getInitState(), action) => {
|
|||||||
case RECEIVE_ALL_APPLICATIONS:
|
case RECEIVE_ALL_APPLICATIONS:
|
||||||
return state.set('list', new List(action.value.applications));
|
return state.set('list', new List(action.value.applications));
|
||||||
case USER_LOGOUT:
|
case USER_LOGOUT:
|
||||||
case UPDATE_USER:
|
case USER_LOGIN:
|
||||||
return getInitState();
|
return getInitState();
|
||||||
default:
|
default:
|
||||||
return state;
|
return state;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { List, Map as $Map } from 'immutable';
|
import { List, Map as $Map } from 'immutable';
|
||||||
import { RECEIVE_ARCHIVE, REVIVE_TOGGLE } from './archive-actions';
|
import { RECEIVE_ARCHIVE, REVIVE_TOGGLE } from './archive-actions';
|
||||||
import { USER_LOGOUT, UPDATE_USER } from './user/actions';
|
import { USER_LOGOUT, USER_LOGIN } from './user/actions';
|
||||||
|
|
||||||
function getInitState() {
|
function getInitState() {
|
||||||
return new $Map({ list: new List() });
|
return new $Map({ list: new List() });
|
||||||
@ -13,7 +13,7 @@ const archiveStore = (state = getInitState(), action) => {
|
|||||||
case RECEIVE_ARCHIVE:
|
case RECEIVE_ARCHIVE:
|
||||||
return state.set('list', new List(action.value));
|
return state.set('list', new List(action.value));
|
||||||
case USER_LOGOUT:
|
case USER_LOGOUT:
|
||||||
case UPDATE_USER:
|
case USER_LOGIN:
|
||||||
return getInitState();
|
return getInitState();
|
||||||
default:
|
default:
|
||||||
return state;
|
return state;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { fromJS } from 'immutable';
|
import { fromJS } from 'immutable';
|
||||||
import { RECEIVE_CLIENT_INSTANCES } from './client-instance-actions';
|
import { RECEIVE_CLIENT_INSTANCES } from './client-instance-actions';
|
||||||
import { USER_LOGOUT, UPDATE_USER } from './user/actions';
|
import { USER_LOGOUT, USER_LOGIN } from './user/actions';
|
||||||
|
|
||||||
function getInitState() {
|
function getInitState() {
|
||||||
return fromJS([]);
|
return fromJS([]);
|
||||||
@ -11,7 +11,7 @@ const store = (state = getInitState(), action) => {
|
|||||||
case RECEIVE_CLIENT_INSTANCES:
|
case RECEIVE_CLIENT_INSTANCES:
|
||||||
return fromJS(action.value);
|
return fromJS(action.value);
|
||||||
case USER_LOGOUT:
|
case USER_LOGOUT:
|
||||||
case UPDATE_USER:
|
case USER_LOGIN:
|
||||||
return getInitState();
|
return getInitState();
|
||||||
default:
|
default:
|
||||||
return state;
|
return state;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { List } from 'immutable';
|
import { List } from 'immutable';
|
||||||
import { RECEIVE_CONTEXT, REMOVE_CONTEXT, ADD_CONTEXT_FIELD, UPDATE_CONTEXT_FIELD } from './actions';
|
import { RECEIVE_CONTEXT, REMOVE_CONTEXT, ADD_CONTEXT_FIELD, UPDATE_CONTEXT_FIELD } from './actions';
|
||||||
import { USER_LOGOUT, UPDATE_USER } from '../user/actions';
|
import { USER_LOGOUT, USER_LOGIN } from '../user/actions';
|
||||||
|
|
||||||
const DEFAULT_CONTEXT_FIELDS = [{ name: 'environment' }, { name: 'userId' }, { name: 'appName' }];
|
const DEFAULT_CONTEXT_FIELDS = [{ name: 'environment' }, { name: 'userId' }, { name: 'appName' }];
|
||||||
|
|
||||||
@ -21,7 +21,7 @@ const strategies = (state = getInitState(), action) => {
|
|||||||
return state.set(index, action.context);
|
return state.set(index, action.context);
|
||||||
}
|
}
|
||||||
case USER_LOGOUT:
|
case USER_LOGOUT:
|
||||||
case UPDATE_USER:
|
case USER_LOGIN:
|
||||||
return getInitState();
|
return getInitState();
|
||||||
default:
|
default:
|
||||||
return state;
|
return state;
|
||||||
|
@ -10,7 +10,7 @@ import {
|
|||||||
TOGGLE_FEATURE_TOGGLE,
|
TOGGLE_FEATURE_TOGGLE,
|
||||||
} from './feature-actions';
|
} from './feature-actions';
|
||||||
|
|
||||||
import { USER_LOGOUT, UPDATE_USER } from './user/actions';
|
import { USER_LOGOUT, USER_LOGIN } from './user/actions';
|
||||||
|
|
||||||
const features = (state = new List([]), action) => {
|
const features = (state = new List([]), action) => {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
@ -50,7 +50,7 @@ const features = (state = new List([]), action) => {
|
|||||||
case RECEIVE_FEATURE_TOGGLES:
|
case RECEIVE_FEATURE_TOGGLES:
|
||||||
debug(RECEIVE_FEATURE_TOGGLES, action);
|
debug(RECEIVE_FEATURE_TOGGLES, action);
|
||||||
return new List(action.featureToggles.map($Map));
|
return new List(action.featureToggles.map($Map));
|
||||||
case UPDATE_USER:
|
case USER_LOGIN:
|
||||||
case USER_LOGOUT:
|
case USER_LOGOUT:
|
||||||
debug(USER_LOGOUT, action);
|
debug(USER_LOGOUT, action);
|
||||||
return new List([]);
|
return new List([]);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { List, Map as $Map } from 'immutable';
|
import { List, Map as $Map } from 'immutable';
|
||||||
import { RECEIVE_HISTORY, RECEIVE_HISTORY_FOR_TOGGLE } from './history-actions';
|
import { RECEIVE_HISTORY, RECEIVE_HISTORY_FOR_TOGGLE } from './history-actions';
|
||||||
import { USER_LOGOUT, UPDATE_USER } from './user/actions';
|
import { USER_LOGOUT, USER_LOGIN } from './user/actions';
|
||||||
|
|
||||||
function getInitState() {
|
function getInitState() {
|
||||||
return new $Map({ list: new List(), toggles: new $Map() });
|
return new $Map({ list: new List(), toggles: new $Map() });
|
||||||
@ -13,7 +13,7 @@ const historyStore = (state = getInitState(), action) => {
|
|||||||
case RECEIVE_HISTORY:
|
case RECEIVE_HISTORY:
|
||||||
return state.set('list', new List(action.value));
|
return state.set('list', new List(action.value));
|
||||||
case USER_LOGOUT:
|
case USER_LOGOUT:
|
||||||
case UPDATE_USER:
|
case USER_LOGIN:
|
||||||
return getInitState();
|
return getInitState();
|
||||||
default:
|
default:
|
||||||
return state;
|
return state;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { Map as $Map, List, fromJS } from 'immutable';
|
import { Map as $Map, List, fromJS } from 'immutable';
|
||||||
import actions from './input-actions';
|
import actions from './input-actions';
|
||||||
import { USER_LOGOUT, UPDATE_USER } from './user/actions';
|
import { USER_LOGOUT, USER_LOGIN } from './user/actions';
|
||||||
|
|
||||||
function getInitState() {
|
function getInitState() {
|
||||||
return new $Map();
|
return new $Map();
|
||||||
@ -103,7 +103,7 @@ const inputState = (state = getInitState(), action) => {
|
|||||||
case actions.CLEAR:
|
case actions.CLEAR:
|
||||||
return clear(state, action);
|
return clear(state, action);
|
||||||
case USER_LOGOUT:
|
case USER_LOGOUT:
|
||||||
case UPDATE_USER:
|
case USER_LOGIN:
|
||||||
return getInitState();
|
return getInitState();
|
||||||
default:
|
default:
|
||||||
// console.log('TYPE', action.type, action);
|
// console.log('TYPE', action.type, action);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { fromJS, Map as $Map } from 'immutable';
|
import { fromJS, Map as $Map } from 'immutable';
|
||||||
import { UPDATE_SETTING } from './actions';
|
import { UPDATE_SETTING } from './actions';
|
||||||
import { USER_LOGOUT, UPDATE_USER } from '../user/actions';
|
import { USER_LOGOUT, USER_LOGIN } from '../user/actions';
|
||||||
|
|
||||||
// TODO: provde a mock if localstorage does not exists?
|
// TODO: provde a mock if localstorage does not exists?
|
||||||
const localStorage = window.localStorage || {};
|
const localStorage = window.localStorage || {};
|
||||||
@ -27,7 +27,7 @@ const settingStore = (state = getInitState(), action) => {
|
|||||||
case UPDATE_SETTING:
|
case UPDATE_SETTING:
|
||||||
return updateSetting(state, action);
|
return updateSetting(state, action);
|
||||||
case USER_LOGOUT:
|
case USER_LOGOUT:
|
||||||
case UPDATE_USER:
|
case USER_LOGIN:
|
||||||
return getInitState();
|
return getInitState();
|
||||||
default:
|
default:
|
||||||
return state;
|
return state;
|
||||||
|
@ -2,6 +2,7 @@ import api from '../../data/user-api';
|
|||||||
import { dispatchAndThrow } from '../util';
|
import { dispatchAndThrow } from '../util';
|
||||||
export const UPDATE_USER = 'UPDATE_USER';
|
export const UPDATE_USER = 'UPDATE_USER';
|
||||||
export const USER_LOGOUT = 'USER_LOGOUT';
|
export const USER_LOGOUT = 'USER_LOGOUT';
|
||||||
|
export const USER_LOGIN = 'USER_LOGIN';
|
||||||
export const START_FETCH_USER = 'START_FETCH_USER';
|
export const START_FETCH_USER = 'START_FETCH_USER';
|
||||||
export const ERROR_FETCH_USER = 'ERROR_FETCH_USER';
|
export const ERROR_FETCH_USER = 'ERROR_FETCH_USER';
|
||||||
const debug = require('debug')('unleash:user-actions');
|
const debug = require('debug')('unleash:user-actions');
|
||||||
@ -42,7 +43,10 @@ export function passwordLogin(path, user) {
|
|||||||
return dispatch => {
|
return dispatch => {
|
||||||
dispatch({ type: START_FETCH_USER });
|
dispatch({ type: START_FETCH_USER });
|
||||||
|
|
||||||
return api.passwordLogin(path, user).then(json => dispatch(updateUser(json)));
|
return api
|
||||||
|
.passwordLogin(path, user)
|
||||||
|
.then(json => dispatch(updateUser(json)))
|
||||||
|
.then(() => dispatch({ type: USER_LOGIN }));
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user