gab-social/app/javascript/gabsocial/actions/timeline_injections.js
mgabdev d198695bdb Added Timeline Injections
• Added:
- Timeline Injections
- FeaturedGroupsInjection, GroupCategoriesInjection, ProUpgradeInjection, PWAInjection, ShopInjection, TimelineInjectionBase, TimelineInjectionLayout, TimelineInjectionRoot, UserSuggestionsInjection
- Constants
- Redux for timeline_injections
- settings for setting
- popover for dismissing and saving weight
2020-09-14 11:40:42 -05:00

32 lines
949 B
JavaScript

import {
TIMELINE_INJECTION_WEIGHT_DEFAULT,
TIMELINE_INJECTION_WEIGHT_MULTIPLIER,
TIMELINE_INJECTION_WEIGHT_SUBTRACTOR,
TIMELINE_INJECTION_WEIGHT_MIN,
} from '../constants'
import { changeSetting } from './settings'
export const TIMELINE_INJECTION_SHOW = 'TIMELINE_INJECTION_SHOW'
export const TIMELINE_INJECTION_HIDE = 'TIMELINE_INJECTION_HIDE'
export const showTimelineInjection = (injectionId) => (dispatch) => {
dispatch({
type: TIMELINE_INJECTION_SHOW,
injectionId,
})
}
export const hideTimelineInjection = (injectionId) => (dispatch, getState) => {
const existingInjectionWeight = getState().getIn(['settings', 'injections', injectionId], null)
if (!existingInjectionWeight) return false
const newInjectionWeight = Math.max(existingInjectionWeight - 0.005, 0.01)
dispatch(changeSetting(['injections', injectionId], newInjectionWeight))
dispatch({
type: TIMELINE_INJECTION_HIDE,
injectionId,
})
}