pr feedback
This commit is contained in:
parent
5ff2491e78
commit
6bd56492ad
4 changed files with 15 additions and 43 deletions
28
dist/bundle.es.js
vendored
28
dist/bundle.es.js
vendored
|
@ -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; };
|
||||
|
||||
function extractSettings(rawObj) {
|
||||
if (rawObj && rawObj.version === '0' && rawObj.shared) {
|
||||
function extractUserState(rawObj) {
|
||||
if (rawObj && rawObj.version === '0.1' && rawObj.shared) {
|
||||
const { subscriptions, tags } = rawObj.shared;
|
||||
|
||||
return _extends$5({}, subscriptions ? { subscriptions } : {}, tags ? { tags } : {});
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
function doPopulateUserSettings(settings) {
|
||||
function doPopulateSharedUserState(settings) {
|
||||
return dispatch => {
|
||||
const { subscriptions, tags } = extractSettings(settings);
|
||||
const { subscriptions, tags } = extractUserState(settings);
|
||||
dispatch({ type: USER_STATE_POPULATE, data: { subscriptions, tags } });
|
||||
};
|
||||
}
|
||||
|
@ -4524,23 +4525,8 @@ const tagsReducer = handleActions({
|
|||
},
|
||||
[USER_STATE_POPULATE]: (state, action) => {
|
||||
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, {
|
||||
followedTags: newTags
|
||||
followedTags: tags && tags.length ? tags : DEFAULT_FOLLOWED_TAGS
|
||||
});
|
||||
}
|
||||
}, defaultState$8);
|
||||
|
@ -4975,7 +4961,7 @@ exports.doFileGet = doFileGet;
|
|||
exports.doFileList = doFileList;
|
||||
exports.doFocusSearchInput = doFocusSearchInput;
|
||||
exports.doGetNewAddress = doGetNewAddress;
|
||||
exports.doPopulateUserSettings = doPopulateUserSettings;
|
||||
exports.doPopulateSharedUserState = doPopulateSharedUserState;
|
||||
exports.doPrepareEdit = doPrepareEdit;
|
||||
exports.doPublish = doPublish;
|
||||
exports.doPurchaseUri = doPurchaseUri;
|
||||
|
|
|
@ -113,7 +113,7 @@ export { doCommentList, doCommentCreate } from 'redux/actions/comments';
|
|||
|
||||
export { doToggleBlockChannel } from 'redux/actions/blocked';
|
||||
|
||||
export { doPopulateUserSettings } from 'redux/actions/sync';
|
||||
export { doPopulateSharedUserState } from 'redux/actions/sync';
|
||||
|
||||
// utils
|
||||
export { batchActions } from 'util/batch-actions';
|
||||
|
|
|
@ -2,16 +2,17 @@
|
|||
import * as ACTIONS from 'constants/action_types';
|
||||
|
||||
type v0Data = {
|
||||
version: '0',
|
||||
version: '0.1',
|
||||
shared: {
|
||||
subscriptions?: Array<string>,
|
||||
tags?: Array<string>,
|
||||
},
|
||||
};
|
||||
|
||||
function extractSettings(rawObj: v0Data) {
|
||||
if (rawObj && rawObj.version === '0' && rawObj.shared) {
|
||||
function extractUserState(rawObj: v0Data) {
|
||||
if (rawObj && rawObj.version === '0.1' && rawObj.shared) {
|
||||
const { subscriptions, tags } = rawObj.shared;
|
||||
|
||||
return {
|
||||
...(subscriptions ? { subscriptions } : {}),
|
||||
...(tags ? { tags } : {}),
|
||||
|
@ -21,9 +22,9 @@ function extractSettings(rawObj: v0Data) {
|
|||
return {};
|
||||
}
|
||||
|
||||
export function doPopulateUserSettings(settings: any) {
|
||||
export function doPopulateSharedUserState(settings: any) {
|
||||
return (dispatch: Dispatch) => {
|
||||
const { subscriptions, tags } = extractSettings(settings);
|
||||
const { subscriptions, tags } = extractUserState(settings);
|
||||
dispatch({ type: ACTIONS.USER_STATE_POPULATE, data: { subscriptions, tags } });
|
||||
};
|
||||
}
|
||||
|
|
|
@ -70,24 +70,9 @@ export const tagsReducer = handleActions(
|
|||
action: { data: { tags: ?Array<string> } }
|
||||
) => {
|
||||
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 {
|
||||
...state,
|
||||
followedTags: newTags,
|
||||
followedTags: tags && tags.length ? tags : DEFAULT_FOLLOWED_TAGS,
|
||||
};
|
||||
},
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue