@@ -256,6 +256,7 @@ interface BackendOptions {
256256 backendName : string ;
257257 config : CmsConfig ;
258258 authStore ?: AuthStore ;
259+ dispatch ?: any ;
259260}
260261
261262export interface MediaFile {
@@ -291,6 +292,7 @@ interface ImplementationInitOptions {
291292 useWorkflow : boolean ;
292293 updateUserCredentials : ( credentials : Credentials ) => void ;
293294 initialWorkflowStatus : string ;
295+ dispatch ?: any ;
294296}
295297
296298type Implementation = BackendImplementation & {
@@ -354,14 +356,15 @@ export class Backend {
354356 user ?: User | null ;
355357 backupSync : AsyncLock ;
356358
357- constructor ( implementation : Implementation , { backendName, authStore, config } : BackendOptions ) {
359+ constructor ( implementation : Implementation , { backendName, authStore, config, dispatch } : BackendOptions ) {
358360 // We can't reliably run this on exit, so we do cleanup on load.
359361 this . deleteAnonymousBackup ( ) ;
360362 this . config = config ;
361363 this . implementation = implementation . init ( this . config , {
362364 useWorkflow : selectUseWorkflow ( this . config ) ,
363365 updateUserCredentials : this . updateUserCredentials ,
364366 initialWorkflowStatus : status . first ( ) ,
367+ dispatch,
365368 } ) ;
366369 this . backendName = backendName ;
367370 this . authStore = authStore ;
@@ -1369,7 +1372,7 @@ export class Backend {
13691372 }
13701373}
13711374
1372- export function resolveBackend ( config : CmsConfig ) {
1375+ export function resolveBackend ( config : CmsConfig , dispatch ?: any ) {
13731376 if ( ! config . backend . name ) {
13741377 throw new Error ( 'No backend defined in configuration' ) ;
13751378 }
@@ -1381,18 +1384,18 @@ export function resolveBackend(config: CmsConfig) {
13811384 if ( ! backend ) {
13821385 throw new Error ( `Backend not found: ${ name } ` ) ;
13831386 } else {
1384- return new Backend ( backend , { backendName : name , authStore, config } ) ;
1387+ return new Backend ( backend , { backendName : name , authStore, config, dispatch } ) ;
13851388 }
13861389}
13871390
13881391export const currentBackend = ( function ( ) {
13891392 let backend : Backend ;
13901393
1391- return ( config : CmsConfig ) => {
1394+ return ( config : CmsConfig , dispatch ?: any ) => {
13921395 if ( backend ) {
13931396 return backend ;
13941397 }
13951398
1396- return ( backend = resolveBackend ( config ) ) ;
1399+ return ( backend = resolveBackend ( config , dispatch ) ) ;
13971400 } ;
13981401} ) ( ) ;
0 commit comments