mirror of
https://github.com/LBRYFoundation/lbry-desktop.git
synced 2025-08-23 17:47:24 +00:00
Performance: don't spread in 'reduce'
This commit is contained in:
parent
dec38e1770
commit
15015dacd7
1 changed files with 6 additions and 9 deletions
|
@ -4,13 +4,10 @@ import { ACTIONS as LBRY_REDUX_ACTIONS, DEFAULT_KNOWN_TAGS, DEFAULT_FOLLOWED_TAG
|
||||||
import { handleActions } from 'util/redux-utils';
|
import { handleActions } from 'util/redux-utils';
|
||||||
|
|
||||||
function getDefaultKnownTags() {
|
function getDefaultKnownTags() {
|
||||||
return DEFAULT_FOLLOWED_TAGS.concat(DEFAULT_KNOWN_TAGS).reduce(
|
return DEFAULT_FOLLOWED_TAGS.concat(DEFAULT_KNOWN_TAGS).reduce((tagsMap, tag) => {
|
||||||
(tagsMap, tag) => ({
|
tagsMap[tag] = { name: tag };
|
||||||
...tagsMap,
|
return tagsMap;
|
||||||
[tag]: { name: tag },
|
}, {});
|
||||||
}),
|
|
||||||
{}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const defaultState: TagState = {
|
const defaultState: TagState = {
|
||||||
|
@ -27,7 +24,7 @@ export default handleActions(
|
||||||
let newFollowedTags = followedTags.slice();
|
let newFollowedTags = followedTags.slice();
|
||||||
|
|
||||||
if (newFollowedTags.includes(name)) {
|
if (newFollowedTags.includes(name)) {
|
||||||
newFollowedTags = newFollowedTags.filter(tag => tag !== name);
|
newFollowedTags = newFollowedTags.filter((tag) => tag !== name);
|
||||||
} else {
|
} else {
|
||||||
newFollowedTags.push(name);
|
newFollowedTags.push(name);
|
||||||
}
|
}
|
||||||
|
@ -57,7 +54,7 @@ export default handleActions(
|
||||||
|
|
||||||
let newKnownTags = { ...knownTags };
|
let newKnownTags = { ...knownTags };
|
||||||
delete newKnownTags[name];
|
delete newKnownTags[name];
|
||||||
const newFollowedTags = followedTags.filter(tag => tag !== name);
|
const newFollowedTags = followedTags.filter((tag) => tag !== name);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
|
|
Loading…
Add table
Reference in a new issue