parent
51b096c194
commit
1cb428b489
|
@ -184,7 +184,7 @@ class DaysController extends GenericApiController
|
||||||
{
|
{
|
||||||
// Do not preload anything for native clients.
|
// Do not preload anything for native clients.
|
||||||
// Since the contents of preloads are trusted, clients will not load locals.
|
// Since the contents of preloads are trusted, clients will not load locals.
|
||||||
if (Util::callerIsNative()) {
|
if (Util::callerIsNative() || $this->noPreload()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -283,6 +283,11 @@ class DaysController extends GenericApiController
|
||||||
return null !== $this->request->getParam('hidden');
|
return null !== $this->request->getParam('hidden');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function noPreload()
|
||||||
|
{
|
||||||
|
return null !== $this->request->getParam('nopreload');
|
||||||
|
}
|
||||||
|
|
||||||
private function isMonthView()
|
private function isMonthView()
|
||||||
{
|
{
|
||||||
return null !== $this->request->getParam('monthView');
|
return null !== $this->request->getParam('monthView');
|
||||||
|
|
|
@ -227,6 +227,12 @@ trait TimelineQueryDays
|
||||||
}
|
}
|
||||||
unset($row['categoryid']);
|
unset($row['categoryid']);
|
||||||
|
|
||||||
|
// Get hidden field if present
|
||||||
|
if (\array_key_exists('hidden', $row) && $row['hidden']) {
|
||||||
|
$row['ishidden'] = 1;
|
||||||
|
}
|
||||||
|
unset($row['hidden']);
|
||||||
|
|
||||||
// All cluster transformations
|
// All cluster transformations
|
||||||
ClustersBackend\Manager::applyDayPostTransforms($this->request, $row);
|
ClustersBackend\Manager::applyDayPostTransforms($this->request, $row);
|
||||||
|
|
||||||
|
@ -239,11 +245,6 @@ trait TimelineQueryDays
|
||||||
// compute AUID and discard epoch and size
|
// compute AUID and discard epoch and size
|
||||||
$row['auid'] = Exif::getAUID($epoch, $size);
|
$row['auid'] = Exif::getAUID($epoch, $size);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get hidden field if present
|
|
||||||
if (\array_key_exists('hidden', $row)) {
|
|
||||||
$row['hidden'] = (bool) $row['hidden'];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -844,8 +844,16 @@ export default defineComponent({
|
||||||
},
|
},
|
||||||
|
|
||||||
/** API url for Day call */
|
/** API url for Day call */
|
||||||
getDayUrl(dayId: number | string) {
|
getDayUrl(dayIds: number[]) {
|
||||||
return API.Q(API.DAY(dayId), this.getQuery());
|
const query = this.getQuery();
|
||||||
|
|
||||||
|
// If any day in the fetch list has local images we need to fetch
|
||||||
|
// the remote hidden images for the merging to happen correctly
|
||||||
|
if (this.routeHasNative && dayIds.some((id) => this.heads[id]?.day?.haslocal)) {
|
||||||
|
query[DaysFilterType.HIDDEN] = '1';
|
||||||
|
}
|
||||||
|
|
||||||
|
return API.Q(API.DAY(dayIds.join(',')), query);
|
||||||
},
|
},
|
||||||
|
|
||||||
/** Fetch image data for one dayId */
|
/** Fetch image data for one dayId */
|
||||||
|
@ -858,7 +866,7 @@ export default defineComponent({
|
||||||
this.sizedDays.add(dayId);
|
this.sizedDays.add(dayId);
|
||||||
|
|
||||||
// Look for cache
|
// Look for cache
|
||||||
const cacheUrl = this.getDayUrl(dayId);
|
const cacheUrl = this.getDayUrl([dayId]);
|
||||||
try {
|
try {
|
||||||
const cache = await utils.getCachedData<IPhoto[]>(cacheUrl);
|
const cache = await utils.getCachedData<IPhoto[]>(cacheUrl);
|
||||||
if (cache) {
|
if (cache) {
|
||||||
|
@ -868,6 +876,7 @@ export default defineComponent({
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process the cache
|
// Process the cache
|
||||||
|
utils.removeHiddenPhotos(cache);
|
||||||
this.processDay(dayId, cache);
|
this.processDay(dayId, cache);
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
|
@ -900,8 +909,7 @@ export default defineComponent({
|
||||||
for (const dayId of dayIds) dayMap.set(dayId, []);
|
for (const dayId of dayIds) dayMap.set(dayId, []);
|
||||||
|
|
||||||
// Construct URL
|
// Construct URL
|
||||||
const dayStr = dayIds.join(',');
|
const url = this.getDayUrl(dayIds);
|
||||||
const url = this.getDayUrl(dayStr);
|
|
||||||
this.fetchDayQueue = [];
|
this.fetchDayQueue = [];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -911,7 +919,7 @@ export default defineComponent({
|
||||||
const data = res.data;
|
const data = res.data;
|
||||||
|
|
||||||
// Check if the state has changed
|
// Check if the state has changed
|
||||||
if (this.state !== startState || this.getDayUrl(dayStr) !== url) {
|
if (this.state !== startState || this.getDayUrl(dayIds) !== url) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -929,7 +937,7 @@ export default defineComponent({
|
||||||
// creates circular references which cannot be stringified
|
// creates circular references which cannot be stringified
|
||||||
for (const [dayId, photos] of dayMap) {
|
for (const [dayId, photos] of dayMap) {
|
||||||
if (photos.length === 0) continue;
|
if (photos.length === 0) continue;
|
||||||
utils.cacheData(this.getDayUrl(dayId), photos);
|
utils.cacheData(this.getDayUrl([dayId]), photos);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get local images if we are running in native environment.
|
// Get local images if we are running in native environment.
|
||||||
|
@ -946,6 +954,9 @@ export default defineComponent({
|
||||||
|
|
||||||
// Process each day as needed
|
// Process each day as needed
|
||||||
for (const [dayId, photos] of dayMap) {
|
for (const [dayId, photos] of dayMap) {
|
||||||
|
// Remove hidden photos
|
||||||
|
utils.removeHiddenPhotos(photos);
|
||||||
|
|
||||||
// Check if the response has any delta
|
// Check if the response has any delta
|
||||||
const head = this.heads[dayId];
|
const head = this.heads[dayId];
|
||||||
if (head?.day?.detail?.length === photos.length) {
|
if (head?.day?.detail?.length === photos.length) {
|
||||||
|
|
|
@ -34,6 +34,8 @@ export enum DaysFilterType {
|
||||||
RECURSIVE = 'recursive',
|
RECURSIVE = 'recursive',
|
||||||
MONTH_VIEW = 'monthView',
|
MONTH_VIEW = 'monthView',
|
||||||
REVERSE = 'reverse',
|
REVERSE = 'reverse',
|
||||||
|
HIDDEN = 'hidden',
|
||||||
|
NO_PRELOAD = 'nopreload',
|
||||||
}
|
}
|
||||||
|
|
||||||
export class API {
|
export class API {
|
||||||
|
|
|
@ -135,6 +135,18 @@ export function updatePhotoFromImageInfo(photo: IPhoto, imageInfo: IImageInfo) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove hidden photos from the list in place
|
||||||
|
* @param photos List of photos
|
||||||
|
*/
|
||||||
|
export function removeHiddenPhotos(photos: IPhoto[]) {
|
||||||
|
for (let i = photos.length - 1; i >= 0; i--) {
|
||||||
|
if (photos[i].ishidden) {
|
||||||
|
photos.splice(i, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the path of the folder on folders route
|
* Get the path of the folder on folders route
|
||||||
* This function does not check if this is the folder route
|
* This function does not check if this is the folder route
|
||||||
|
|
|
@ -80,6 +80,11 @@ export type IPhoto = {
|
||||||
isfavorite?: boolean;
|
isfavorite?: boolean;
|
||||||
/** Local file from native */
|
/** Local file from native */
|
||||||
islocal?: boolean;
|
islocal?: boolean;
|
||||||
|
/**
|
||||||
|
* Photo is hidden from timeline; discard immediately.
|
||||||
|
* This field exists so that we can merge with locals.
|
||||||
|
*/
|
||||||
|
ishidden?: boolean;
|
||||||
|
|
||||||
/** AUID of file (optional, NativeX) */
|
/** AUID of file (optional, NativeX) */
|
||||||
auid?: number;
|
auid?: number;
|
||||||
|
|
Loading…
Reference in New Issue