import { ActionTypes , ConfirmationRequest } from '../reducers/Global' ; import { Dispatch } from 'redux' ; export const showError = ( error ? ) => ( { error , type : ActionTypes . showError , } ) ; export const showNotification = ( notification ? ) => ( { notification , type : ActionTypes . showNotification , } ) ; export const didLaunch = ( ) => ( { type : ActionTypes . didLaunch , } ) ; export const toggleSettingsVisibility = ( ) => ( dispatch ) => { dispatch ( { type : ActionTypes . toggleSettingsVisibility , } ) ; } ; export const requestConfirmation = ( title , inquiry ) => ( dispatch ) => { return new Promise ( resolve => { const confirmationRequest = { title , inquiry , callback : ( confirmed ) => { resolve ( confirmed ) ; dispatch ( removeConfirmationRequest ( confirmationRequest ) ) ; } , } ; dispatch ( { confirmationRequest , type : ActionTypes . requestConfirmation , } ) ; } ) ; } ; export const removeConfirmationRequest = ( confirmationRequest ) => ( dispatch ) => { return new Promise ( ( resolve , reject ) => { dispatch ( { confirmationRequest , type : ActionTypes . removeConfirmationRequest , } ) ; } ) ; } ;