import { Dispatch } from 'redux' ; import { IconSize , IconSortVariant , UIaction , UIactionTypes , } from '../../types/redux/ui-reducer-types' ; import { State } from '../reducers' ; UI function returns { function } export const changeTheme = ( ) => { return async ( dispatch , getState ) : Promise < void > => { dispatch ( { type : UIactionTypes . CHANGE_THEME } ) ; localStorage . setItem ( 'theme' , getState ( ) . ui . theme ) ; dispatch ( { type : UIactionTypes . THEME_WAS_CHANGED } ) ; } ; } ; UI function returns { function } export const toggleWidgetsModal = ( ) => { return async ( dispatch , getState ) : Promise < void > => { const { isWidgetOpen } = getState ( ) . ui ; if ( isWidgetOpen === false ) { dispatch ( { type : UIactionTypes . OPEN_WIDGETS_MODAL } ) ; } else { dispatch ( { type : UIactionTypes . CLOSE_WIDGETS_MODAL } ) ; } } ; } ; export const closeWidgetsModal = ( ) : UIaction => ( { type : UIactionTypes . CLOSE_WIDGETS_MODAL , } ) ; UI function returns { function } export const toggleAppCenterModal = ( ) => { return async ( dispatch , getState ) : Promise < void > => { const { isAppCenterOpen } = getState ( ) . ui ; if ( isAppCenterOpen === false ) { dispatch ( { type : UIactionTypes . OPEN_APP_CENTER_MODAL } ) ; } else { dispatch ( { type : UIactionTypes . CLOSE_APP_CENTER_MODAL } ) ; } } ; } ; export const closeAppCenterModal = ( ) : UIaction => ( { type : UIactionTypes . CLOSE_APP_CENTER_MODAL , } ) ; UI function returns { function } export const toggleSettingsModal = ( ) => { return async ( dispatch , getState ) : Promise < void > => { const { areSettingsOpen } = getState ( ) . ui ; if ( areSettingsOpen === false ) { dispatch ( { type : UIactionTypes . OPEN_SETTINGS_MODAL } ) ; } else { dispatch ( { type : UIactionTypes . CLOSE_SETTINGS_MODAL } ) ; } } ; } ; export const closeSettingsModal = ( ) : UIaction => ( { type : UIactionTypes . CLOSE_SETTINGS_MODAL , } ) ; UI function returns { function } export const toggleSearchModal = ( ) => { return async ( dispatch , getState ) : Promise < void > => { const { isSearchOpen } = getState ( ) . ui ; if ( isSearchOpen === false ) { dispatch ( { type : UIactionTypes . OPEN_SEARCH_MODAL } ) ; } else { dispatch ( { type : UIactionTypes . CLOSE_SEARCH_MODAL } ) ; } } ; } ; export const closeSearchModal = ( ) : UIaction => ( { type : UIactionTypes . CLOSE_SEARCH_MODAL , } ) ; UI function returns { function } export const toggleCalendarModal = ( ) => { return async ( dispatch , getState ) : Promise < void > => { const { isCalendarOpen } = getState ( ) . ui ; if ( isCalendarOpen === false ) { dispatch ( { type : UIactionTypes . OPEN_CALENDAR_MODAL } ) ; } else { dispatch ( { type : UIactionTypes . CLOSE_CALENDAR_MODAL } ) ; } } ; } ; export const openCalendarModal = ( ) : UIaction => ( { type : UIactionTypes . OPEN_CALENDAR_MODAL , } ) ; export const closeCalendarModal = ( ) : UIaction => ( { type : UIactionTypes . CLOSE_CALENDAR_MODAL , } ) ; UI function returns { function } export const toggleNightLightMode = ( ) => { return async ( dispatch , getState ) : Promise < void > => { const { isInNightLightMode } = getState ( ) . ui ; if ( isInNightLightMode === false ) { dispatch ( { type : UIactionTypes . TURN_ON_NIGHT_MODE } ) ; } else { dispatch ( { type : UIactionTypes . TURN_OFF_NIGHT_MODE } ) ; } } ; } ; UI function returns { function } export const changeScreenBrightness = ( brightness ) => { return async ( dispatch ) : Promise < void > => { dispatch ( { type : UIactionTypes . CHANGE_BRIGHTNESS , payload : brightness } ) ; } ; } ; UI function returns { function } export const notShowIntroAgain = ( ) : UIaction => ( { type : UIactionTypes . INTRO_WAS_SHOWN , } ) ; UI function param { object } coords returns { function } export const openContextMenu = ( coords ) : UIaction => ( { type : UIactionTypes . OPEN_CONTEXT_MENU , payload : coords , } ) ; UI function returns { function } export const closeContextMenu = ( ) : UIaction => ( { type : UIactionTypes . CLOSE_CONTEXT_MENU , } ) ; UI function param { enum } wayOfSorting returns { function } export const sortDesktopIcons = ( wayOfSorting ) : UIaction => ( { type : UIactionTypes . SORT_DESKTOP_ICONS , payload : wayOfSorting , } ) ; UI function param { enum } iconSize returns { function } export const changeDesktopIconSize = ( iconSize ) : UIaction => ( { type : UIactionTypes . CHANGE_ICON_SIZE , payload : iconSize , } ) ; UI function param { string } appName returns { function } export const deleteDesktopApp = ( appName ) : UIaction => ( { type : UIactionTypes . DELETE_APP , payload : appName , } ) ; UI function returns { function } export const undoLastDeleteDesktopApp = ( ) : UIaction => ( { type : UIactionTypes . UNDO_DELETE_APP , } ) ; UI function returns { function } export const compressDesktopApp = ( appName ) : UIaction => ( { type : UIactionTypes . COMPRESS_DESKTOP_APP , payload : appName , } ) ;