import { AnyAction } from "redux" ; import { EthContentHeader } from "@joincivil/typescript-types" ; export const ADD_REVISION = "ADD_REVISION" ; export const ADD_REVISION_JSON = "ADD_REVISION_JSON" ; const fetchRevision = async ( uri ) => { return new Promise ( ( resolve , reject ) => { fetch ( uri ) . then ( async ( res ) => res . json ( ) ) . then ( json => { resolve ( json ) ; } ) . catch ( e => { reject ( e ) ; } ) ; } ) ; } ; export const addRevision = ( revision ) : AnyAction => { return { type : ADD_REVISION , data : revision , } ; } ; export const fetchRevisionJson = ( uri , contentId , revisionId ) : any => async ( dispatch ) : Promise < AnyAction > => { const json = await fetchRevision ( uri ) ; return dispatch ( { type : ADD_REVISION_JSON , data : { contentId , revisionId , json , } , } ) ; } ;