@@ -259,6 +259,7 @@ interface BackendOptions {
259259 backendName : string ;
260260 config : CmsConfig ;
261261 authStore ?: AuthStore ;
262+ dispatch ?: any ;
262263}
263264
264265export interface MediaFile {
@@ -294,6 +295,7 @@ interface ImplementationInitOptions {
294295 useWorkflow : boolean ;
295296 updateUserCredentials : ( credentials : Credentials ) => void ;
296297 initialWorkflowStatus : string ;
298+ dispatch ?: any ;
297299}
298300
299301type Implementation = BackendImplementation & {
@@ -383,14 +385,18 @@ export class Backend {
383385 user ?: User | null ;
384386 backupSync : AsyncLock ;
385387
386- constructor ( implementation : Implementation , { backendName, authStore, config } : BackendOptions ) {
388+ constructor (
389+ implementation : Implementation ,
390+ { backendName, authStore, config, dispatch } : BackendOptions ,
391+ ) {
387392 // We can't reliably run this on exit, so we do cleanup on load.
388393 this . deleteAnonymousBackup ( ) ;
389394 this . config = config ;
390395 this . implementation = implementation . init ( this . config , {
391396 useWorkflow : selectUseWorkflow ( this . config ) ,
392397 updateUserCredentials : this . updateUserCredentials ,
393398 initialWorkflowStatus : status . first ( ) ,
399+ dispatch,
394400 } ) ;
395401 this . backendName = backendName ;
396402 this . authStore = authStore ;
@@ -1498,7 +1504,7 @@ export class Backend {
14981504 }
14991505}
15001506
1501- export function resolveBackend ( config : CmsConfig ) {
1507+ export function resolveBackend ( config : CmsConfig , dispatch ?: any ) {
15021508 if ( ! config . backend . name ) {
15031509 throw new Error ( 'No backend defined in configuration' ) ;
15041510 }
@@ -1510,18 +1516,18 @@ export function resolveBackend(config: CmsConfig) {
15101516 if ( ! backend ) {
15111517 throw new Error ( `Backend not found: ${ name } ` ) ;
15121518 } else {
1513- return new Backend ( backend , { backendName : name , authStore, config } ) ;
1519+ return new Backend ( backend , { backendName : name , authStore, config, dispatch } ) ;
15141520 }
15151521}
15161522
15171523export const currentBackend = ( function ( ) {
15181524 let backend : Backend ;
15191525
1520- return ( config : CmsConfig ) => {
1526+ return ( config : CmsConfig , dispatch ?: any ) => {
15211527 if ( backend ) {
15221528 return backend ;
15231529 }
15241530
1525- return ( backend = resolveBackend ( config ) ) ;
1531+ return ( backend = resolveBackend ( config , dispatch ) ) ;
15261532 } ;
15271533} ) ( ) ;
0 commit comments