script_factory = $script_factory; $this->ate_jobs_repository = $ate_jobs_repository; $this->syncTrigger = $syncTrigger; $this->downloadQueue = $downloadQueue; } public function load() { $jobsToSync = $this->ate_jobs_repository->get_jobs_to_sync(); if ( $jobsToSync->count() || $this->syncTrigger->isSyncRequired() || $this->downloadQueue->count() ) { wp_register_script( self::JS_HANDLER, WPML_TM_URL . '/dist/js/ate/jobs-sync-app.js', [], WPML_TM_VERSION ); $jobIds = $jobsToSync->map_to_property( 'translate_job_id' ); // $isCompletedButNotDownloaded :: int->bool $isCompletedButNotDownloaded = pipe( [ ReturnedJobsQueue::class, 'getStatus' ], Relation::equals( ReturnedJobsQueue::STATUS_COMPLETED ) ); wp_localize_script( self::JS_HANDLER, self::JS_VARIABLE, [ 'jobIds' => $jobIds, 'completedInATE' => Fns::filter( $isCompletedButNotDownloaded, $jobIds ), 'strings' => [ 'tooltip' => __( 'Processing translation (could take a few minutes)', 'wpml-translation-management' ), 'status' => __( 'Processing translation', 'wpml-translation-management' ), ], ] ); wp_enqueue_script( self::JS_HANDLER ); $this->script_factory->localize_script( self::JS_HANDLER ); } } }