import { CHANGE_DAILY_GOAL , CHANGE_SELECTED_TAB , TOGGLE_SEARCH_ACTIVITY , TOGGLE_LEGACY_LINKS , TOGGLE_SEARCH_AUDIO , UPDATE_QUEUE_SORT } from '../constants' ; import { Primitive , QueueSortingOption } from '../types' ; export interface ChangeTab { readonly type : CHANGE_SELECTED_TAB ; readonly data : number ; } export interface ChangeDailyGoal { readonly type : CHANGE_DAILY_GOAL ; readonly data : number ; } export interface ChangeQueueSort { readonly type : UPDATE_QUEUE_SORT ; readonly data : QueueSortingOption ; } export interface ToggleSearchActive { readonly type : TOGGLE_SEARCH_ACTIVITY ; } export interface ToggleLegacyLinks { readonly type : TOGGLE_LEGACY_LINKS ; } export interface ToggleSearchAudio { readonly type : TOGGLE_SEARCH_AUDIO ; } export const updateValue = < T extends Primitive > ( type ) => ( data ) => ( { type , data } ) ; export const toggleValue = ( type ) => ( ) => ( { type } ) ; export const changeDailyGoal = updateValue < number > ( CHANGE_DAILY_GOAL ) ; export const changeTab = updateValue < number > ( CHANGE_SELECTED_TAB ) ; export const toggleSearchActive = toggleValue ( TOGGLE_SEARCH_ACTIVITY ) ; export const toggleLegacyLinks = toggleValue ( TOGGLE_LEGACY_LINKS ) ; export const toggleSearchAudio = toggleValue ( TOGGLE_SEARCH_AUDIO ) ;