pr feedback

This commit is contained in:
Sean Yesmunt 2019-09-20 11:22:21 -04:00
parent 5ff2491e78
commit 6bd56492ad
4 changed files with 15 additions and 43 deletions

28
dist/bundle.es.js vendored
View file

@ -3558,18 +3558,19 @@ const doToggleBlockChannel = uri => ({
var _extends$5 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _extends$5 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
function extractSettings(rawObj) { function extractUserState(rawObj) {
if (rawObj && rawObj.version === '0' && rawObj.shared) { if (rawObj && rawObj.version === '0.1' && rawObj.shared) {
const { subscriptions, tags } = rawObj.shared; const { subscriptions, tags } = rawObj.shared;
return _extends$5({}, subscriptions ? { subscriptions } : {}, tags ? { tags } : {}); return _extends$5({}, subscriptions ? { subscriptions } : {}, tags ? { tags } : {});
} }
return {}; return {};
} }
function doPopulateUserSettings(settings) { function doPopulateSharedUserState(settings) {
return dispatch => { return dispatch => {
const { subscriptions, tags } = extractSettings(settings); const { subscriptions, tags } = extractUserState(settings);
dispatch({ type: USER_STATE_POPULATE, data: { subscriptions, tags } }); dispatch({ type: USER_STATE_POPULATE, data: { subscriptions, tags } });
}; };
} }
@ -4524,23 +4525,8 @@ const tagsReducer = handleActions({
}, },
[USER_STATE_POPULATE]: (state, action) => { [USER_STATE_POPULATE]: (state, action) => {
const { tags } = action.data; const { tags } = action.data;
let newTags;
if (!tags) {
newTags = state.followedTags.length ? state.followedTags : DEFAULT_FOLLOWED_TAGS;
} else {
if (!state.followedTags.length) {
newTags = tags;
} else {
const map = {};
newTags = tags.concat(state.followedTags).filter(tag => {
return map[tag] ? false : map[tag] = true;
}, {});
}
}
return _extends$d({}, state, { return _extends$d({}, state, {
followedTags: newTags followedTags: tags && tags.length ? tags : DEFAULT_FOLLOWED_TAGS
}); });
} }
}, defaultState$8); }, defaultState$8);
@ -4975,7 +4961,7 @@ exports.doFileGet = doFileGet;
exports.doFileList = doFileList; exports.doFileList = doFileList;
exports.doFocusSearchInput = doFocusSearchInput; exports.doFocusSearchInput = doFocusSearchInput;
exports.doGetNewAddress = doGetNewAddress; exports.doGetNewAddress = doGetNewAddress;
exports.doPopulateUserSettings = doPopulateUserSettings; exports.doPopulateSharedUserState = doPopulateSharedUserState;
exports.doPrepareEdit = doPrepareEdit; exports.doPrepareEdit = doPrepareEdit;
exports.doPublish = doPublish; exports.doPublish = doPublish;
exports.doPurchaseUri = doPurchaseUri; exports.doPurchaseUri = doPurchaseUri;

View file

@ -113,7 +113,7 @@ export { doCommentList, doCommentCreate } from 'redux/actions/comments';
export { doToggleBlockChannel } from 'redux/actions/blocked'; export { doToggleBlockChannel } from 'redux/actions/blocked';
export { doPopulateUserSettings } from 'redux/actions/sync'; export { doPopulateSharedUserState } from 'redux/actions/sync';
// utils // utils
export { batchActions } from 'util/batch-actions'; export { batchActions } from 'util/batch-actions';

View file

@ -2,16 +2,17 @@
import * as ACTIONS from 'constants/action_types'; import * as ACTIONS from 'constants/action_types';
type v0Data = { type v0Data = {
version: '0', version: '0.1',
shared: { shared: {
subscriptions?: Array<string>, subscriptions?: Array<string>,
tags?: Array<string>, tags?: Array<string>,
}, },
}; };
function extractSettings(rawObj: v0Data) { function extractUserState(rawObj: v0Data) {
if (rawObj && rawObj.version === '0' && rawObj.shared) { if (rawObj && rawObj.version === '0.1' && rawObj.shared) {
const { subscriptions, tags } = rawObj.shared; const { subscriptions, tags } = rawObj.shared;
return { return {
...(subscriptions ? { subscriptions } : {}), ...(subscriptions ? { subscriptions } : {}),
...(tags ? { tags } : {}), ...(tags ? { tags } : {}),
@ -21,9 +22,9 @@ function extractSettings(rawObj: v0Data) {
return {}; return {};
} }
export function doPopulateUserSettings(settings: any) { export function doPopulateSharedUserState(settings: any) {
return (dispatch: Dispatch) => { return (dispatch: Dispatch) => {
const { subscriptions, tags } = extractSettings(settings); const { subscriptions, tags } = extractUserState(settings);
dispatch({ type: ACTIONS.USER_STATE_POPULATE, data: { subscriptions, tags } }); dispatch({ type: ACTIONS.USER_STATE_POPULATE, data: { subscriptions, tags } });
}; };
} }

View file

@ -70,24 +70,9 @@ export const tagsReducer = handleActions(
action: { data: { tags: ?Array<string> } } action: { data: { tags: ?Array<string> } }
) => { ) => {
const { tags } = action.data; const { tags } = action.data;
let newTags;
if (!tags) {
newTags = state.followedTags.length ? state.followedTags : DEFAULT_FOLLOWED_TAGS;
} else {
if (!state.followedTags.length) {
newTags = tags;
} else {
const map = {};
newTags = tags.concat(state.followedTags).filter(tag => {
return map[tag] ? false : (map[tag] = true);
}, {});
}
}
return { return {
...state, ...state,
followedTags: newTags, followedTags: tags && tags.length ? tags : DEFAULT_FOLLOWED_TAGS,
}; };
}, },
}, },