allow apps to set their own default followed tags

This commit is contained in:
Sean Yesmunt 2019-06-13 12:10:27 -04:00
parent 82a5f242d0
commit ae2f720d1d
4 changed files with 54 additions and 105 deletions

21
dist/bundle.es.js vendored
View file

@ -3732,24 +3732,9 @@ function contentReducer(state = defaultState$6, action) {
return state;
}
const defaultFollowedTags = ['gaming', 'blockchain', 'news', 'learning', 'funny', 'technology', 'automotive', 'economics', 'sports', 'food', 'science', 'art', 'nature', 'beliefs', 'music', 'pop culture', 'weapons'];
const defaultRecommendedTags = [];
var _extends$b = 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 getDefaultRecommendedTags() {
return defaultFollowedTags.concat(defaultRecommendedTags).reduce((tagsMap, tag) => _extends$b({}, tagsMap, {
[tag]: { name: tag }
}), {});
}
const defaultState$7 = {
followedTags: defaultFollowedTags,
knownTags: getDefaultRecommendedTags()
};
const tagsReducer = handleActions({
const tagsReducerBuilder = defaultState => handleActions({
[TOGGLE_TAG_FOLLOW]: (state, action) => {
const { followedTags } = state;
const { name } = action.data;
@ -3792,7 +3777,7 @@ const tagsReducer = handleActions({
followedTags: newFollowedTags
});
}
}, defaultState$7);
}, defaultState);
const selectState$5 = state => state.content || {};
@ -4041,6 +4026,6 @@ exports.selectWalletUnlockPending = selectWalletUnlockPending;
exports.selectWalletUnlockResult = selectWalletUnlockResult;
exports.selectWalletUnlockSucceeded = selectWalletUnlockSucceeded;
exports.setSearchApi = setSearchApi;
exports.tagsReducer = tagsReducer;
exports.tagsReducerBuilder = tagsReducerBuilder;
exports.toQueryString = toQueryString;
exports.walletReducer = walletReducer;

View file

@ -1,21 +0,0 @@
export const defaultFollowedTags = [
'gaming',
'blockchain',
'news',
'learning',
'funny',
'technology',
'automotive',
'economics',
'sports',
'food',
'science',
'art',
'nature',
'beliefs',
'music',
'pop culture',
'weapons',
];
export const defaultRecommendedTags = [];

View file

@ -104,7 +104,7 @@ export { notificationsReducer } from 'redux/reducers/notifications';
export { searchReducer } from 'redux/reducers/search';
export { walletReducer } from 'redux/reducers/wallet';
export { contentReducer } from 'redux/reducers/content';
export { tagsReducer } from 'redux/reducers/tags';
export { tagsReducerBuilder } from 'redux/reducers/tags';
// selectors
export { makeSelectContentPositionForUri } from 'redux/selectors/content';

View file

@ -1,24 +1,9 @@
// @flow
import * as ACTIONS from 'constants/action_types';
import { handleActions } from 'util/redux-utils';
import { defaultRecommendedTags, defaultFollowedTags } from 'constants/tags';
function getDefaultRecommendedTags() {
return defaultFollowedTags.concat(defaultRecommendedTags).reduce(
(tagsMap, tag) => ({
...tagsMap,
[tag]: { name: tag },
}),
{}
);
}
const defaultState: TagState = {
followedTags: defaultFollowedTags,
knownTags: getDefaultRecommendedTags(),
};
export const tagsReducer = handleActions(
export const tagsReducerBuilder = (defaultState: TagState) =>
handleActions(
{
[ACTIONS.TOGGLE_TAG_FOLLOW]: (state: TagState, action: TagAction): TagState => {
const { followedTags } = state;