Skip to content

Commit

Permalink
title: Clean up logic a bit in getTitleBackgroundColor.
Browse files Browse the repository at this point in the history
Hopefully this makes it easier to see what's happening.
  • Loading branch information
gnprice committed Nov 21, 2018
1 parent d2faf47 commit e7baf88
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions src/title/titleSelectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,10 @@ export const DEFAULT_TITLE_BACKGROUND_COLOR = 'transparent';
* Otherwise, it takes a default value.
*/
export const getTitleBackgroundColor = (narrow?: Narrow): Selector<string> =>
createSelector(
getSubscriptions,
subscriptions =>
isStreamOrTopicNarrow(narrow)
? (
subscriptions.find(sub => Array.isArray(narrow) && narrow[0].operand === sub.name)
|| NULL_SUBSCRIPTION
).color
: DEFAULT_TITLE_BACKGROUND_COLOR,
);
createSelector(getSubscriptions, subscriptions => {
if (!narrow || !isStreamOrTopicNarrow(narrow)) {
return DEFAULT_TITLE_BACKGROUND_COLOR;
}
const streamName = narrow[0].operand;
return (subscriptions.find(sub => streamName === sub.name) || NULL_SUBSCRIPTION).color;
});

0 comments on commit e7baf88

Please sign in to comment.