Skip to content

Commit

Permalink
fix: refactor generate preview url flow
Browse files Browse the repository at this point in the history
  • Loading branch information
shnsumit committed Jan 21, 2022
1 parent d74e7d7 commit b2b209d
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions src/services/repository/FileRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ public function regeneratePreviewUrls($order, $previewUrls, $queue=null) {
$service = new RegeneratePreviewUrls();
foreach ($order->files as $file) {

if (! ($file->hasDraft() || $file->isComplete())) continue;
if (! $file->isComplete()) continue;

if ($queue) {
$service->updateProgress($queue, $currentElement++ / $totalElements);
Expand All @@ -239,18 +239,7 @@ public function regeneratePreviewUrls($order, $previewUrls, $queue=null) {
$draft = Translations::$plugin->draftRepository->getDraftById($file->draftId, $file->targetSite);

if ($draft) {
$element = Craft::$app->getElements()->getElementById($file->elementId, null, $file->sourceSite);
$file->previewUrl = $previewUrls[$file->id] ?? $draft->url;
$file->source = Translations::$plugin->elementToFileConverter->convert(
$element,
Constants::FILE_FORMAT_XML,
[
'sourceSite' => $file->sourceSite,
'targetSite' => $file->targetSite,
'previewUrl' => $file->previewUrl,
'orderId' => $file->orderId,
]
);
}

Translations::$plugin->fileRepository->saveFile($file);
Expand Down

0 comments on commit b2b209d

Please sign in to comment.