Added promotions to redux and added selector for setting promotions if not PRO

• Added:
- promotions to redux
- selector for setting promotions if not PRO

• Updated:
- StatusList, SidebarPanelGroup to use promotions from redux
This commit is contained in:
mgabdev
2020-11-09 13:28:43 -06:00
parent f806fddb5f
commit 21937d9e09
9 changed files with 123 additions and 23 deletions

View File

@@ -38,6 +38,16 @@ const toServerSideType = columnType => {
export const getFilters = (state, { contextType }) => state.get('filters', ImmutableList()).filter(filter => contextType && filter.get('context').includes(toServerSideType(contextType)) && (filter.get('expires_at') === null || Date.parse(filter.get('expires_at')) > (new Date())));
export const getPromotions = () => {
return createSelector([
(state) => state,
(state) => state.getIn(['accounts', me, 'is_pro']),
(state) => state.get('promotions'),
], (state, isPro, promotions) => {
return !isPro ? promotions : ImmutableList()
})
}
const escapeRegExp = string =>
string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string