PhotoMosaic: keep queue ordered by date captured
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
|
||||
class PhotoMosaic
|
||||
{
|
||||
private $descending;
|
||||
private AssetIterator $iterator;
|
||||
private $layouts;
|
||||
private $processedImages = 0;
|
||||
@@ -19,6 +20,7 @@ class PhotoMosaic
|
||||
{
|
||||
$this->iterator = $iterator;
|
||||
$this->layouts = $this->availableLayouts();
|
||||
$this->descending = $iterator->isDescending();
|
||||
}
|
||||
|
||||
public function __destruct()
|
||||
@@ -143,8 +145,17 @@ class PhotoMosaic
|
||||
return -$priority_diff;
|
||||
}
|
||||
|
||||
private function orderQueueByDate()
|
||||
{
|
||||
usort($this->queue, function($a, $b) {
|
||||
$score = $a->getDateCaptured() <=> $b->getDateCaptured();
|
||||
return $score * ($this->descending ? -1 : 1);
|
||||
});
|
||||
}
|
||||
|
||||
private function pushToQueue(Image $image)
|
||||
{
|
||||
$this->queue[] = $image;
|
||||
$this->orderQueueByDate();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user