single-item: fix post-processing (fix #470)
Signed-off-by: Varun Patil <varunpatil@ucla.edu>pull/563/head
parent
81708a4de7
commit
dae5785462
|
@ -215,10 +215,8 @@ class PublicController extends AuthPublicShareController
|
|||
}
|
||||
|
||||
/** Get initial state of single item */
|
||||
private function getSingleItemInitialState(\OCP\Files\File $file): string
|
||||
private function getSingleItemInitialState(\OCP\Files\File $file): array
|
||||
{
|
||||
$photo = $this->timelineQuery->getSingleItem($file->getId());
|
||||
|
||||
return json_encode($photo);
|
||||
return $this->timelineQuery->getSingleItem($file->getId());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -168,11 +168,15 @@ trait TimelineQueryDays
|
|||
// Apply all transformations
|
||||
$this->applyAllTransforms($queryTransforms, $query, false);
|
||||
|
||||
$cursor = $this->executeQueryWithCTEs($query);
|
||||
$rows = $cursor->fetchAll();
|
||||
$cursor->closeCursor();
|
||||
// FETCH all photos in this day
|
||||
$day = $this->executeQueryWithCTEs($query)->fetchAll();
|
||||
|
||||
return $this->processDay($rows);
|
||||
// Post process the day in-place
|
||||
foreach ($day as &$photo) {
|
||||
$this->processDayPhoto($photo);
|
||||
}
|
||||
|
||||
return $day;
|
||||
}
|
||||
|
||||
public function executeQueryWithCTEs(IQueryBuilder $query, string $psql = '')
|
||||
|
@ -253,9 +257,8 @@ trait TimelineQueryDays
|
|||
/**
|
||||
* Process the single day response.
|
||||
*/
|
||||
private function processDay(array $day)
|
||||
private function processDayPhoto(array &$row)
|
||||
{
|
||||
foreach ($day as &$row) {
|
||||
// Convert field types
|
||||
$row['fileid'] = (int) $row['fileid'];
|
||||
$row['isvideo'] = (int) $row['isvideo'];
|
||||
|
@ -281,9 +284,6 @@ trait TimelineQueryDays
|
|||
unset($row['datetaken']);
|
||||
}
|
||||
|
||||
return $day;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all folders inside a top folder.
|
||||
*/
|
||||
|
|
|
@ -25,7 +25,13 @@ trait TimelineQuerySingleItem
|
|||
// JOIN with mimetypes to get the mimetype
|
||||
$query->join('f', 'mimetypes', 'mimetypes', $query->expr()->eq('f.mimetype', 'mimetypes.id'));
|
||||
|
||||
return $query->executeQuery()->fetch();
|
||||
// FETCH the photo
|
||||
$photo = $query->executeQuery()->fetch();
|
||||
|
||||
// Post process the record
|
||||
$this->processDayPhoto($photo);
|
||||
|
||||
return $photo;
|
||||
}
|
||||
|
||||
public function getInfoById(int $id, bool $basic): array
|
||||
|
|
|
@ -1,7 +1,12 @@
|
|||
import { IDay } from "../../types";
|
||||
import { loadState } from "@nextcloud/initial-state";
|
||||
|
||||
const singleItem = JSON.parse(loadState("memories", "single_item", "{}"));
|
||||
let singleItem = null;
|
||||
try {
|
||||
singleItem = loadState("memories", "single_item", {});
|
||||
} catch (e) {
|
||||
console.error("Could not load single item", e);
|
||||
}
|
||||
|
||||
export function isSingleItem(): boolean {
|
||||
return Boolean(singleItem?.fileid);
|
||||
|
|
Loading…
Reference in New Issue