feat(web): Scroll to asset in gridview; increase gridview perf; reduce memory; scrollbar ticks in fixed position (#10646)
* Squashed
* Change strategy - now pre-measure buckets offscreen, so don't need to worry about sub-bucket scroll preservation
* Reduce jank on scroll, delay DOM updates until after scroll
* css opt, log measure time
* Trickle out queue while scrolling, flush when stopped
* yay
* Cleanup cleanup...
* everybody...
* everywhere...
* Clean up cleanup!
* Everybody do their share
* CLEANUP!
* package-lock ?
* dynamic measure, todo
* Fix web test
* type lint
* fix e2e
* e2e test
* Better scrollbar
* Tuning, and more tunables
* Tunable tweaks, more tunables
* Scrollbar dots and viewport events
* lint
* Tweaked tunnables, use requestIdleCallback for garbage tasks, bug fixes
* New tunables, and don't update url by default
* Bug fixes
* Bug fix, with debug
* Fix flickr, fix graybox bug, reduced debug
* Refactor/cleanup
* Fix
* naming
* Final cleanup
* review comment
* Forgot to update this after naming change
* scrubber works, with debug
* cleanup
* Rename scrollbar to scrubber
* rename to
* left over rename and change to previous album bar
* bugfix addassets, comments
* missing destroy(), cleanup
---------
Co-authored-by: Alex <alex.tran1502@gmail.com>
2024-08-21 22:15:21 -04:00
|
|
|
import { locale } from '$lib/stores/preferences.store';
|
2024-02-14 08:09:49 -05:00
|
|
|
import { getKey } from '$lib/utils';
|
feat(web): Scroll to asset in gridview; increase gridview perf; reduce memory; scrollbar ticks in fixed position (#10646)
* Squashed
* Change strategy - now pre-measure buckets offscreen, so don't need to worry about sub-bucket scroll preservation
* Reduce jank on scroll, delay DOM updates until after scroll
* css opt, log measure time
* Trickle out queue while scrolling, flush when stopped
* yay
* Cleanup cleanup...
* everybody...
* everywhere...
* Clean up cleanup!
* Everybody do their share
* CLEANUP!
* package-lock ?
* dynamic measure, todo
* Fix web test
* type lint
* fix e2e
* e2e test
* Better scrollbar
* Tuning, and more tunables
* Tunable tweaks, more tunables
* Scrollbar dots and viewport events
* lint
* Tweaked tunnables, use requestIdleCallback for garbage tasks, bug fixes
* New tunables, and don't update url by default
* Bug fixes
* Bug fix, with debug
* Fix flickr, fix graybox bug, reduced debug
* Refactor/cleanup
* Fix
* naming
* Final cleanup
* review comment
* Forgot to update this after naming change
* scrubber works, with debug
* cleanup
* Rename scrollbar to scrubber
* rename to
* left over rename and change to previous album bar
* bugfix addassets, comments
* missing destroy(), cleanup
---------
Co-authored-by: Alex <alex.tran1502@gmail.com>
2024-08-21 22:15:21 -04:00
|
|
|
import { AssetGridTaskManager } from '$lib/utils/asset-store-task-manager';
|
2024-09-05 07:29:07 -07:00
|
|
|
import { generateId } from '$lib/utils/generate-id';
|
feat(web): Scroll to asset in gridview; increase gridview perf; reduce memory; scrollbar ticks in fixed position (#10646)
* Squashed
* Change strategy - now pre-measure buckets offscreen, so don't need to worry about sub-bucket scroll preservation
* Reduce jank on scroll, delay DOM updates until after scroll
* css opt, log measure time
* Trickle out queue while scrolling, flush when stopped
* yay
* Cleanup cleanup...
* everybody...
* everywhere...
* Clean up cleanup!
* Everybody do their share
* CLEANUP!
* package-lock ?
* dynamic measure, todo
* Fix web test
* type lint
* fix e2e
* e2e test
* Better scrollbar
* Tuning, and more tunables
* Tunable tweaks, more tunables
* Scrollbar dots and viewport events
* lint
* Tweaked tunnables, use requestIdleCallback for garbage tasks, bug fixes
* New tunables, and don't update url by default
* Bug fixes
* Bug fix, with debug
* Fix flickr, fix graybox bug, reduced debug
* Refactor/cleanup
* Fix
* naming
* Final cleanup
* review comment
* Forgot to update this after naming change
* scrubber works, with debug
* cleanup
* Rename scrollbar to scrubber
* rename to
* left over rename and change to previous album bar
* bugfix addassets, comments
* missing destroy(), cleanup
---------
Co-authored-by: Alex <alex.tran1502@gmail.com>
2024-08-21 22:15:21 -04:00
|
|
|
import type { AssetGridRouteSearchParams } from '$lib/utils/navigation';
|
2025-02-21 12:20:25 +03:00
|
|
|
import { fromLocalDateTime, splitBucketIntoDateGroups, type DateGroup } from '$lib/utils/timeline-util';
|
feat(web): Scroll to asset in gridview; increase gridview perf; reduce memory; scrollbar ticks in fixed position (#10646)
* Squashed
* Change strategy - now pre-measure buckets offscreen, so don't need to worry about sub-bucket scroll preservation
* Reduce jank on scroll, delay DOM updates until after scroll
* css opt, log measure time
* Trickle out queue while scrolling, flush when stopped
* yay
* Cleanup cleanup...
* everybody...
* everywhere...
* Clean up cleanup!
* Everybody do their share
* CLEANUP!
* package-lock ?
* dynamic measure, todo
* Fix web test
* type lint
* fix e2e
* e2e test
* Better scrollbar
* Tuning, and more tunables
* Tunable tweaks, more tunables
* Scrollbar dots and viewport events
* lint
* Tweaked tunnables, use requestIdleCallback for garbage tasks, bug fixes
* New tunables, and don't update url by default
* Bug fixes
* Bug fix, with debug
* Fix flickr, fix graybox bug, reduced debug
* Refactor/cleanup
* Fix
* naming
* Final cleanup
* review comment
* Forgot to update this after naming change
* scrubber works, with debug
* cleanup
* Rename scrollbar to scrubber
* rename to
* left over rename and change to previous album bar
* bugfix addassets, comments
* missing destroy(), cleanup
---------
Co-authored-by: Alex <alex.tran1502@gmail.com>
2024-08-21 22:15:21 -04:00
|
|
|
import { TimeBucketSize, getAssetInfo, getTimeBucket, getTimeBuckets, type AssetResponseDto } from '@immich/sdk';
|
2023-10-06 15:48:11 -05:00
|
|
|
import { throttle } from 'lodash-es';
|
|
|
|
|
import { DateTime } from 'luxon';
|
2024-07-01 00:29:10 +02:00
|
|
|
import { t } from 'svelte-i18n';
|
|
|
|
|
import { get, writable, type Unsubscriber } from 'svelte/store';
|
2023-08-03 11:44:12 -04:00
|
|
|
import { handleError } from '../utils/handle-error';
|
2024-02-16 21:43:40 +01:00
|
|
|
import { websocketEvents } from './websocket';
|
2024-02-14 06:38:57 -08:00
|
|
|
type AssetApiGetTimeBucketsRequest = Parameters<typeof getTimeBuckets>[0];
|
2023-10-26 14:55:10 -04:00
|
|
|
export type AssetStoreOptions = Omit<AssetApiGetTimeBucketsRequest, 'size'>;
|
2023-08-02 21:57:11 -04:00
|
|
|
|
2023-08-03 11:44:12 -04:00
|
|
|
export interface Viewport {
|
|
|
|
|
width: number;
|
|
|
|
|
height: number;
|
|
|
|
|
}
|
feat(web): Scroll to asset in gridview; increase gridview perf; reduce memory; scrollbar ticks in fixed position (#10646)
* Squashed
* Change strategy - now pre-measure buckets offscreen, so don't need to worry about sub-bucket scroll preservation
* Reduce jank on scroll, delay DOM updates until after scroll
* css opt, log measure time
* Trickle out queue while scrolling, flush when stopped
* yay
* Cleanup cleanup...
* everybody...
* everywhere...
* Clean up cleanup!
* Everybody do their share
* CLEANUP!
* package-lock ?
* dynamic measure, todo
* Fix web test
* type lint
* fix e2e
* e2e test
* Better scrollbar
* Tuning, and more tunables
* Tunable tweaks, more tunables
* Scrollbar dots and viewport events
* lint
* Tweaked tunnables, use requestIdleCallback for garbage tasks, bug fixes
* New tunables, and don't update url by default
* Bug fixes
* Bug fix, with debug
* Fix flickr, fix graybox bug, reduced debug
* Refactor/cleanup
* Fix
* naming
* Final cleanup
* review comment
* Forgot to update this after naming change
* scrubber works, with debug
* cleanup
* Rename scrollbar to scrubber
* rename to
* left over rename and change to previous album bar
* bugfix addassets, comments
* missing destroy(), cleanup
---------
Co-authored-by: Alex <alex.tran1502@gmail.com>
2024-08-21 22:15:21 -04:00
|
|
|
export type ViewportXY = Viewport & {
|
|
|
|
|
x: number;
|
|
|
|
|
y: number;
|
|
|
|
|
};
|
2023-08-02 21:57:11 -04:00
|
|
|
|
2023-08-03 11:44:12 -04:00
|
|
|
interface AssetLookup {
|
|
|
|
|
bucket: AssetBucket;
|
|
|
|
|
bucketIndex: number;
|
|
|
|
|
assetIndex: number;
|
|
|
|
|
}
|
2023-08-02 21:57:11 -04:00
|
|
|
|
2023-08-03 11:44:12 -04:00
|
|
|
export class AssetBucket {
|
feat(web): Scroll to asset in gridview; increase gridview perf; reduce memory; scrollbar ticks in fixed position (#10646)
* Squashed
* Change strategy - now pre-measure buckets offscreen, so don't need to worry about sub-bucket scroll preservation
* Reduce jank on scroll, delay DOM updates until after scroll
* css opt, log measure time
* Trickle out queue while scrolling, flush when stopped
* yay
* Cleanup cleanup...
* everybody...
* everywhere...
* Clean up cleanup!
* Everybody do their share
* CLEANUP!
* package-lock ?
* dynamic measure, todo
* Fix web test
* type lint
* fix e2e
* e2e test
* Better scrollbar
* Tuning, and more tunables
* Tunable tweaks, more tunables
* Scrollbar dots and viewport events
* lint
* Tweaked tunnables, use requestIdleCallback for garbage tasks, bug fixes
* New tunables, and don't update url by default
* Bug fixes
* Bug fix, with debug
* Fix flickr, fix graybox bug, reduced debug
* Refactor/cleanup
* Fix
* naming
* Final cleanup
* review comment
* Forgot to update this after naming change
* scrubber works, with debug
* cleanup
* Rename scrollbar to scrubber
* rename to
* left over rename and change to previous album bar
* bugfix addassets, comments
* missing destroy(), cleanup
---------
Co-authored-by: Alex <alex.tran1502@gmail.com>
2024-08-21 22:15:21 -04:00
|
|
|
store!: AssetStore;
|
|
|
|
|
bucketDate!: string;
|
2023-08-03 11:44:12 -04:00
|
|
|
/**
|
|
|
|
|
* The DOM height of the bucket in pixel
|
|
|
|
|
* This value is first estimated by the number of asset and later is corrected as the user scroll
|
|
|
|
|
*/
|
feat(web): Scroll to asset in gridview; increase gridview perf; reduce memory; scrollbar ticks in fixed position (#10646)
* Squashed
* Change strategy - now pre-measure buckets offscreen, so don't need to worry about sub-bucket scroll preservation
* Reduce jank on scroll, delay DOM updates until after scroll
* css opt, log measure time
* Trickle out queue while scrolling, flush when stopped
* yay
* Cleanup cleanup...
* everybody...
* everywhere...
* Clean up cleanup!
* Everybody do their share
* CLEANUP!
* package-lock ?
* dynamic measure, todo
* Fix web test
* type lint
* fix e2e
* e2e test
* Better scrollbar
* Tuning, and more tunables
* Tunable tweaks, more tunables
* Scrollbar dots and viewport events
* lint
* Tweaked tunnables, use requestIdleCallback for garbage tasks, bug fixes
* New tunables, and don't update url by default
* Bug fixes
* Bug fix, with debug
* Fix flickr, fix graybox bug, reduced debug
* Refactor/cleanup
* Fix
* naming
* Final cleanup
* review comment
* Forgot to update this after naming change
* scrubber works, with debug
* cleanup
* Rename scrollbar to scrubber
* rename to
* left over rename and change to previous album bar
* bugfix addassets, comments
* missing destroy(), cleanup
---------
Co-authored-by: Alex <alex.tran1502@gmail.com>
2024-08-21 22:15:21 -04:00
|
|
|
bucketHeight: number = 0;
|
|
|
|
|
isBucketHeightActual: boolean = false;
|
|
|
|
|
bucketDateFormattted!: string;
|
|
|
|
|
bucketCount: number = 0;
|
|
|
|
|
assets: AssetResponseDto[] = [];
|
|
|
|
|
dateGroups: DateGroup[] = [];
|
|
|
|
|
cancelToken: AbortController | undefined;
|
|
|
|
|
/**
|
|
|
|
|
* Prevent this asset's load from being canceled; i.e. to force load of offscreen asset.
|
|
|
|
|
*/
|
|
|
|
|
isPreventCancel: boolean = false;
|
|
|
|
|
/**
|
|
|
|
|
* A promise that resolves once the bucket is loaded, and rejects if bucket is canceled.
|
|
|
|
|
*/
|
|
|
|
|
complete!: Promise<void>;
|
|
|
|
|
loading: boolean = false;
|
|
|
|
|
isLoaded: boolean = false;
|
|
|
|
|
intersecting: boolean = false;
|
|
|
|
|
measured: boolean = false;
|
|
|
|
|
measuredPromise!: Promise<void>;
|
|
|
|
|
|
|
|
|
|
constructor(props: Partial<AssetBucket> & { store: AssetStore; bucketDate: string }) {
|
|
|
|
|
Object.assign(this, props);
|
|
|
|
|
this.init();
|
|
|
|
|
}
|
2024-09-05 07:29:07 -07:00
|
|
|
/** The svelte key for this view model object */
|
|
|
|
|
get viewId() {
|
|
|
|
|
return this.store.viewId + '-' + this.bucketDate;
|
|
|
|
|
}
|
feat(web): Scroll to asset in gridview; increase gridview perf; reduce memory; scrollbar ticks in fixed position (#10646)
* Squashed
* Change strategy - now pre-measure buckets offscreen, so don't need to worry about sub-bucket scroll preservation
* Reduce jank on scroll, delay DOM updates until after scroll
* css opt, log measure time
* Trickle out queue while scrolling, flush when stopped
* yay
* Cleanup cleanup...
* everybody...
* everywhere...
* Clean up cleanup!
* Everybody do their share
* CLEANUP!
* package-lock ?
* dynamic measure, todo
* Fix web test
* type lint
* fix e2e
* e2e test
* Better scrollbar
* Tuning, and more tunables
* Tunable tweaks, more tunables
* Scrollbar dots and viewport events
* lint
* Tweaked tunnables, use requestIdleCallback for garbage tasks, bug fixes
* New tunables, and don't update url by default
* Bug fixes
* Bug fix, with debug
* Fix flickr, fix graybox bug, reduced debug
* Refactor/cleanup
* Fix
* naming
* Final cleanup
* review comment
* Forgot to update this after naming change
* scrubber works, with debug
* cleanup
* Rename scrollbar to scrubber
* rename to
* left over rename and change to previous album bar
* bugfix addassets, comments
* missing destroy(), cleanup
---------
Co-authored-by: Alex <alex.tran1502@gmail.com>
2024-08-21 22:15:21 -04:00
|
|
|
private init() {
|
|
|
|
|
// create a promise, and store its resolve/reject callbacks. The loadedSignal callback
|
|
|
|
|
// will be incoked when a bucket is loaded, fulfilling the promise. The canceledSignal
|
|
|
|
|
// callback will be called if the bucket is canceled before it was loaded, rejecting the
|
|
|
|
|
// promise.
|
|
|
|
|
this.complete = new Promise((resolve, reject) => {
|
|
|
|
|
this.loadedSignal = resolve;
|
|
|
|
|
this.canceledSignal = reject;
|
|
|
|
|
});
|
|
|
|
|
// if no-one waits on complete, and its rejected a uncaught rejection message is logged.
|
|
|
|
|
// We this message with an empty reject handler, since waiting on a bucket is optional.
|
|
|
|
|
this.complete.catch(() => void 0);
|
|
|
|
|
this.measuredPromise = new Promise((resolve) => {
|
|
|
|
|
this.measuredSignal = resolve;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
this.bucketDateFormattted = fromLocalDateTime(this.bucketDate)
|
|
|
|
|
.startOf('month')
|
|
|
|
|
.toJSDate()
|
|
|
|
|
.toLocaleString(get(locale), {
|
|
|
|
|
month: 'short',
|
|
|
|
|
year: 'numeric',
|
|
|
|
|
timeZone: 'UTC',
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private loadedSignal: (() => void) | undefined;
|
|
|
|
|
private canceledSignal: (() => void) | undefined;
|
|
|
|
|
measuredSignal: (() => void) | undefined;
|
|
|
|
|
|
|
|
|
|
cancel() {
|
|
|
|
|
if (this.isLoaded) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (this.isPreventCancel) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
this.cancelToken?.abort();
|
|
|
|
|
this.canceledSignal?.();
|
|
|
|
|
this.init();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
loaded() {
|
|
|
|
|
this.loadedSignal?.();
|
|
|
|
|
this.isLoaded = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
errored() {
|
|
|
|
|
this.canceledSignal?.();
|
|
|
|
|
this.init();
|
|
|
|
|
}
|
2023-08-01 04:27:56 +03:00
|
|
|
}
|
2022-09-04 08:34:39 -05:00
|
|
|
|
2023-10-06 15:48:11 -05:00
|
|
|
const isMismatched = (option: boolean | undefined, value: boolean): boolean =>
|
|
|
|
|
option === undefined ? false : option !== value;
|
|
|
|
|
|
2023-08-03 11:44:12 -04:00
|
|
|
const THUMBNAIL_HEIGHT = 235;
|
|
|
|
|
|
2023-10-06 15:48:11 -05:00
|
|
|
interface AddAsset {
|
|
|
|
|
type: 'add';
|
2024-03-15 17:11:29 +01:00
|
|
|
values: AssetResponseDto[];
|
2023-10-06 15:48:11 -05:00
|
|
|
}
|
|
|
|
|
|
2024-02-29 18:44:30 +01:00
|
|
|
interface UpdateAsset {
|
|
|
|
|
type: 'update';
|
2024-03-15 17:11:29 +01:00
|
|
|
values: AssetResponseDto[];
|
2024-02-29 18:44:30 +01:00
|
|
|
}
|
|
|
|
|
|
2023-10-06 15:48:11 -05:00
|
|
|
interface DeleteAsset {
|
|
|
|
|
type: 'delete';
|
2024-03-15 17:11:29 +01:00
|
|
|
values: string[];
|
2023-10-06 15:48:11 -05:00
|
|
|
}
|
|
|
|
|
|
2024-03-02 01:49:31 +01:00
|
|
|
interface TrashAssets {
|
2023-10-06 15:48:11 -05:00
|
|
|
type: 'trash';
|
2024-03-15 17:11:29 +01:00
|
|
|
values: string[];
|
2023-10-06 15:48:11 -05:00
|
|
|
}
|
feat(web): Scroll to asset in gridview; increase gridview perf; reduce memory; scrollbar ticks in fixed position (#10646)
* Squashed
* Change strategy - now pre-measure buckets offscreen, so don't need to worry about sub-bucket scroll preservation
* Reduce jank on scroll, delay DOM updates until after scroll
* css opt, log measure time
* Trickle out queue while scrolling, flush when stopped
* yay
* Cleanup cleanup...
* everybody...
* everywhere...
* Clean up cleanup!
* Everybody do their share
* CLEANUP!
* package-lock ?
* dynamic measure, todo
* Fix web test
* type lint
* fix e2e
* e2e test
* Better scrollbar
* Tuning, and more tunables
* Tunable tweaks, more tunables
* Scrollbar dots and viewport events
* lint
* Tweaked tunnables, use requestIdleCallback for garbage tasks, bug fixes
* New tunables, and don't update url by default
* Bug fixes
* Bug fix, with debug
* Fix flickr, fix graybox bug, reduced debug
* Refactor/cleanup
* Fix
* naming
* Final cleanup
* review comment
* Forgot to update this after naming change
* scrubber works, with debug
* cleanup
* Rename scrollbar to scrubber
* rename to
* left over rename and change to previous album bar
* bugfix addassets, comments
* missing destroy(), cleanup
---------
Co-authored-by: Alex <alex.tran1502@gmail.com>
2024-08-21 22:15:21 -04:00
|
|
|
interface UpdateStackAssets {
|
|
|
|
|
type: 'update_stack_assets';
|
|
|
|
|
values: string[];
|
|
|
|
|
}
|
2023-10-06 15:48:11 -05:00
|
|
|
|
2025-02-21 09:58:25 -06:00
|
|
|
export const photoViewerImgElement = writable<HTMLImageElement | null>(null);
|
2023-12-05 16:43:15 +01:00
|
|
|
|
feat(web): Scroll to asset in gridview; increase gridview perf; reduce memory; scrollbar ticks in fixed position (#10646)
* Squashed
* Change strategy - now pre-measure buckets offscreen, so don't need to worry about sub-bucket scroll preservation
* Reduce jank on scroll, delay DOM updates until after scroll
* css opt, log measure time
* Trickle out queue while scrolling, flush when stopped
* yay
* Cleanup cleanup...
* everybody...
* everywhere...
* Clean up cleanup!
* Everybody do their share
* CLEANUP!
* package-lock ?
* dynamic measure, todo
* Fix web test
* type lint
* fix e2e
* e2e test
* Better scrollbar
* Tuning, and more tunables
* Tunable tweaks, more tunables
* Scrollbar dots and viewport events
* lint
* Tweaked tunnables, use requestIdleCallback for garbage tasks, bug fixes
* New tunables, and don't update url by default
* Bug fixes
* Bug fix, with debug
* Fix flickr, fix graybox bug, reduced debug
* Refactor/cleanup
* Fix
* naming
* Final cleanup
* review comment
* Forgot to update this after naming change
* scrubber works, with debug
* cleanup
* Rename scrollbar to scrubber
* rename to
* left over rename and change to previous album bar
* bugfix addassets, comments
* missing destroy(), cleanup
---------
Co-authored-by: Alex <alex.tran1502@gmail.com>
2024-08-21 22:15:21 -04:00
|
|
|
type PendingChange = AddAsset | UpdateAsset | DeleteAsset | TrashAssets | UpdateStackAssets;
|
|
|
|
|
|
|
|
|
|
export type BucketListener = (
|
|
|
|
|
event:
|
|
|
|
|
| ViewPortEvent
|
|
|
|
|
| BucketLoadEvent
|
|
|
|
|
| BucketLoadedEvent
|
|
|
|
|
| BucketCancelEvent
|
|
|
|
|
| BucketHeightEvent
|
|
|
|
|
| DateGroupIntersecting
|
|
|
|
|
| DateGroupHeightEvent,
|
|
|
|
|
) => void;
|
|
|
|
|
|
|
|
|
|
type ViewPortEvent = {
|
|
|
|
|
type: 'viewport';
|
|
|
|
|
};
|
|
|
|
|
type BucketLoadEvent = {
|
|
|
|
|
type: 'load';
|
|
|
|
|
bucket: AssetBucket;
|
|
|
|
|
};
|
|
|
|
|
type BucketLoadedEvent = {
|
|
|
|
|
type: 'loaded';
|
|
|
|
|
bucket: AssetBucket;
|
|
|
|
|
};
|
|
|
|
|
type BucketCancelEvent = {
|
|
|
|
|
type: 'cancel';
|
|
|
|
|
bucket: AssetBucket;
|
|
|
|
|
};
|
|
|
|
|
type BucketHeightEvent = {
|
|
|
|
|
type: 'bucket-height';
|
|
|
|
|
bucket: AssetBucket;
|
|
|
|
|
delta: number;
|
|
|
|
|
};
|
|
|
|
|
type DateGroupIntersecting = {
|
|
|
|
|
type: 'intersecting';
|
|
|
|
|
bucket: AssetBucket;
|
|
|
|
|
dateGroup: DateGroup;
|
|
|
|
|
};
|
|
|
|
|
type DateGroupHeightEvent = {
|
|
|
|
|
type: 'height';
|
|
|
|
|
bucket: AssetBucket;
|
|
|
|
|
dateGroup: DateGroup;
|
|
|
|
|
delta: number;
|
|
|
|
|
height: number;
|
|
|
|
|
};
|
2023-10-06 15:48:11 -05:00
|
|
|
|
2023-08-03 11:44:12 -04:00
|
|
|
export class AssetStore {
|
|
|
|
|
private assetToBucket: Record<string, AssetLookup> = {};
|
2023-10-06 15:48:11 -05:00
|
|
|
private pendingChanges: PendingChange[] = [];
|
|
|
|
|
private unsubscribers: Unsubscriber[] = [];
|
2024-09-05 07:29:07 -07:00
|
|
|
private options!: AssetApiGetTimeBucketsRequest;
|
feat(web): Scroll to asset in gridview; increase gridview perf; reduce memory; scrollbar ticks in fixed position (#10646)
* Squashed
* Change strategy - now pre-measure buckets offscreen, so don't need to worry about sub-bucket scroll preservation
* Reduce jank on scroll, delay DOM updates until after scroll
* css opt, log measure time
* Trickle out queue while scrolling, flush when stopped
* yay
* Cleanup cleanup...
* everybody...
* everywhere...
* Clean up cleanup!
* Everybody do their share
* CLEANUP!
* package-lock ?
* dynamic measure, todo
* Fix web test
* type lint
* fix e2e
* e2e test
* Better scrollbar
* Tuning, and more tunables
* Tunable tweaks, more tunables
* Scrollbar dots and viewport events
* lint
* Tweaked tunnables, use requestIdleCallback for garbage tasks, bug fixes
* New tunables, and don't update url by default
* Bug fixes
* Bug fix, with debug
* Fix flickr, fix graybox bug, reduced debug
* Refactor/cleanup
* Fix
* naming
* Final cleanup
* review comment
* Forgot to update this after naming change
* scrubber works, with debug
* cleanup
* Rename scrollbar to scrubber
* rename to
* left over rename and change to previous album bar
* bugfix addassets, comments
* missing destroy(), cleanup
---------
Co-authored-by: Alex <alex.tran1502@gmail.com>
2024-08-21 22:15:21 -04:00
|
|
|
private viewport: Viewport = {
|
|
|
|
|
height: 0,
|
|
|
|
|
width: 0,
|
|
|
|
|
};
|
|
|
|
|
private initializedSignal!: () => void;
|
|
|
|
|
private store$ = writable(this);
|
2024-09-05 07:29:07 -07:00
|
|
|
/** The svelte key for this view model object */
|
|
|
|
|
viewId = generateId();
|
2023-08-03 11:44:12 -04:00
|
|
|
|
feat(web): Scroll to asset in gridview; increase gridview perf; reduce memory; scrollbar ticks in fixed position (#10646)
* Squashed
* Change strategy - now pre-measure buckets offscreen, so don't need to worry about sub-bucket scroll preservation
* Reduce jank on scroll, delay DOM updates until after scroll
* css opt, log measure time
* Trickle out queue while scrolling, flush when stopped
* yay
* Cleanup cleanup...
* everybody...
* everywhere...
* Clean up cleanup!
* Everybody do their share
* CLEANUP!
* package-lock ?
* dynamic measure, todo
* Fix web test
* type lint
* fix e2e
* e2e test
* Better scrollbar
* Tuning, and more tunables
* Tunable tweaks, more tunables
* Scrollbar dots and viewport events
* lint
* Tweaked tunnables, use requestIdleCallback for garbage tasks, bug fixes
* New tunables, and don't update url by default
* Bug fixes
* Bug fix, with debug
* Fix flickr, fix graybox bug, reduced debug
* Refactor/cleanup
* Fix
* naming
* Final cleanup
* review comment
* Forgot to update this after naming change
* scrubber works, with debug
* cleanup
* Rename scrollbar to scrubber
* rename to
* left over rename and change to previous album bar
* bugfix addassets, comments
* missing destroy(), cleanup
---------
Co-authored-by: Alex <alex.tran1502@gmail.com>
2024-08-21 22:15:21 -04:00
|
|
|
lastScrollTime: number = 0;
|
|
|
|
|
subscribe = this.store$.subscribe;
|
|
|
|
|
/**
|
|
|
|
|
* A promise that resolves once the store is initialized.
|
|
|
|
|
*/
|
|
|
|
|
complete!: Promise<void>;
|
2024-09-05 07:29:07 -07:00
|
|
|
taskManager = new AssetGridTaskManager(this);
|
2023-09-01 19:12:09 +02:00
|
|
|
initialized = false;
|
2023-08-03 11:44:12 -04:00
|
|
|
timelineHeight = 0;
|
|
|
|
|
buckets: AssetBucket[] = [];
|
|
|
|
|
assets: AssetResponseDto[] = [];
|
2023-08-11 12:00:51 -04:00
|
|
|
albumAssets: Set<string> = new Set();
|
feat(web): Scroll to asset in gridview; increase gridview perf; reduce memory; scrollbar ticks in fixed position (#10646)
* Squashed
* Change strategy - now pre-measure buckets offscreen, so don't need to worry about sub-bucket scroll preservation
* Reduce jank on scroll, delay DOM updates until after scroll
* css opt, log measure time
* Trickle out queue while scrolling, flush when stopped
* yay
* Cleanup cleanup...
* everybody...
* everywhere...
* Clean up cleanup!
* Everybody do their share
* CLEANUP!
* package-lock ?
* dynamic measure, todo
* Fix web test
* type lint
* fix e2e
* e2e test
* Better scrollbar
* Tuning, and more tunables
* Tunable tweaks, more tunables
* Scrollbar dots and viewport events
* lint
* Tweaked tunnables, use requestIdleCallback for garbage tasks, bug fixes
* New tunables, and don't update url by default
* Bug fixes
* Bug fix, with debug
* Fix flickr, fix graybox bug, reduced debug
* Refactor/cleanup
* Fix
* naming
* Final cleanup
* review comment
* Forgot to update this after naming change
* scrubber works, with debug
* cleanup
* Rename scrollbar to scrubber
* rename to
* left over rename and change to previous album bar
* bugfix addassets, comments
* missing destroy(), cleanup
---------
Co-authored-by: Alex <alex.tran1502@gmail.com>
2024-08-21 22:15:21 -04:00
|
|
|
pendingScrollBucket: AssetBucket | undefined;
|
|
|
|
|
pendingScrollAssetId: string | undefined;
|
2025-02-21 07:38:12 +03:00
|
|
|
maxBucketAssets = 0;
|
feat(web): Scroll to asset in gridview; increase gridview perf; reduce memory; scrollbar ticks in fixed position (#10646)
* Squashed
* Change strategy - now pre-measure buckets offscreen, so don't need to worry about sub-bucket scroll preservation
* Reduce jank on scroll, delay DOM updates until after scroll
* css opt, log measure time
* Trickle out queue while scrolling, flush when stopped
* yay
* Cleanup cleanup...
* everybody...
* everywhere...
* Clean up cleanup!
* Everybody do their share
* CLEANUP!
* package-lock ?
* dynamic measure, todo
* Fix web test
* type lint
* fix e2e
* e2e test
* Better scrollbar
* Tuning, and more tunables
* Tunable tweaks, more tunables
* Scrollbar dots and viewport events
* lint
* Tweaked tunnables, use requestIdleCallback for garbage tasks, bug fixes
* New tunables, and don't update url by default
* Bug fixes
* Bug fix, with debug
* Fix flickr, fix graybox bug, reduced debug
* Refactor/cleanup
* Fix
* naming
* Final cleanup
* review comment
* Forgot to update this after naming change
* scrubber works, with debug
* cleanup
* Rename scrollbar to scrubber
* rename to
* left over rename and change to previous album bar
* bugfix addassets, comments
* missing destroy(), cleanup
---------
Co-authored-by: Alex <alex.tran1502@gmail.com>
2024-08-21 22:15:21 -04:00
|
|
|
|
|
|
|
|
listeners: BucketListener[] = [];
|
2023-08-03 11:44:12 -04:00
|
|
|
|
2023-11-27 11:42:04 -05:00
|
|
|
constructor(
|
|
|
|
|
options: AssetStoreOptions,
|
|
|
|
|
private albumId?: string,
|
|
|
|
|
) {
|
2024-09-05 07:29:07 -07:00
|
|
|
this.setOptions(options);
|
|
|
|
|
this.createInitializationSignal();
|
|
|
|
|
this.store$.set(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private setOptions(options: AssetStoreOptions) {
|
2023-10-26 14:55:10 -04:00
|
|
|
this.options = { ...options, size: TimeBucketSize.Month };
|
2024-09-05 07:29:07 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private createInitializationSignal() {
|
feat(web): Scroll to asset in gridview; increase gridview perf; reduce memory; scrollbar ticks in fixed position (#10646)
* Squashed
* Change strategy - now pre-measure buckets offscreen, so don't need to worry about sub-bucket scroll preservation
* Reduce jank on scroll, delay DOM updates until after scroll
* css opt, log measure time
* Trickle out queue while scrolling, flush when stopped
* yay
* Cleanup cleanup...
* everybody...
* everywhere...
* Clean up cleanup!
* Everybody do their share
* CLEANUP!
* package-lock ?
* dynamic measure, todo
* Fix web test
* type lint
* fix e2e
* e2e test
* Better scrollbar
* Tuning, and more tunables
* Tunable tweaks, more tunables
* Scrollbar dots and viewport events
* lint
* Tweaked tunnables, use requestIdleCallback for garbage tasks, bug fixes
* New tunables, and don't update url by default
* Bug fixes
* Bug fix, with debug
* Fix flickr, fix graybox bug, reduced debug
* Refactor/cleanup
* Fix
* naming
* Final cleanup
* review comment
* Forgot to update this after naming change
* scrubber works, with debug
* cleanup
* Rename scrollbar to scrubber
* rename to
* left over rename and change to previous album bar
* bugfix addassets, comments
* missing destroy(), cleanup
---------
Co-authored-by: Alex <alex.tran1502@gmail.com>
2024-08-21 22:15:21 -04:00
|
|
|
// create a promise, and store its resolve callbacks. The initializedSignal callback
|
|
|
|
|
// will be invoked when a the assetstore is initialized.
|
|
|
|
|
this.complete = new Promise((resolve) => {
|
|
|
|
|
this.initializedSignal = resolve;
|
|
|
|
|
});
|
2024-09-05 07:29:07 -07:00
|
|
|
// uncaught rejection go away
|
|
|
|
|
this.complete.catch(() => void 0);
|
2023-08-03 11:44:12 -04:00
|
|
|
}
|
|
|
|
|
|
2023-12-04 20:29:35 -05:00
|
|
|
private addPendingChanges(...changes: PendingChange[]) {
|
|
|
|
|
// prevent websocket events from happening before local client events
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
this.pendingChanges.push(...changes);
|
|
|
|
|
this.processPendingChanges();
|
2024-02-02 04:18:00 +01:00
|
|
|
}, 1000);
|
2023-12-04 20:29:35 -05:00
|
|
|
}
|
|
|
|
|
|
2023-10-06 15:48:11 -05:00
|
|
|
connect() {
|
|
|
|
|
this.unsubscribers.push(
|
2024-08-27 22:31:32 -05:00
|
|
|
websocketEvents.on('on_upload_success', (_) => {
|
|
|
|
|
// TODO!: Temporarily disable to avoid flashing effect of the timeline
|
|
|
|
|
// this.addPendingChanges({ type: 'add', values: [asset] });
|
2023-10-06 15:48:11 -05:00
|
|
|
}),
|
2024-02-16 21:43:40 +01:00
|
|
|
websocketEvents.on('on_asset_trash', (ids) => {
|
2024-03-15 17:11:29 +01:00
|
|
|
this.addPendingChanges({ type: 'trash', values: ids });
|
2023-10-06 15:48:11 -05:00
|
|
|
}),
|
2024-02-29 18:44:30 +01:00
|
|
|
websocketEvents.on('on_asset_update', (asset) => {
|
2024-03-15 17:11:29 +01:00
|
|
|
this.addPendingChanges({ type: 'update', values: [asset] });
|
2024-02-29 18:44:30 +01:00
|
|
|
}),
|
2024-02-16 21:43:40 +01:00
|
|
|
websocketEvents.on('on_asset_delete', (id: string) => {
|
2024-03-15 17:11:29 +01:00
|
|
|
this.addPendingChanges({ type: 'delete', values: [id] });
|
2023-10-06 15:48:11 -05:00
|
|
|
}),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
disconnect() {
|
|
|
|
|
for (const unsubscribe of this.unsubscribers) {
|
|
|
|
|
unsubscribe();
|
|
|
|
|
}
|
2024-09-05 07:29:07 -07:00
|
|
|
this.unsubscribers = [];
|
2023-10-06 15:48:11 -05:00
|
|
|
}
|
|
|
|
|
|
2024-03-15 17:11:29 +01:00
|
|
|
private getPendingChangeBatches() {
|
|
|
|
|
const batches: PendingChange[] = [];
|
|
|
|
|
let batch: PendingChange | undefined;
|
|
|
|
|
|
|
|
|
|
for (const { type, values: _values } of this.pendingChanges) {
|
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
|
|
|
const values = _values as any[];
|
|
|
|
|
|
|
|
|
|
if (batch && batch.type !== type) {
|
|
|
|
|
batches.push(batch);
|
|
|
|
|
batch = undefined;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (batch) {
|
|
|
|
|
batch.values.push(...values);
|
|
|
|
|
} else {
|
|
|
|
|
batch = { type, values };
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (batch) {
|
|
|
|
|
batches.push(batch);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return batches;
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-06 15:48:11 -05:00
|
|
|
processPendingChanges = throttle(() => {
|
2024-03-15 17:11:29 +01:00
|
|
|
for (const { type, values } of this.getPendingChangeBatches()) {
|
2023-10-06 15:48:11 -05:00
|
|
|
switch (type) {
|
2024-02-02 04:18:00 +01:00
|
|
|
case 'add': {
|
2024-03-15 17:11:29 +01:00
|
|
|
this.addAssets(values);
|
2023-10-06 15:48:11 -05:00
|
|
|
break;
|
2024-02-02 04:18:00 +01:00
|
|
|
}
|
2023-10-06 15:48:11 -05:00
|
|
|
|
2024-02-29 18:44:30 +01:00
|
|
|
case 'update': {
|
2024-03-15 17:11:29 +01:00
|
|
|
this.updateAssets(values);
|
2024-02-29 18:44:30 +01:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-02 04:18:00 +01:00
|
|
|
case 'trash': {
|
2023-10-06 15:48:11 -05:00
|
|
|
if (!this.options.isTrashed) {
|
2024-03-15 17:11:29 +01:00
|
|
|
this.removeAssets(values);
|
2023-10-06 15:48:11 -05:00
|
|
|
}
|
|
|
|
|
break;
|
2024-02-02 04:18:00 +01:00
|
|
|
}
|
2023-10-06 15:48:11 -05:00
|
|
|
|
2024-02-02 04:18:00 +01:00
|
|
|
case 'delete': {
|
2024-03-15 17:11:29 +01:00
|
|
|
this.removeAssets(values);
|
2023-10-06 15:48:11 -05:00
|
|
|
break;
|
2024-02-02 04:18:00 +01:00
|
|
|
}
|
2023-10-06 15:48:11 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.pendingChanges = [];
|
|
|
|
|
this.emit(true);
|
2024-03-15 17:11:29 +01:00
|
|
|
}, 2500);
|
2023-10-06 15:48:11 -05:00
|
|
|
|
feat(web): Scroll to asset in gridview; increase gridview perf; reduce memory; scrollbar ticks in fixed position (#10646)
* Squashed
* Change strategy - now pre-measure buckets offscreen, so don't need to worry about sub-bucket scroll preservation
* Reduce jank on scroll, delay DOM updates until after scroll
* css opt, log measure time
* Trickle out queue while scrolling, flush when stopped
* yay
* Cleanup cleanup...
* everybody...
* everywhere...
* Clean up cleanup!
* Everybody do their share
* CLEANUP!
* package-lock ?
* dynamic measure, todo
* Fix web test
* type lint
* fix e2e
* e2e test
* Better scrollbar
* Tuning, and more tunables
* Tunable tweaks, more tunables
* Scrollbar dots and viewport events
* lint
* Tweaked tunnables, use requestIdleCallback for garbage tasks, bug fixes
* New tunables, and don't update url by default
* Bug fixes
* Bug fix, with debug
* Fix flickr, fix graybox bug, reduced debug
* Refactor/cleanup
* Fix
* naming
* Final cleanup
* review comment
* Forgot to update this after naming change
* scrubber works, with debug
* cleanup
* Rename scrollbar to scrubber
* rename to
* left over rename and change to previous album bar
* bugfix addassets, comments
* missing destroy(), cleanup
---------
Co-authored-by: Alex <alex.tran1502@gmail.com>
2024-08-21 22:15:21 -04:00
|
|
|
addListener(bucketListener: BucketListener) {
|
|
|
|
|
this.listeners.push(bucketListener);
|
|
|
|
|
}
|
|
|
|
|
removeListener(bucketListener: BucketListener) {
|
|
|
|
|
this.listeners = this.listeners.filter((l) => l != bucketListener);
|
|
|
|
|
}
|
|
|
|
|
private notifyListeners(
|
|
|
|
|
event:
|
|
|
|
|
| ViewPortEvent
|
|
|
|
|
| BucketLoadEvent
|
|
|
|
|
| BucketLoadedEvent
|
|
|
|
|
| BucketCancelEvent
|
|
|
|
|
| BucketHeightEvent
|
|
|
|
|
| DateGroupIntersecting
|
|
|
|
|
| DateGroupHeightEvent,
|
|
|
|
|
) {
|
|
|
|
|
for (const fn of this.listeners) {
|
|
|
|
|
fn(event);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
async init({ bucketListener }: { bucketListener?: BucketListener } = {}) {
|
|
|
|
|
if (this.initialized) {
|
|
|
|
|
throw 'Can only init once';
|
|
|
|
|
}
|
|
|
|
|
if (bucketListener) {
|
|
|
|
|
this.addListener(bucketListener);
|
|
|
|
|
}
|
2024-09-05 07:29:07 -07:00
|
|
|
await this.initialiazeTimeBuckets();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async initialiazeTimeBuckets() {
|
2023-08-11 12:00:51 -04:00
|
|
|
this.timelineHeight = 0;
|
|
|
|
|
this.buckets = [];
|
|
|
|
|
this.assets = [];
|
|
|
|
|
this.assetToBucket = {};
|
|
|
|
|
this.albumAssets = new Set();
|
|
|
|
|
|
2024-04-24 15:24:19 -04:00
|
|
|
const timebuckets = await getTimeBuckets({
|
2024-03-14 17:45:03 +01:00
|
|
|
...this.options,
|
|
|
|
|
key: getKey(),
|
|
|
|
|
});
|
feat(web): Scroll to asset in gridview; increase gridview perf; reduce memory; scrollbar ticks in fixed position (#10646)
* Squashed
* Change strategy - now pre-measure buckets offscreen, so don't need to worry about sub-bucket scroll preservation
* Reduce jank on scroll, delay DOM updates until after scroll
* css opt, log measure time
* Trickle out queue while scrolling, flush when stopped
* yay
* Cleanup cleanup...
* everybody...
* everywhere...
* Clean up cleanup!
* Everybody do their share
* CLEANUP!
* package-lock ?
* dynamic measure, todo
* Fix web test
* type lint
* fix e2e
* e2e test
* Better scrollbar
* Tuning, and more tunables
* Tunable tweaks, more tunables
* Scrollbar dots and viewport events
* lint
* Tweaked tunnables, use requestIdleCallback for garbage tasks, bug fixes
* New tunables, and don't update url by default
* Bug fixes
* Bug fix, with debug
* Fix flickr, fix graybox bug, reduced debug
* Refactor/cleanup
* Fix
* naming
* Final cleanup
* review comment
* Forgot to update this after naming change
* scrubber works, with debug
* cleanup
* Rename scrollbar to scrubber
* rename to
* left over rename and change to previous album bar
* bugfix addassets, comments
* missing destroy(), cleanup
---------
Co-authored-by: Alex <alex.tran1502@gmail.com>
2024-08-21 22:15:21 -04:00
|
|
|
this.buckets = timebuckets.map(
|
|
|
|
|
(bucket) => new AssetBucket({ store: this, bucketDate: bucket.timeBucket, bucketCount: bucket.count }),
|
|
|
|
|
);
|
|
|
|
|
this.initializedSignal();
|
2023-09-01 19:12:09 +02:00
|
|
|
this.initialized = true;
|
feat(web): Scroll to asset in gridview; increase gridview perf; reduce memory; scrollbar ticks in fixed position (#10646)
* Squashed
* Change strategy - now pre-measure buckets offscreen, so don't need to worry about sub-bucket scroll preservation
* Reduce jank on scroll, delay DOM updates until after scroll
* css opt, log measure time
* Trickle out queue while scrolling, flush when stopped
* yay
* Cleanup cleanup...
* everybody...
* everywhere...
* Clean up cleanup!
* Everybody do their share
* CLEANUP!
* package-lock ?
* dynamic measure, todo
* Fix web test
* type lint
* fix e2e
* e2e test
* Better scrollbar
* Tuning, and more tunables
* Tunable tweaks, more tunables
* Scrollbar dots and viewport events
* lint
* Tweaked tunnables, use requestIdleCallback for garbage tasks, bug fixes
* New tunables, and don't update url by default
* Bug fixes
* Bug fix, with debug
* Fix flickr, fix graybox bug, reduced debug
* Refactor/cleanup
* Fix
* naming
* Final cleanup
* review comment
* Forgot to update this after naming change
* scrubber works, with debug
* cleanup
* Rename scrollbar to scrubber
* rename to
* left over rename and change to previous album bar
* bugfix addassets, comments
* missing destroy(), cleanup
---------
Co-authored-by: Alex <alex.tran1502@gmail.com>
2024-08-21 22:15:21 -04:00
|
|
|
}
|
2023-09-01 19:12:09 +02:00
|
|
|
|
2024-09-05 07:29:07 -07:00
|
|
|
async updateOptions(options: AssetStoreOptions) {
|
2024-12-27 11:16:07 -05:00
|
|
|
// Make sure to re-initialize if the personId changes
|
|
|
|
|
const needsReinitializing = this.options.personId !== options.personId;
|
|
|
|
|
if (!this.initialized && !needsReinitializing) {
|
2024-09-05 07:29:07 -07:00
|
|
|
this.setOptions(options);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// TODO: don't call updateObjects frequently after
|
|
|
|
|
// init - cancelation of the initialize tasks isn't
|
|
|
|
|
// performed right now, and will cause issues if
|
|
|
|
|
// multiple updateOptions() calls are interleved.
|
|
|
|
|
await this.complete;
|
|
|
|
|
this.taskManager.destroy();
|
|
|
|
|
this.taskManager = new AssetGridTaskManager(this);
|
|
|
|
|
this.initialized = false;
|
|
|
|
|
this.viewId = generateId();
|
|
|
|
|
this.createInitializationSignal();
|
|
|
|
|
this.setOptions(options);
|
|
|
|
|
await this.initialiazeTimeBuckets();
|
|
|
|
|
this.emit(true);
|
|
|
|
|
await this.initialLayout(true);
|
|
|
|
|
}
|
|
|
|
|
|
feat(web): Scroll to asset in gridview; increase gridview perf; reduce memory; scrollbar ticks in fixed position (#10646)
* Squashed
* Change strategy - now pre-measure buckets offscreen, so don't need to worry about sub-bucket scroll preservation
* Reduce jank on scroll, delay DOM updates until after scroll
* css opt, log measure time
* Trickle out queue while scrolling, flush when stopped
* yay
* Cleanup cleanup...
* everybody...
* everywhere...
* Clean up cleanup!
* Everybody do their share
* CLEANUP!
* package-lock ?
* dynamic measure, todo
* Fix web test
* type lint
* fix e2e
* e2e test
* Better scrollbar
* Tuning, and more tunables
* Tunable tweaks, more tunables
* Scrollbar dots and viewport events
* lint
* Tweaked tunnables, use requestIdleCallback for garbage tasks, bug fixes
* New tunables, and don't update url by default
* Bug fixes
* Bug fix, with debug
* Fix flickr, fix graybox bug, reduced debug
* Refactor/cleanup
* Fix
* naming
* Final cleanup
* review comment
* Forgot to update this after naming change
* scrubber works, with debug
* cleanup
* Rename scrollbar to scrubber
* rename to
* left over rename and change to previous album bar
* bugfix addassets, comments
* missing destroy(), cleanup
---------
Co-authored-by: Alex <alex.tran1502@gmail.com>
2024-08-21 22:15:21 -04:00
|
|
|
public destroy() {
|
|
|
|
|
this.taskManager.destroy();
|
|
|
|
|
this.listeners = [];
|
|
|
|
|
this.initialized = false;
|
|
|
|
|
}
|
2024-04-24 15:24:19 -04:00
|
|
|
|
feat(web): Scroll to asset in gridview; increase gridview perf; reduce memory; scrollbar ticks in fixed position (#10646)
* Squashed
* Change strategy - now pre-measure buckets offscreen, so don't need to worry about sub-bucket scroll preservation
* Reduce jank on scroll, delay DOM updates until after scroll
* css opt, log measure time
* Trickle out queue while scrolling, flush when stopped
* yay
* Cleanup cleanup...
* everybody...
* everywhere...
* Clean up cleanup!
* Everybody do their share
* CLEANUP!
* package-lock ?
* dynamic measure, todo
* Fix web test
* type lint
* fix e2e
* e2e test
* Better scrollbar
* Tuning, and more tunables
* Tunable tweaks, more tunables
* Scrollbar dots and viewport events
* lint
* Tweaked tunnables, use requestIdleCallback for garbage tasks, bug fixes
* New tunables, and don't update url by default
* Bug fixes
* Bug fix, with debug
* Fix flickr, fix graybox bug, reduced debug
* Refactor/cleanup
* Fix
* naming
* Final cleanup
* review comment
* Forgot to update this after naming change
* scrubber works, with debug
* cleanup
* Rename scrollbar to scrubber
* rename to
* left over rename and change to previous album bar
* bugfix addassets, comments
* missing destroy(), cleanup
---------
Co-authored-by: Alex <alex.tran1502@gmail.com>
2024-08-21 22:15:21 -04:00
|
|
|
async updateViewport(viewport: Viewport, force?: boolean) {
|
|
|
|
|
if (viewport.height === 0 && viewport.width === 0) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (!force && this.viewport.height === viewport.height && this.viewport.width === viewport.width) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2024-09-05 07:29:07 -07:00
|
|
|
await this.complete;
|
feat(web): Scroll to asset in gridview; increase gridview perf; reduce memory; scrollbar ticks in fixed position (#10646)
* Squashed
* Change strategy - now pre-measure buckets offscreen, so don't need to worry about sub-bucket scroll preservation
* Reduce jank on scroll, delay DOM updates until after scroll
* css opt, log measure time
* Trickle out queue while scrolling, flush when stopped
* yay
* Cleanup cleanup...
* everybody...
* everywhere...
* Clean up cleanup!
* Everybody do their share
* CLEANUP!
* package-lock ?
* dynamic measure, todo
* Fix web test
* type lint
* fix e2e
* e2e test
* Better scrollbar
* Tuning, and more tunables
* Tunable tweaks, more tunables
* Scrollbar dots and viewport events
* lint
* Tweaked tunnables, use requestIdleCallback for garbage tasks, bug fixes
* New tunables, and don't update url by default
* Bug fixes
* Bug fix, with debug
* Fix flickr, fix graybox bug, reduced debug
* Refactor/cleanup
* Fix
* naming
* Final cleanup
* review comment
* Forgot to update this after naming change
* scrubber works, with debug
* cleanup
* Rename scrollbar to scrubber
* rename to
* left over rename and change to previous album bar
* bugfix addassets, comments
* missing destroy(), cleanup
---------
Co-authored-by: Alex <alex.tran1502@gmail.com>
2024-08-21 22:15:21 -04:00
|
|
|
// changing width invalidates the actual height, and needs to be remeasured, since width changes causes
|
|
|
|
|
// layout reflows.
|
|
|
|
|
const changedWidth = this.viewport.width != viewport.width;
|
|
|
|
|
this.viewport = { ...viewport };
|
2024-09-05 07:29:07 -07:00
|
|
|
await this.initialLayout(changedWidth);
|
|
|
|
|
}
|
2024-04-24 15:24:19 -04:00
|
|
|
|
2024-09-05 07:29:07 -07:00
|
|
|
private async initialLayout(changedWidth: boolean) {
|
2024-04-24 15:24:19 -04:00
|
|
|
for (const bucket of this.buckets) {
|
2025-02-22 21:16:06 +03:00
|
|
|
await this.updateGeometry(bucket, changedWidth);
|
2024-04-24 15:24:19 -04:00
|
|
|
}
|
2024-03-05 16:43:24 +01:00
|
|
|
this.timelineHeight = this.buckets.reduce((accumulator, b) => accumulator + b.bucketHeight, 0);
|
2024-03-03 17:12:52 -05:00
|
|
|
|
2024-03-05 16:43:24 +01:00
|
|
|
const loaders = [];
|
feat(web): Scroll to asset in gridview; increase gridview perf; reduce memory; scrollbar ticks in fixed position (#10646)
* Squashed
* Change strategy - now pre-measure buckets offscreen, so don't need to worry about sub-bucket scroll preservation
* Reduce jank on scroll, delay DOM updates until after scroll
* css opt, log measure time
* Trickle out queue while scrolling, flush when stopped
* yay
* Cleanup cleanup...
* everybody...
* everywhere...
* Clean up cleanup!
* Everybody do their share
* CLEANUP!
* package-lock ?
* dynamic measure, todo
* Fix web test
* type lint
* fix e2e
* e2e test
* Better scrollbar
* Tuning, and more tunables
* Tunable tweaks, more tunables
* Scrollbar dots and viewport events
* lint
* Tweaked tunnables, use requestIdleCallback for garbage tasks, bug fixes
* New tunables, and don't update url by default
* Bug fixes
* Bug fix, with debug
* Fix flickr, fix graybox bug, reduced debug
* Refactor/cleanup
* Fix
* naming
* Final cleanup
* review comment
* Forgot to update this after naming change
* scrubber works, with debug
* cleanup
* Rename scrollbar to scrubber
* rename to
* left over rename and change to previous album bar
* bugfix addassets, comments
* missing destroy(), cleanup
---------
Co-authored-by: Alex <alex.tran1502@gmail.com>
2024-08-21 22:15:21 -04:00
|
|
|
let height = 0;
|
2024-03-05 16:43:24 +01:00
|
|
|
for (const bucket of this.buckets) {
|
2024-09-05 07:29:07 -07:00
|
|
|
if (height >= this.viewport.height) {
|
feat(web): Scroll to asset in gridview; increase gridview perf; reduce memory; scrollbar ticks in fixed position (#10646)
* Squashed
* Change strategy - now pre-measure buckets offscreen, so don't need to worry about sub-bucket scroll preservation
* Reduce jank on scroll, delay DOM updates until after scroll
* css opt, log measure time
* Trickle out queue while scrolling, flush when stopped
* yay
* Cleanup cleanup...
* everybody...
* everywhere...
* Clean up cleanup!
* Everybody do their share
* CLEANUP!
* package-lock ?
* dynamic measure, todo
* Fix web test
* type lint
* fix e2e
* e2e test
* Better scrollbar
* Tuning, and more tunables
* Tunable tweaks, more tunables
* Scrollbar dots and viewport events
* lint
* Tweaked tunnables, use requestIdleCallback for garbage tasks, bug fixes
* New tunables, and don't update url by default
* Bug fixes
* Bug fix, with debug
* Fix flickr, fix graybox bug, reduced debug
* Refactor/cleanup
* Fix
* naming
* Final cleanup
* review comment
* Forgot to update this after naming change
* scrubber works, with debug
* cleanup
* Rename scrollbar to scrubber
* rename to
* left over rename and change to previous album bar
* bugfix addassets, comments
* missing destroy(), cleanup
---------
Co-authored-by: Alex <alex.tran1502@gmail.com>
2024-08-21 22:15:21 -04:00
|
|
|
break;
|
2024-03-05 16:43:24 +01:00
|
|
|
}
|
feat(web): Scroll to asset in gridview; increase gridview perf; reduce memory; scrollbar ticks in fixed position (#10646)
* Squashed
* Change strategy - now pre-measure buckets offscreen, so don't need to worry about sub-bucket scroll preservation
* Reduce jank on scroll, delay DOM updates until after scroll
* css opt, log measure time
* Trickle out queue while scrolling, flush when stopped
* yay
* Cleanup cleanup...
* everybody...
* everywhere...
* Clean up cleanup!
* Everybody do their share
* CLEANUP!
* package-lock ?
* dynamic measure, todo
* Fix web test
* type lint
* fix e2e
* e2e test
* Better scrollbar
* Tuning, and more tunables
* Tunable tweaks, more tunables
* Scrollbar dots and viewport events
* lint
* Tweaked tunnables, use requestIdleCallback for garbage tasks, bug fixes
* New tunables, and don't update url by default
* Bug fixes
* Bug fix, with debug
* Fix flickr, fix graybox bug, reduced debug
* Refactor/cleanup
* Fix
* naming
* Final cleanup
* review comment
* Forgot to update this after naming change
* scrubber works, with debug
* cleanup
* Rename scrollbar to scrubber
* rename to
* left over rename and change to previous album bar
* bugfix addassets, comments
* missing destroy(), cleanup
---------
Co-authored-by: Alex <alex.tran1502@gmail.com>
2024-08-21 22:15:21 -04:00
|
|
|
height += bucket.bucketHeight;
|
|
|
|
|
loaders.push(this.loadBucket(bucket.bucketDate));
|
2024-03-05 16:43:24 +01:00
|
|
|
}
|
|
|
|
|
await Promise.all(loaders);
|
feat(web): Scroll to asset in gridview; increase gridview perf; reduce memory; scrollbar ticks in fixed position (#10646)
* Squashed
* Change strategy - now pre-measure buckets offscreen, so don't need to worry about sub-bucket scroll preservation
* Reduce jank on scroll, delay DOM updates until after scroll
* css opt, log measure time
* Trickle out queue while scrolling, flush when stopped
* yay
* Cleanup cleanup...
* everybody...
* everywhere...
* Clean up cleanup!
* Everybody do their share
* CLEANUP!
* package-lock ?
* dynamic measure, todo
* Fix web test
* type lint
* fix e2e
* e2e test
* Better scrollbar
* Tuning, and more tunables
* Tunable tweaks, more tunables
* Scrollbar dots and viewport events
* lint
* Tweaked tunnables, use requestIdleCallback for garbage tasks, bug fixes
* New tunables, and don't update url by default
* Bug fixes
* Bug fix, with debug
* Fix flickr, fix graybox bug, reduced debug
* Refactor/cleanup
* Fix
* naming
* Final cleanup
* review comment
* Forgot to update this after naming change
* scrubber works, with debug
* cleanup
* Rename scrollbar to scrubber
* rename to
* left over rename and change to previous album bar
* bugfix addassets, comments
* missing destroy(), cleanup
---------
Co-authored-by: Alex <alex.tran1502@gmail.com>
2024-08-21 22:15:21 -04:00
|
|
|
this.notifyListeners({ type: 'viewport' });
|
2024-04-24 15:24:19 -04:00
|
|
|
this.emit(false);
|
2023-08-03 11:44:12 -04:00
|
|
|
}
|
|
|
|
|
|
2025-02-22 21:16:06 +03:00
|
|
|
private async updateGeometry(bucket: AssetBucket, invalidateHeight: boolean) {
|
feat(web): Scroll to asset in gridview; increase gridview perf; reduce memory; scrollbar ticks in fixed position (#10646)
* Squashed
* Change strategy - now pre-measure buckets offscreen, so don't need to worry about sub-bucket scroll preservation
* Reduce jank on scroll, delay DOM updates until after scroll
* css opt, log measure time
* Trickle out queue while scrolling, flush when stopped
* yay
* Cleanup cleanup...
* everybody...
* everywhere...
* Clean up cleanup!
* Everybody do their share
* CLEANUP!
* package-lock ?
* dynamic measure, todo
* Fix web test
* type lint
* fix e2e
* e2e test
* Better scrollbar
* Tuning, and more tunables
* Tunable tweaks, more tunables
* Scrollbar dots and viewport events
* lint
* Tweaked tunnables, use requestIdleCallback for garbage tasks, bug fixes
* New tunables, and don't update url by default
* Bug fixes
* Bug fix, with debug
* Fix flickr, fix graybox bug, reduced debug
* Refactor/cleanup
* Fix
* naming
* Final cleanup
* review comment
* Forgot to update this after naming change
* scrubber works, with debug
* cleanup
* Rename scrollbar to scrubber
* rename to
* left over rename and change to previous album bar
* bugfix addassets, comments
* missing destroy(), cleanup
---------
Co-authored-by: Alex <alex.tran1502@gmail.com>
2024-08-21 22:15:21 -04:00
|
|
|
if (invalidateHeight) {
|
|
|
|
|
bucket.isBucketHeightActual = false;
|
|
|
|
|
bucket.measured = false;
|
|
|
|
|
for (const assetGroup of bucket.dateGroups) {
|
|
|
|
|
assetGroup.heightActual = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-02-21 12:20:25 +03:00
|
|
|
|
|
|
|
|
const viewportWidth = this.viewport.width;
|
feat(web): Scroll to asset in gridview; increase gridview perf; reduce memory; scrollbar ticks in fixed position (#10646)
* Squashed
* Change strategy - now pre-measure buckets offscreen, so don't need to worry about sub-bucket scroll preservation
* Reduce jank on scroll, delay DOM updates until after scroll
* css opt, log measure time
* Trickle out queue while scrolling, flush when stopped
* yay
* Cleanup cleanup...
* everybody...
* everywhere...
* Clean up cleanup!
* Everybody do their share
* CLEANUP!
* package-lock ?
* dynamic measure, todo
* Fix web test
* type lint
* fix e2e
* e2e test
* Better scrollbar
* Tuning, and more tunables
* Tunable tweaks, more tunables
* Scrollbar dots and viewport events
* lint
* Tweaked tunnables, use requestIdleCallback for garbage tasks, bug fixes
* New tunables, and don't update url by default
* Bug fixes
* Bug fix, with debug
* Fix flickr, fix graybox bug, reduced debug
* Refactor/cleanup
* Fix
* naming
* Final cleanup
* review comment
* Forgot to update this after naming change
* scrubber works, with debug
* cleanup
* Rename scrollbar to scrubber
* rename to
* left over rename and change to previous album bar
* bugfix addassets, comments
* missing destroy(), cleanup
---------
Co-authored-by: Alex <alex.tran1502@gmail.com>
2024-08-21 22:15:21 -04:00
|
|
|
if (!bucket.isBucketHeightActual) {
|
|
|
|
|
const unwrappedWidth = (3 / 2) * bucket.bucketCount * THUMBNAIL_HEIGHT * (7 / 10);
|
2025-02-21 12:20:25 +03:00
|
|
|
const rows = Math.ceil(unwrappedWidth / viewportWidth);
|
feat(web): Scroll to asset in gridview; increase gridview perf; reduce memory; scrollbar ticks in fixed position (#10646)
* Squashed
* Change strategy - now pre-measure buckets offscreen, so don't need to worry about sub-bucket scroll preservation
* Reduce jank on scroll, delay DOM updates until after scroll
* css opt, log measure time
* Trickle out queue while scrolling, flush when stopped
* yay
* Cleanup cleanup...
* everybody...
* everywhere...
* Clean up cleanup!
* Everybody do their share
* CLEANUP!
* package-lock ?
* dynamic measure, todo
* Fix web test
* type lint
* fix e2e
* e2e test
* Better scrollbar
* Tuning, and more tunables
* Tunable tweaks, more tunables
* Scrollbar dots and viewport events
* lint
* Tweaked tunnables, use requestIdleCallback for garbage tasks, bug fixes
* New tunables, and don't update url by default
* Bug fixes
* Bug fix, with debug
* Fix flickr, fix graybox bug, reduced debug
* Refactor/cleanup
* Fix
* naming
* Final cleanup
* review comment
* Forgot to update this after naming change
* scrubber works, with debug
* cleanup
* Rename scrollbar to scrubber
* rename to
* left over rename and change to previous album bar
* bugfix addassets, comments
* missing destroy(), cleanup
---------
Co-authored-by: Alex <alex.tran1502@gmail.com>
2024-08-21 22:15:21 -04:00
|
|
|
const height = 51 + rows * THUMBNAIL_HEIGHT;
|
|
|
|
|
bucket.bucketHeight = height;
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-21 12:20:25 +03:00
|
|
|
const layoutOptions = {
|
|
|
|
|
spacing: 2,
|
|
|
|
|
heightTolerance: 0.15,
|
|
|
|
|
rowHeight: 235,
|
|
|
|
|
rowWidth: Math.floor(viewportWidth),
|
|
|
|
|
};
|
2025-02-22 21:16:06 +03:00
|
|
|
// TODO: move this import and make this method sync after https://github.com/sveltejs/kit/issues/7805 is fixed
|
|
|
|
|
const { getJustifiedLayoutFromAssets } = await import('$lib/utils/layout-utils');
|
feat(web): Scroll to asset in gridview; increase gridview perf; reduce memory; scrollbar ticks in fixed position (#10646)
* Squashed
* Change strategy - now pre-measure buckets offscreen, so don't need to worry about sub-bucket scroll preservation
* Reduce jank on scroll, delay DOM updates until after scroll
* css opt, log measure time
* Trickle out queue while scrolling, flush when stopped
* yay
* Cleanup cleanup...
* everybody...
* everywhere...
* Clean up cleanup!
* Everybody do their share
* CLEANUP!
* package-lock ?
* dynamic measure, todo
* Fix web test
* type lint
* fix e2e
* e2e test
* Better scrollbar
* Tuning, and more tunables
* Tunable tweaks, more tunables
* Scrollbar dots and viewport events
* lint
* Tweaked tunnables, use requestIdleCallback for garbage tasks, bug fixes
* New tunables, and don't update url by default
* Bug fixes
* Bug fix, with debug
* Fix flickr, fix graybox bug, reduced debug
* Refactor/cleanup
* Fix
* naming
* Final cleanup
* review comment
* Forgot to update this after naming change
* scrubber works, with debug
* cleanup
* Rename scrollbar to scrubber
* rename to
* left over rename and change to previous album bar
* bugfix addassets, comments
* missing destroy(), cleanup
---------
Co-authored-by: Alex <alex.tran1502@gmail.com>
2024-08-21 22:15:21 -04:00
|
|
|
for (const assetGroup of bucket.dateGroups) {
|
|
|
|
|
if (!assetGroup.heightActual) {
|
|
|
|
|
const unwrappedWidth = (3 / 2) * assetGroup.assets.length * THUMBNAIL_HEIGHT * (7 / 10);
|
2025-02-21 12:20:25 +03:00
|
|
|
const rows = Math.ceil(unwrappedWidth / viewportWidth);
|
feat(web): Scroll to asset in gridview; increase gridview perf; reduce memory; scrollbar ticks in fixed position (#10646)
* Squashed
* Change strategy - now pre-measure buckets offscreen, so don't need to worry about sub-bucket scroll preservation
* Reduce jank on scroll, delay DOM updates until after scroll
* css opt, log measure time
* Trickle out queue while scrolling, flush when stopped
* yay
* Cleanup cleanup...
* everybody...
* everywhere...
* Clean up cleanup!
* Everybody do their share
* CLEANUP!
* package-lock ?
* dynamic measure, todo
* Fix web test
* type lint
* fix e2e
* e2e test
* Better scrollbar
* Tuning, and more tunables
* Tunable tweaks, more tunables
* Scrollbar dots and viewport events
* lint
* Tweaked tunnables, use requestIdleCallback for garbage tasks, bug fixes
* New tunables, and don't update url by default
* Bug fixes
* Bug fix, with debug
* Fix flickr, fix graybox bug, reduced debug
* Refactor/cleanup
* Fix
* naming
* Final cleanup
* review comment
* Forgot to update this after naming change
* scrubber works, with debug
* cleanup
* Rename scrollbar to scrubber
* rename to
* left over rename and change to previous album bar
* bugfix addassets, comments
* missing destroy(), cleanup
---------
Co-authored-by: Alex <alex.tran1502@gmail.com>
2024-08-21 22:15:21 -04:00
|
|
|
const height = rows * THUMBNAIL_HEIGHT;
|
|
|
|
|
assetGroup.height = height;
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-21 12:20:25 +03:00
|
|
|
assetGroup.geometry = getJustifiedLayoutFromAssets(assetGroup.assets, layoutOptions);
|
feat(web): Scroll to asset in gridview; increase gridview perf; reduce memory; scrollbar ticks in fixed position (#10646)
* Squashed
* Change strategy - now pre-measure buckets offscreen, so don't need to worry about sub-bucket scroll preservation
* Reduce jank on scroll, delay DOM updates until after scroll
* css opt, log measure time
* Trickle out queue while scrolling, flush when stopped
* yay
* Cleanup cleanup...
* everybody...
* everywhere...
* Clean up cleanup!
* Everybody do their share
* CLEANUP!
* package-lock ?
* dynamic measure, todo
* Fix web test
* type lint
* fix e2e
* e2e test
* Better scrollbar
* Tuning, and more tunables
* Tunable tweaks, more tunables
* Scrollbar dots and viewport events
* lint
* Tweaked tunnables, use requestIdleCallback for garbage tasks, bug fixes
* New tunables, and don't update url by default
* Bug fixes
* Bug fix, with debug
* Fix flickr, fix graybox bug, reduced debug
* Refactor/cleanup
* Fix
* naming
* Final cleanup
* review comment
* Forgot to update this after naming change
* scrubber works, with debug
* cleanup
* Rename scrollbar to scrubber
* rename to
* left over rename and change to previous album bar
* bugfix addassets, comments
* missing destroy(), cleanup
---------
Co-authored-by: Alex <alex.tran1502@gmail.com>
2024-08-21 22:15:21 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async loadBucket(bucketDate: string, options: { preventCancel?: boolean; pending?: boolean } = {}): Promise<void> {
|
2024-03-20 20:40:41 +01:00
|
|
|
const bucket = this.getBucketByDate(bucketDate);
|
|
|
|
|
if (!bucket) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
feat(web): Scroll to asset in gridview; increase gridview perf; reduce memory; scrollbar ticks in fixed position (#10646)
* Squashed
* Change strategy - now pre-measure buckets offscreen, so don't need to worry about sub-bucket scroll preservation
* Reduce jank on scroll, delay DOM updates until after scroll
* css opt, log measure time
* Trickle out queue while scrolling, flush when stopped
* yay
* Cleanup cleanup...
* everybody...
* everywhere...
* Clean up cleanup!
* Everybody do their share
* CLEANUP!
* package-lock ?
* dynamic measure, todo
* Fix web test
* type lint
* fix e2e
* e2e test
* Better scrollbar
* Tuning, and more tunables
* Tunable tweaks, more tunables
* Scrollbar dots and viewport events
* lint
* Tweaked tunnables, use requestIdleCallback for garbage tasks, bug fixes
* New tunables, and don't update url by default
* Bug fixes
* Bug fix, with debug
* Fix flickr, fix graybox bug, reduced debug
* Refactor/cleanup
* Fix
* naming
* Final cleanup
* review comment
* Forgot to update this after naming change
* scrubber works, with debug
* cleanup
* Rename scrollbar to scrubber
* rename to
* left over rename and change to previous album bar
* bugfix addassets, comments
* missing destroy(), cleanup
---------
Co-authored-by: Alex <alex.tran1502@gmail.com>
2024-08-21 22:15:21 -04:00
|
|
|
if (bucket.bucketCount === bucket.assets.length) {
|
|
|
|
|
// already loaded
|
|
|
|
|
return;
|
|
|
|
|
}
|
2023-08-03 11:44:12 -04:00
|
|
|
|
feat(web): Scroll to asset in gridview; increase gridview perf; reduce memory; scrollbar ticks in fixed position (#10646)
* Squashed
* Change strategy - now pre-measure buckets offscreen, so don't need to worry about sub-bucket scroll preservation
* Reduce jank on scroll, delay DOM updates until after scroll
* css opt, log measure time
* Trickle out queue while scrolling, flush when stopped
* yay
* Cleanup cleanup...
* everybody...
* everywhere...
* Clean up cleanup!
* Everybody do their share
* CLEANUP!
* package-lock ?
* dynamic measure, todo
* Fix web test
* type lint
* fix e2e
* e2e test
* Better scrollbar
* Tuning, and more tunables
* Tunable tweaks, more tunables
* Scrollbar dots and viewport events
* lint
* Tweaked tunnables, use requestIdleCallback for garbage tasks, bug fixes
* New tunables, and don't update url by default
* Bug fixes
* Bug fix, with debug
* Fix flickr, fix graybox bug, reduced debug
* Refactor/cleanup
* Fix
* naming
* Final cleanup
* review comment
* Forgot to update this after naming change
* scrubber works, with debug
* cleanup
* Rename scrollbar to scrubber
* rename to
* left over rename and change to previous album bar
* bugfix addassets, comments
* missing destroy(), cleanup
---------
Co-authored-by: Alex <alex.tran1502@gmail.com>
2024-08-21 22:15:21 -04:00
|
|
|
if (bucket.cancelToken != null && bucket.bucketCount !== bucket.assets.length) {
|
|
|
|
|
// if promise is pending, and preventCancel is requested, then don't overwrite it
|
|
|
|
|
if (!bucket.isPreventCancel && options.preventCancel) {
|
|
|
|
|
bucket.isPreventCancel = options.preventCancel;
|
|
|
|
|
}
|
|
|
|
|
await bucket.complete;
|
2024-03-20 20:40:41 +01:00
|
|
|
return;
|
|
|
|
|
}
|
2023-08-03 11:44:12 -04:00
|
|
|
|
feat(web): Scroll to asset in gridview; increase gridview perf; reduce memory; scrollbar ticks in fixed position (#10646)
* Squashed
* Change strategy - now pre-measure buckets offscreen, so don't need to worry about sub-bucket scroll preservation
* Reduce jank on scroll, delay DOM updates until after scroll
* css opt, log measure time
* Trickle out queue while scrolling, flush when stopped
* yay
* Cleanup cleanup...
* everybody...
* everywhere...
* Clean up cleanup!
* Everybody do their share
* CLEANUP!
* package-lock ?
* dynamic measure, todo
* Fix web test
* type lint
* fix e2e
* e2e test
* Better scrollbar
* Tuning, and more tunables
* Tunable tweaks, more tunables
* Scrollbar dots and viewport events
* lint
* Tweaked tunnables, use requestIdleCallback for garbage tasks, bug fixes
* New tunables, and don't update url by default
* Bug fixes
* Bug fix, with debug
* Fix flickr, fix graybox bug, reduced debug
* Refactor/cleanup
* Fix
* naming
* Final cleanup
* review comment
* Forgot to update this after naming change
* scrubber works, with debug
* cleanup
* Rename scrollbar to scrubber
* rename to
* left over rename and change to previous album bar
* bugfix addassets, comments
* missing destroy(), cleanup
---------
Co-authored-by: Alex <alex.tran1502@gmail.com>
2024-08-21 22:15:21 -04:00
|
|
|
if (options.pending) {
|
|
|
|
|
this.pendingScrollBucket = bucket;
|
|
|
|
|
}
|
|
|
|
|
this.notifyListeners({ type: 'load', bucket });
|
|
|
|
|
bucket.isPreventCancel = !!options.preventCancel;
|
2023-08-03 11:44:12 -04:00
|
|
|
|
feat(web): Scroll to asset in gridview; increase gridview perf; reduce memory; scrollbar ticks in fixed position (#10646)
* Squashed
* Change strategy - now pre-measure buckets offscreen, so don't need to worry about sub-bucket scroll preservation
* Reduce jank on scroll, delay DOM updates until after scroll
* css opt, log measure time
* Trickle out queue while scrolling, flush when stopped
* yay
* Cleanup cleanup...
* everybody...
* everywhere...
* Clean up cleanup!
* Everybody do their share
* CLEANUP!
* package-lock ?
* dynamic measure, todo
* Fix web test
* type lint
* fix e2e
* e2e test
* Better scrollbar
* Tuning, and more tunables
* Tunable tweaks, more tunables
* Scrollbar dots and viewport events
* lint
* Tweaked tunnables, use requestIdleCallback for garbage tasks, bug fixes
* New tunables, and don't update url by default
* Bug fixes
* Bug fix, with debug
* Fix flickr, fix graybox bug, reduced debug
* Refactor/cleanup
* Fix
* naming
* Final cleanup
* review comment
* Forgot to update this after naming change
* scrubber works, with debug
* cleanup
* Rename scrollbar to scrubber
* rename to
* left over rename and change to previous album bar
* bugfix addassets, comments
* missing destroy(), cleanup
---------
Co-authored-by: Alex <alex.tran1502@gmail.com>
2024-08-21 22:15:21 -04:00
|
|
|
const cancelToken = (bucket.cancelToken = new AbortController());
|
2024-03-20 20:40:41 +01:00
|
|
|
try {
|
2024-02-14 08:09:49 -05:00
|
|
|
const assets = await getTimeBucket(
|
2023-08-25 00:03:28 -04:00
|
|
|
{
|
|
|
|
|
...this.options,
|
|
|
|
|
timeBucket: bucketDate,
|
2024-02-14 08:09:49 -05:00
|
|
|
key: getKey(),
|
2023-08-25 00:03:28 -04:00
|
|
|
},
|
feat(web): Scroll to asset in gridview; increase gridview perf; reduce memory; scrollbar ticks in fixed position (#10646)
* Squashed
* Change strategy - now pre-measure buckets offscreen, so don't need to worry about sub-bucket scroll preservation
* Reduce jank on scroll, delay DOM updates until after scroll
* css opt, log measure time
* Trickle out queue while scrolling, flush when stopped
* yay
* Cleanup cleanup...
* everybody...
* everywhere...
* Clean up cleanup!
* Everybody do their share
* CLEANUP!
* package-lock ?
* dynamic measure, todo
* Fix web test
* type lint
* fix e2e
* e2e test
* Better scrollbar
* Tuning, and more tunables
* Tunable tweaks, more tunables
* Scrollbar dots and viewport events
* lint
* Tweaked tunnables, use requestIdleCallback for garbage tasks, bug fixes
* New tunables, and don't update url by default
* Bug fixes
* Bug fix, with debug
* Fix flickr, fix graybox bug, reduced debug
* Refactor/cleanup
* Fix
* naming
* Final cleanup
* review comment
* Forgot to update this after naming change
* scrubber works, with debug
* cleanup
* Rename scrollbar to scrubber
* rename to
* left over rename and change to previous album bar
* bugfix addassets, comments
* missing destroy(), cleanup
---------
Co-authored-by: Alex <alex.tran1502@gmail.com>
2024-08-21 22:15:21 -04:00
|
|
|
{ signal: cancelToken.signal },
|
2023-08-03 11:44:12 -04:00
|
|
|
);
|
|
|
|
|
|
feat(web): Scroll to asset in gridview; increase gridview perf; reduce memory; scrollbar ticks in fixed position (#10646)
* Squashed
* Change strategy - now pre-measure buckets offscreen, so don't need to worry about sub-bucket scroll preservation
* Reduce jank on scroll, delay DOM updates until after scroll
* css opt, log measure time
* Trickle out queue while scrolling, flush when stopped
* yay
* Cleanup cleanup...
* everybody...
* everywhere...
* Clean up cleanup!
* Everybody do their share
* CLEANUP!
* package-lock ?
* dynamic measure, todo
* Fix web test
* type lint
* fix e2e
* e2e test
* Better scrollbar
* Tuning, and more tunables
* Tunable tweaks, more tunables
* Scrollbar dots and viewport events
* lint
* Tweaked tunnables, use requestIdleCallback for garbage tasks, bug fixes
* New tunables, and don't update url by default
* Bug fixes
* Bug fix, with debug
* Fix flickr, fix graybox bug, reduced debug
* Refactor/cleanup
* Fix
* naming
* Final cleanup
* review comment
* Forgot to update this after naming change
* scrubber works, with debug
* cleanup
* Rename scrollbar to scrubber
* rename to
* left over rename and change to previous album bar
* bugfix addassets, comments
* missing destroy(), cleanup
---------
Co-authored-by: Alex <alex.tran1502@gmail.com>
2024-08-21 22:15:21 -04:00
|
|
|
if (cancelToken.signal.aborted) {
|
|
|
|
|
this.notifyListeners({ type: 'cancel', bucket });
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-11 12:00:51 -04:00
|
|
|
if (this.albumId) {
|
2024-02-14 08:09:49 -05:00
|
|
|
const albumAssets = await getTimeBucket(
|
2023-08-11 12:00:51 -04:00
|
|
|
{
|
|
|
|
|
albumId: this.albumId,
|
|
|
|
|
timeBucket: bucketDate,
|
|
|
|
|
size: this.options.size,
|
2024-02-14 08:09:49 -05:00
|
|
|
key: getKey(),
|
2023-08-11 12:00:51 -04:00
|
|
|
},
|
feat(web): Scroll to asset in gridview; increase gridview perf; reduce memory; scrollbar ticks in fixed position (#10646)
* Squashed
* Change strategy - now pre-measure buckets offscreen, so don't need to worry about sub-bucket scroll preservation
* Reduce jank on scroll, delay DOM updates until after scroll
* css opt, log measure time
* Trickle out queue while scrolling, flush when stopped
* yay
* Cleanup cleanup...
* everybody...
* everywhere...
* Clean up cleanup!
* Everybody do their share
* CLEANUP!
* package-lock ?
* dynamic measure, todo
* Fix web test
* type lint
* fix e2e
* e2e test
* Better scrollbar
* Tuning, and more tunables
* Tunable tweaks, more tunables
* Scrollbar dots and viewport events
* lint
* Tweaked tunnables, use requestIdleCallback for garbage tasks, bug fixes
* New tunables, and don't update url by default
* Bug fixes
* Bug fix, with debug
* Fix flickr, fix graybox bug, reduced debug
* Refactor/cleanup
* Fix
* naming
* Final cleanup
* review comment
* Forgot to update this after naming change
* scrubber works, with debug
* cleanup
* Rename scrollbar to scrubber
* rename to
* left over rename and change to previous album bar
* bugfix addassets, comments
* missing destroy(), cleanup
---------
Co-authored-by: Alex <alex.tran1502@gmail.com>
2024-08-21 22:15:21 -04:00
|
|
|
{ signal: cancelToken.signal },
|
2023-08-11 12:00:51 -04:00
|
|
|
);
|
feat(web): Scroll to asset in gridview; increase gridview perf; reduce memory; scrollbar ticks in fixed position (#10646)
* Squashed
* Change strategy - now pre-measure buckets offscreen, so don't need to worry about sub-bucket scroll preservation
* Reduce jank on scroll, delay DOM updates until after scroll
* css opt, log measure time
* Trickle out queue while scrolling, flush when stopped
* yay
* Cleanup cleanup...
* everybody...
* everywhere...
* Clean up cleanup!
* Everybody do their share
* CLEANUP!
* package-lock ?
* dynamic measure, todo
* Fix web test
* type lint
* fix e2e
* e2e test
* Better scrollbar
* Tuning, and more tunables
* Tunable tweaks, more tunables
* Scrollbar dots and viewport events
* lint
* Tweaked tunnables, use requestIdleCallback for garbage tasks, bug fixes
* New tunables, and don't update url by default
* Bug fixes
* Bug fix, with debug
* Fix flickr, fix graybox bug, reduced debug
* Refactor/cleanup
* Fix
* naming
* Final cleanup
* review comment
* Forgot to update this after naming change
* scrubber works, with debug
* cleanup
* Rename scrollbar to scrubber
* rename to
* left over rename and change to previous album bar
* bugfix addassets, comments
* missing destroy(), cleanup
---------
Co-authored-by: Alex <alex.tran1502@gmail.com>
2024-08-21 22:15:21 -04:00
|
|
|
if (cancelToken.signal.aborted) {
|
|
|
|
|
this.notifyListeners({ type: 'cancel', bucket });
|
|
|
|
|
return;
|
|
|
|
|
}
|
2023-08-11 12:00:51 -04:00
|
|
|
for (const asset of albumAssets) {
|
|
|
|
|
this.albumAssets.add(asset.id);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-05 16:43:24 +01:00
|
|
|
bucket.assets = assets;
|
feat(web): Scroll to asset in gridview; increase gridview perf; reduce memory; scrollbar ticks in fixed position (#10646)
* Squashed
* Change strategy - now pre-measure buckets offscreen, so don't need to worry about sub-bucket scroll preservation
* Reduce jank on scroll, delay DOM updates until after scroll
* css opt, log measure time
* Trickle out queue while scrolling, flush when stopped
* yay
* Cleanup cleanup...
* everybody...
* everywhere...
* Clean up cleanup!
* Everybody do their share
* CLEANUP!
* package-lock ?
* dynamic measure, todo
* Fix web test
* type lint
* fix e2e
* e2e test
* Better scrollbar
* Tuning, and more tunables
* Tunable tweaks, more tunables
* Scrollbar dots and viewport events
* lint
* Tweaked tunnables, use requestIdleCallback for garbage tasks, bug fixes
* New tunables, and don't update url by default
* Bug fixes
* Bug fix, with debug
* Fix flickr, fix graybox bug, reduced debug
* Refactor/cleanup
* Fix
* naming
* Final cleanup
* review comment
* Forgot to update this after naming change
* scrubber works, with debug
* cleanup
* Rename scrollbar to scrubber
* rename to
* left over rename and change to previous album bar
* bugfix addassets, comments
* missing destroy(), cleanup
---------
Co-authored-by: Alex <alex.tran1502@gmail.com>
2024-08-21 22:15:21 -04:00
|
|
|
bucket.dateGroups = splitBucketIntoDateGroups(bucket, get(locale));
|
2025-02-21 07:38:12 +03:00
|
|
|
this.maxBucketAssets = Math.max(this.maxBucketAssets, assets.length);
|
2025-02-22 21:16:06 +03:00
|
|
|
await this.updateGeometry(bucket, true);
|
feat(web): Scroll to asset in gridview; increase gridview perf; reduce memory; scrollbar ticks in fixed position (#10646)
* Squashed
* Change strategy - now pre-measure buckets offscreen, so don't need to worry about sub-bucket scroll preservation
* Reduce jank on scroll, delay DOM updates until after scroll
* css opt, log measure time
* Trickle out queue while scrolling, flush when stopped
* yay
* Cleanup cleanup...
* everybody...
* everywhere...
* Clean up cleanup!
* Everybody do their share
* CLEANUP!
* package-lock ?
* dynamic measure, todo
* Fix web test
* type lint
* fix e2e
* e2e test
* Better scrollbar
* Tuning, and more tunables
* Tunable tweaks, more tunables
* Scrollbar dots and viewport events
* lint
* Tweaked tunnables, use requestIdleCallback for garbage tasks, bug fixes
* New tunables, and don't update url by default
* Bug fixes
* Bug fix, with debug
* Fix flickr, fix graybox bug, reduced debug
* Refactor/cleanup
* Fix
* naming
* Final cleanup
* review comment
* Forgot to update this after naming change
* scrubber works, with debug
* cleanup
* Rename scrollbar to scrubber
* rename to
* left over rename and change to previous album bar
* bugfix addassets, comments
* missing destroy(), cleanup
---------
Co-authored-by: Alex <alex.tran1502@gmail.com>
2024-08-21 22:15:21 -04:00
|
|
|
this.timelineHeight = this.buckets.reduce((accumulator, b) => accumulator + b.bucketHeight, 0);
|
|
|
|
|
bucket.loaded();
|
|
|
|
|
this.notifyListeners({ type: 'loaded', bucket });
|
2023-08-03 11:44:12 -04:00
|
|
|
} catch (error) {
|
feat(web): Scroll to asset in gridview; increase gridview perf; reduce memory; scrollbar ticks in fixed position (#10646)
* Squashed
* Change strategy - now pre-measure buckets offscreen, so don't need to worry about sub-bucket scroll preservation
* Reduce jank on scroll, delay DOM updates until after scroll
* css opt, log measure time
* Trickle out queue while scrolling, flush when stopped
* yay
* Cleanup cleanup...
* everybody...
* everywhere...
* Clean up cleanup!
* Everybody do their share
* CLEANUP!
* package-lock ?
* dynamic measure, todo
* Fix web test
* type lint
* fix e2e
* e2e test
* Better scrollbar
* Tuning, and more tunables
* Tunable tweaks, more tunables
* Scrollbar dots and viewport events
* lint
* Tweaked tunnables, use requestIdleCallback for garbage tasks, bug fixes
* New tunables, and don't update url by default
* Bug fixes
* Bug fix, with debug
* Fix flickr, fix graybox bug, reduced debug
* Refactor/cleanup
* Fix
* naming
* Final cleanup
* review comment
* Forgot to update this after naming change
* scrubber works, with debug
* cleanup
* Rename scrollbar to scrubber
* rename to
* left over rename and change to previous album bar
* bugfix addassets, comments
* missing destroy(), cleanup
---------
Co-authored-by: Alex <alex.tran1502@gmail.com>
2024-08-21 22:15:21 -04:00
|
|
|
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
|
|
|
if ((error as any).name === 'AbortError') {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2024-07-01 00:29:10 +02:00
|
|
|
const $t = get(t);
|
|
|
|
|
handleError(error, $t('errors.failed_to_load_assets'));
|
feat(web): Scroll to asset in gridview; increase gridview perf; reduce memory; scrollbar ticks in fixed position (#10646)
* Squashed
* Change strategy - now pre-measure buckets offscreen, so don't need to worry about sub-bucket scroll preservation
* Reduce jank on scroll, delay DOM updates until after scroll
* css opt, log measure time
* Trickle out queue while scrolling, flush when stopped
* yay
* Cleanup cleanup...
* everybody...
* everywhere...
* Clean up cleanup!
* Everybody do their share
* CLEANUP!
* package-lock ?
* dynamic measure, todo
* Fix web test
* type lint
* fix e2e
* e2e test
* Better scrollbar
* Tuning, and more tunables
* Tunable tweaks, more tunables
* Scrollbar dots and viewport events
* lint
* Tweaked tunnables, use requestIdleCallback for garbage tasks, bug fixes
* New tunables, and don't update url by default
* Bug fixes
* Bug fix, with debug
* Fix flickr, fix graybox bug, reduced debug
* Refactor/cleanup
* Fix
* naming
* Final cleanup
* review comment
* Forgot to update this after naming change
* scrubber works, with debug
* cleanup
* Rename scrollbar to scrubber
* rename to
* left over rename and change to previous album bar
* bugfix addassets, comments
* missing destroy(), cleanup
---------
Co-authored-by: Alex <alex.tran1502@gmail.com>
2024-08-21 22:15:21 -04:00
|
|
|
bucket.errored();
|
2024-03-20 20:40:41 +01:00
|
|
|
} finally {
|
feat(web): Scroll to asset in gridview; increase gridview perf; reduce memory; scrollbar ticks in fixed position (#10646)
* Squashed
* Change strategy - now pre-measure buckets offscreen, so don't need to worry about sub-bucket scroll preservation
* Reduce jank on scroll, delay DOM updates until after scroll
* css opt, log measure time
* Trickle out queue while scrolling, flush when stopped
* yay
* Cleanup cleanup...
* everybody...
* everywhere...
* Clean up cleanup!
* Everybody do their share
* CLEANUP!
* package-lock ?
* dynamic measure, todo
* Fix web test
* type lint
* fix e2e
* e2e test
* Better scrollbar
* Tuning, and more tunables
* Tunable tweaks, more tunables
* Scrollbar dots and viewport events
* lint
* Tweaked tunnables, use requestIdleCallback for garbage tasks, bug fixes
* New tunables, and don't update url by default
* Bug fixes
* Bug fix, with debug
* Fix flickr, fix graybox bug, reduced debug
* Refactor/cleanup
* Fix
* naming
* Final cleanup
* review comment
* Forgot to update this after naming change
* scrubber works, with debug
* cleanup
* Rename scrollbar to scrubber
* rename to
* left over rename and change to previous album bar
* bugfix addassets, comments
* missing destroy(), cleanup
---------
Co-authored-by: Alex <alex.tran1502@gmail.com>
2024-08-21 22:15:21 -04:00
|
|
|
bucket.cancelToken = undefined;
|
|
|
|
|
this.emit(true);
|
2023-08-03 11:44:12 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
feat(web): Scroll to asset in gridview; increase gridview perf; reduce memory; scrollbar ticks in fixed position (#10646)
* Squashed
* Change strategy - now pre-measure buckets offscreen, so don't need to worry about sub-bucket scroll preservation
* Reduce jank on scroll, delay DOM updates until after scroll
* css opt, log measure time
* Trickle out queue while scrolling, flush when stopped
* yay
* Cleanup cleanup...
* everybody...
* everywhere...
* Clean up cleanup!
* Everybody do their share
* CLEANUP!
* package-lock ?
* dynamic measure, todo
* Fix web test
* type lint
* fix e2e
* e2e test
* Better scrollbar
* Tuning, and more tunables
* Tunable tweaks, more tunables
* Scrollbar dots and viewport events
* lint
* Tweaked tunnables, use requestIdleCallback for garbage tasks, bug fixes
* New tunables, and don't update url by default
* Bug fixes
* Bug fix, with debug
* Fix flickr, fix graybox bug, reduced debug
* Refactor/cleanup
* Fix
* naming
* Final cleanup
* review comment
* Forgot to update this after naming change
* scrubber works, with debug
* cleanup
* Rename scrollbar to scrubber
* rename to
* left over rename and change to previous album bar
* bugfix addassets, comments
* missing destroy(), cleanup
---------
Co-authored-by: Alex <alex.tran1502@gmail.com>
2024-08-21 22:15:21 -04:00
|
|
|
updateBucket(bucketDate: string, properties: { height?: number; intersecting?: boolean; measured?: boolean }) {
|
2023-08-03 11:44:12 -04:00
|
|
|
const bucket = this.getBucketByDate(bucketDate);
|
|
|
|
|
if (!bucket) {
|
feat(web): Scroll to asset in gridview; increase gridview perf; reduce memory; scrollbar ticks in fixed position (#10646)
* Squashed
* Change strategy - now pre-measure buckets offscreen, so don't need to worry about sub-bucket scroll preservation
* Reduce jank on scroll, delay DOM updates until after scroll
* css opt, log measure time
* Trickle out queue while scrolling, flush when stopped
* yay
* Cleanup cleanup...
* everybody...
* everywhere...
* Clean up cleanup!
* Everybody do their share
* CLEANUP!
* package-lock ?
* dynamic measure, todo
* Fix web test
* type lint
* fix e2e
* e2e test
* Better scrollbar
* Tuning, and more tunables
* Tunable tweaks, more tunables
* Scrollbar dots and viewport events
* lint
* Tweaked tunnables, use requestIdleCallback for garbage tasks, bug fixes
* New tunables, and don't update url by default
* Bug fixes
* Bug fix, with debug
* Fix flickr, fix graybox bug, reduced debug
* Refactor/cleanup
* Fix
* naming
* Final cleanup
* review comment
* Forgot to update this after naming change
* scrubber works, with debug
* cleanup
* Rename scrollbar to scrubber
* rename to
* left over rename and change to previous album bar
* bugfix addassets, comments
* missing destroy(), cleanup
---------
Co-authored-by: Alex <alex.tran1502@gmail.com>
2024-08-21 22:15:21 -04:00
|
|
|
return {};
|
|
|
|
|
}
|
|
|
|
|
let delta = 0;
|
|
|
|
|
if ('height' in properties) {
|
|
|
|
|
const height = properties.height!;
|
|
|
|
|
delta = height - bucket.bucketHeight;
|
|
|
|
|
bucket.isBucketHeightActual = true;
|
|
|
|
|
bucket.bucketHeight = height;
|
|
|
|
|
this.timelineHeight += delta;
|
|
|
|
|
this.notifyListeners({ type: 'bucket-height', bucket, delta });
|
|
|
|
|
}
|
|
|
|
|
if ('intersecting' in properties) {
|
|
|
|
|
bucket.intersecting = properties.intersecting!;
|
|
|
|
|
}
|
|
|
|
|
if ('measured' in properties) {
|
|
|
|
|
if (properties.measured) {
|
|
|
|
|
bucket.measuredSignal?.();
|
|
|
|
|
}
|
|
|
|
|
bucket.measured = properties.measured!;
|
2023-08-03 11:44:12 -04:00
|
|
|
}
|
|
|
|
|
this.emit(false);
|
feat(web): Scroll to asset in gridview; increase gridview perf; reduce memory; scrollbar ticks in fixed position (#10646)
* Squashed
* Change strategy - now pre-measure buckets offscreen, so don't need to worry about sub-bucket scroll preservation
* Reduce jank on scroll, delay DOM updates until after scroll
* css opt, log measure time
* Trickle out queue while scrolling, flush when stopped
* yay
* Cleanup cleanup...
* everybody...
* everywhere...
* Clean up cleanup!
* Everybody do their share
* CLEANUP!
* package-lock ?
* dynamic measure, todo
* Fix web test
* type lint
* fix e2e
* e2e test
* Better scrollbar
* Tuning, and more tunables
* Tunable tweaks, more tunables
* Scrollbar dots and viewport events
* lint
* Tweaked tunnables, use requestIdleCallback for garbage tasks, bug fixes
* New tunables, and don't update url by default
* Bug fixes
* Bug fix, with debug
* Fix flickr, fix graybox bug, reduced debug
* Refactor/cleanup
* Fix
* naming
* Final cleanup
* review comment
* Forgot to update this after naming change
* scrubber works, with debug
* cleanup
* Rename scrollbar to scrubber
* rename to
* left over rename and change to previous album bar
* bugfix addassets, comments
* missing destroy(), cleanup
---------
Co-authored-by: Alex <alex.tran1502@gmail.com>
2024-08-21 22:15:21 -04:00
|
|
|
return { delta };
|
|
|
|
|
}
|
2023-08-03 11:44:12 -04:00
|
|
|
|
feat(web): Scroll to asset in gridview; increase gridview perf; reduce memory; scrollbar ticks in fixed position (#10646)
* Squashed
* Change strategy - now pre-measure buckets offscreen, so don't need to worry about sub-bucket scroll preservation
* Reduce jank on scroll, delay DOM updates until after scroll
* css opt, log measure time
* Trickle out queue while scrolling, flush when stopped
* yay
* Cleanup cleanup...
* everybody...
* everywhere...
* Clean up cleanup!
* Everybody do their share
* CLEANUP!
* package-lock ?
* dynamic measure, todo
* Fix web test
* type lint
* fix e2e
* e2e test
* Better scrollbar
* Tuning, and more tunables
* Tunable tweaks, more tunables
* Scrollbar dots and viewport events
* lint
* Tweaked tunnables, use requestIdleCallback for garbage tasks, bug fixes
* New tunables, and don't update url by default
* Bug fixes
* Bug fix, with debug
* Fix flickr, fix graybox bug, reduced debug
* Refactor/cleanup
* Fix
* naming
* Final cleanup
* review comment
* Forgot to update this after naming change
* scrubber works, with debug
* cleanup
* Rename scrollbar to scrubber
* rename to
* left over rename and change to previous album bar
* bugfix addassets, comments
* missing destroy(), cleanup
---------
Co-authored-by: Alex <alex.tran1502@gmail.com>
2024-08-21 22:15:21 -04:00
|
|
|
updateBucketDateGroup(
|
|
|
|
|
bucket: AssetBucket,
|
|
|
|
|
dateGroup: DateGroup,
|
|
|
|
|
properties: { height?: number; intersecting?: boolean },
|
|
|
|
|
) {
|
|
|
|
|
let delta = 0;
|
|
|
|
|
if ('height' in properties) {
|
|
|
|
|
const height = properties.height!;
|
|
|
|
|
if (height > 0) {
|
|
|
|
|
delta = height - dateGroup.height;
|
|
|
|
|
dateGroup.heightActual = true;
|
|
|
|
|
dateGroup.height = height;
|
|
|
|
|
this.notifyListeners({ type: 'height', bucket, dateGroup, delta, height });
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if ('intersecting' in properties) {
|
|
|
|
|
dateGroup.intersecting = properties.intersecting!;
|
|
|
|
|
if (dateGroup.intersecting) {
|
|
|
|
|
this.notifyListeners({ type: 'intersecting', bucket, dateGroup });
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
this.emit(false);
|
|
|
|
|
return { delta };
|
2023-08-03 11:44:12 -04:00
|
|
|
}
|
|
|
|
|
|
2024-03-15 17:11:29 +01:00
|
|
|
addAssets(assets: AssetResponseDto[]) {
|
|
|
|
|
const assetsToUpdate: AssetResponseDto[] = [];
|
|
|
|
|
const assetsToAdd: AssetResponseDto[] = [];
|
|
|
|
|
|
|
|
|
|
for (const asset of assets) {
|
|
|
|
|
if (
|
|
|
|
|
this.assetToBucket[asset.id] ||
|
|
|
|
|
this.options.userId ||
|
|
|
|
|
this.options.personId ||
|
|
|
|
|
this.options.albumId ||
|
2024-09-18 15:22:34 -04:00
|
|
|
this.isExcluded(asset)
|
2024-03-15 17:11:29 +01:00
|
|
|
) {
|
|
|
|
|
// If asset is already in the bucket we don't need to recalculate
|
|
|
|
|
// asset store containers
|
|
|
|
|
assetsToUpdate.push(asset);
|
|
|
|
|
} else {
|
|
|
|
|
assetsToAdd.push(asset);
|
|
|
|
|
}
|
2023-10-06 15:48:11 -05:00
|
|
|
}
|
|
|
|
|
|
2024-03-15 17:11:29 +01:00
|
|
|
this.updateAssets(assetsToUpdate);
|
|
|
|
|
this.addAssetsToBuckets(assetsToAdd);
|
2024-02-29 18:44:30 +01:00
|
|
|
}
|
|
|
|
|
|
2024-03-15 17:11:29 +01:00
|
|
|
private addAssetsToBuckets(assets: AssetResponseDto[]) {
|
|
|
|
|
if (assets.length === 0) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
const updatedBuckets = new Set<AssetBucket>();
|
2023-10-06 15:48:11 -05:00
|
|
|
|
2024-03-15 17:11:29 +01:00
|
|
|
for (const asset of assets) {
|
2024-09-12 15:30:28 -04:00
|
|
|
const timeBucket = DateTime.fromISO(asset.localDateTime).toUTC().startOf('month').toString();
|
2024-03-15 17:11:29 +01:00
|
|
|
let bucket = this.getBucketByDate(timeBucket);
|
2023-10-06 15:48:11 -05:00
|
|
|
|
2024-03-15 17:11:29 +01:00
|
|
|
if (!bucket) {
|
feat(web): Scroll to asset in gridview; increase gridview perf; reduce memory; scrollbar ticks in fixed position (#10646)
* Squashed
* Change strategy - now pre-measure buckets offscreen, so don't need to worry about sub-bucket scroll preservation
* Reduce jank on scroll, delay DOM updates until after scroll
* css opt, log measure time
* Trickle out queue while scrolling, flush when stopped
* yay
* Cleanup cleanup...
* everybody...
* everywhere...
* Clean up cleanup!
* Everybody do their share
* CLEANUP!
* package-lock ?
* dynamic measure, todo
* Fix web test
* type lint
* fix e2e
* e2e test
* Better scrollbar
* Tuning, and more tunables
* Tunable tweaks, more tunables
* Scrollbar dots and viewport events
* lint
* Tweaked tunnables, use requestIdleCallback for garbage tasks, bug fixes
* New tunables, and don't update url by default
* Bug fixes
* Bug fix, with debug
* Fix flickr, fix graybox bug, reduced debug
* Refactor/cleanup
* Fix
* naming
* Final cleanup
* review comment
* Forgot to update this after naming change
* scrubber works, with debug
* cleanup
* Rename scrollbar to scrubber
* rename to
* left over rename and change to previous album bar
* bugfix addassets, comments
* missing destroy(), cleanup
---------
Co-authored-by: Alex <alex.tran1502@gmail.com>
2024-08-21 22:15:21 -04:00
|
|
|
bucket = new AssetBucket({ store: this, bucketDate: timeBucket, bucketHeight: THUMBNAIL_HEIGHT });
|
2024-03-15 17:11:29 +01:00
|
|
|
this.buckets.push(bucket);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bucket.assets.push(asset);
|
|
|
|
|
this.assets.push(asset);
|
|
|
|
|
updatedBuckets.add(bucket);
|
2023-10-06 15:48:11 -05:00
|
|
|
}
|
|
|
|
|
|
2024-03-15 17:11:29 +01:00
|
|
|
this.buckets = this.buckets.sort((a, b) => {
|
|
|
|
|
const aDate = DateTime.fromISO(a.bucketDate).toUTC();
|
|
|
|
|
const bDate = DateTime.fromISO(b.bucketDate).toUTC();
|
2024-03-05 16:43:24 +01:00
|
|
|
return bDate.diff(aDate).milliseconds;
|
|
|
|
|
});
|
2023-11-04 15:59:21 +03:00
|
|
|
|
2024-03-15 17:11:29 +01:00
|
|
|
for (const bucket of updatedBuckets) {
|
|
|
|
|
bucket.assets.sort((a, b) => {
|
|
|
|
|
const aDate = DateTime.fromISO(a.fileCreatedAt).toUTC();
|
|
|
|
|
const bDate = DateTime.fromISO(b.fileCreatedAt).toUTC();
|
|
|
|
|
return bDate.diff(aDate).milliseconds;
|
|
|
|
|
});
|
feat(web): Scroll to asset in gridview; increase gridview perf; reduce memory; scrollbar ticks in fixed position (#10646)
* Squashed
* Change strategy - now pre-measure buckets offscreen, so don't need to worry about sub-bucket scroll preservation
* Reduce jank on scroll, delay DOM updates until after scroll
* css opt, log measure time
* Trickle out queue while scrolling, flush when stopped
* yay
* Cleanup cleanup...
* everybody...
* everywhere...
* Clean up cleanup!
* Everybody do their share
* CLEANUP!
* package-lock ?
* dynamic measure, todo
* Fix web test
* type lint
* fix e2e
* e2e test
* Better scrollbar
* Tuning, and more tunables
* Tunable tweaks, more tunables
* Scrollbar dots and viewport events
* lint
* Tweaked tunnables, use requestIdleCallback for garbage tasks, bug fixes
* New tunables, and don't update url by default
* Bug fixes
* Bug fix, with debug
* Fix flickr, fix graybox bug, reduced debug
* Refactor/cleanup
* Fix
* naming
* Final cleanup
* review comment
* Forgot to update this after naming change
* scrubber works, with debug
* cleanup
* Rename scrollbar to scrubber
* rename to
* left over rename and change to previous album bar
* bugfix addassets, comments
* missing destroy(), cleanup
---------
Co-authored-by: Alex <alex.tran1502@gmail.com>
2024-08-21 22:15:21 -04:00
|
|
|
bucket.dateGroups = splitBucketIntoDateGroups(bucket, get(locale));
|
2025-02-22 21:16:06 +03:00
|
|
|
void this.updateGeometry(bucket, true);
|
2024-03-15 17:11:29 +01:00
|
|
|
}
|
|
|
|
|
|
2024-02-29 18:44:30 +01:00
|
|
|
this.emit(true);
|
2023-10-06 15:48:11 -05:00
|
|
|
}
|
|
|
|
|
|
2023-08-03 11:44:12 -04:00
|
|
|
getBucketByDate(bucketDate: string): AssetBucket | null {
|
2024-03-05 16:43:24 +01:00
|
|
|
return this.buckets.find((bucket) => bucket.bucketDate === bucketDate) || null;
|
2023-08-03 11:44:12 -04:00
|
|
|
}
|
|
|
|
|
|
feat(web): Scroll to asset in gridview; increase gridview perf; reduce memory; scrollbar ticks in fixed position (#10646)
* Squashed
* Change strategy - now pre-measure buckets offscreen, so don't need to worry about sub-bucket scroll preservation
* Reduce jank on scroll, delay DOM updates until after scroll
* css opt, log measure time
* Trickle out queue while scrolling, flush when stopped
* yay
* Cleanup cleanup...
* everybody...
* everywhere...
* Clean up cleanup!
* Everybody do their share
* CLEANUP!
* package-lock ?
* dynamic measure, todo
* Fix web test
* type lint
* fix e2e
* e2e test
* Better scrollbar
* Tuning, and more tunables
* Tunable tweaks, more tunables
* Scrollbar dots and viewport events
* lint
* Tweaked tunnables, use requestIdleCallback for garbage tasks, bug fixes
* New tunables, and don't update url by default
* Bug fixes
* Bug fix, with debug
* Fix flickr, fix graybox bug, reduced debug
* Refactor/cleanup
* Fix
* naming
* Final cleanup
* review comment
* Forgot to update this after naming change
* scrubber works, with debug
* cleanup
* Rename scrollbar to scrubber
* rename to
* left over rename and change to previous album bar
* bugfix addassets, comments
* missing destroy(), cleanup
---------
Co-authored-by: Alex <alex.tran1502@gmail.com>
2024-08-21 22:15:21 -04:00
|
|
|
async findAndLoadBucketAsPending(id: string) {
|
2024-04-24 15:24:19 -04:00
|
|
|
const bucketInfo = this.assetToBucket[id];
|
2024-09-18 15:22:34 -04:00
|
|
|
let bucket: AssetBucket | null = bucketInfo?.bucket ?? null;
|
|
|
|
|
if (!bucket) {
|
|
|
|
|
const asset = await getAssetInfo({ id });
|
|
|
|
|
if (!asset || this.isExcluded(asset)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bucket = await this.loadBucketAtTime(asset.localDateTime, { preventCancel: true, pending: true });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (bucket && bucket.assets.some((a) => a.id === id)) {
|
feat(web): Scroll to asset in gridview; increase gridview perf; reduce memory; scrollbar ticks in fixed position (#10646)
* Squashed
* Change strategy - now pre-measure buckets offscreen, so don't need to worry about sub-bucket scroll preservation
* Reduce jank on scroll, delay DOM updates until after scroll
* css opt, log measure time
* Trickle out queue while scrolling, flush when stopped
* yay
* Cleanup cleanup...
* everybody...
* everywhere...
* Clean up cleanup!
* Everybody do their share
* CLEANUP!
* package-lock ?
* dynamic measure, todo
* Fix web test
* type lint
* fix e2e
* e2e test
* Better scrollbar
* Tuning, and more tunables
* Tunable tweaks, more tunables
* Scrollbar dots and viewport events
* lint
* Tweaked tunnables, use requestIdleCallback for garbage tasks, bug fixes
* New tunables, and don't update url by default
* Bug fixes
* Bug fix, with debug
* Fix flickr, fix graybox bug, reduced debug
* Refactor/cleanup
* Fix
* naming
* Final cleanup
* review comment
* Forgot to update this after naming change
* scrubber works, with debug
* cleanup
* Rename scrollbar to scrubber
* rename to
* left over rename and change to previous album bar
* bugfix addassets, comments
* missing destroy(), cleanup
---------
Co-authored-by: Alex <alex.tran1502@gmail.com>
2024-08-21 22:15:21 -04:00
|
|
|
this.pendingScrollBucket = bucket;
|
|
|
|
|
this.pendingScrollAssetId = id;
|
|
|
|
|
this.emit(false);
|
|
|
|
|
return bucket;
|
2024-04-24 15:24:19 -04:00
|
|
|
}
|
feat(web): Scroll to asset in gridview; increase gridview perf; reduce memory; scrollbar ticks in fixed position (#10646)
* Squashed
* Change strategy - now pre-measure buckets offscreen, so don't need to worry about sub-bucket scroll preservation
* Reduce jank on scroll, delay DOM updates until after scroll
* css opt, log measure time
* Trickle out queue while scrolling, flush when stopped
* yay
* Cleanup cleanup...
* everybody...
* everywhere...
* Clean up cleanup!
* Everybody do their share
* CLEANUP!
* package-lock ?
* dynamic measure, todo
* Fix web test
* type lint
* fix e2e
* e2e test
* Better scrollbar
* Tuning, and more tunables
* Tunable tweaks, more tunables
* Scrollbar dots and viewport events
* lint
* Tweaked tunnables, use requestIdleCallback for garbage tasks, bug fixes
* New tunables, and don't update url by default
* Bug fixes
* Bug fix, with debug
* Fix flickr, fix graybox bug, reduced debug
* Refactor/cleanup
* Fix
* naming
* Final cleanup
* review comment
* Forgot to update this after naming change
* scrubber works, with debug
* cleanup
* Rename scrollbar to scrubber
* rename to
* left over rename and change to previous album bar
* bugfix addassets, comments
* missing destroy(), cleanup
---------
Co-authored-by: Alex <alex.tran1502@gmail.com>
2024-08-21 22:15:21 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Must be paired with matching clearPendingScroll() call */
|
|
|
|
|
async scheduleScrollToAssetId(scrollTarget: AssetGridRouteSearchParams, onFailure: () => void) {
|
|
|
|
|
try {
|
|
|
|
|
const { at: assetId } = scrollTarget;
|
|
|
|
|
if (assetId) {
|
|
|
|
|
await this.complete;
|
|
|
|
|
const bucket = await this.findAndLoadBucketAsPending(assetId);
|
|
|
|
|
if (bucket) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} catch {
|
|
|
|
|
// failure
|
|
|
|
|
}
|
|
|
|
|
onFailure();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
clearPendingScroll() {
|
|
|
|
|
this.pendingScrollBucket = undefined;
|
|
|
|
|
this.pendingScrollAssetId = undefined;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async loadBucketAtTime(localDateTime: string, options: { preventCancel?: boolean; pending?: boolean }) {
|
2024-04-24 15:24:19 -04:00
|
|
|
let date = fromLocalDateTime(localDateTime);
|
|
|
|
|
if (this.options.size == TimeBucketSize.Month) {
|
|
|
|
|
date = date.set({ day: 1, hour: 0, minute: 0, second: 0, millisecond: 0 });
|
|
|
|
|
} else if (this.options.size == TimeBucketSize.Day) {
|
|
|
|
|
date = date.set({ hour: 0, minute: 0, second: 0, millisecond: 0 });
|
|
|
|
|
}
|
feat(web): Scroll to asset in gridview; increase gridview perf; reduce memory; scrollbar ticks in fixed position (#10646)
* Squashed
* Change strategy - now pre-measure buckets offscreen, so don't need to worry about sub-bucket scroll preservation
* Reduce jank on scroll, delay DOM updates until after scroll
* css opt, log measure time
* Trickle out queue while scrolling, flush when stopped
* yay
* Cleanup cleanup...
* everybody...
* everywhere...
* Clean up cleanup!
* Everybody do their share
* CLEANUP!
* package-lock ?
* dynamic measure, todo
* Fix web test
* type lint
* fix e2e
* e2e test
* Better scrollbar
* Tuning, and more tunables
* Tunable tweaks, more tunables
* Scrollbar dots and viewport events
* lint
* Tweaked tunnables, use requestIdleCallback for garbage tasks, bug fixes
* New tunables, and don't update url by default
* Bug fixes
* Bug fix, with debug
* Fix flickr, fix graybox bug, reduced debug
* Refactor/cleanup
* Fix
* naming
* Final cleanup
* review comment
* Forgot to update this after naming change
* scrubber works, with debug
* cleanup
* Rename scrollbar to scrubber
* rename to
* left over rename and change to previous album bar
* bugfix addassets, comments
* missing destroy(), cleanup
---------
Co-authored-by: Alex <alex.tran1502@gmail.com>
2024-08-21 22:15:21 -04:00
|
|
|
const iso = date.toISO()!;
|
|
|
|
|
await this.loadBucket(iso, options);
|
|
|
|
|
return this.getBucketByDate(iso);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async getBucketInfoForAsset(
|
|
|
|
|
{ id, localDateTime }: Pick<AssetResponseDto, 'id' | 'localDateTime'>,
|
|
|
|
|
options: { preventCancel?: boolean; pending?: boolean } = {},
|
|
|
|
|
) {
|
|
|
|
|
const bucketInfo = this.assetToBucket[id];
|
|
|
|
|
if (bucketInfo) {
|
|
|
|
|
return bucketInfo;
|
|
|
|
|
}
|
|
|
|
|
await this.loadBucketAtTime(localDateTime, options);
|
2024-04-24 15:24:19 -04:00
|
|
|
return this.assetToBucket[id] || null;
|
2023-08-03 11:44:12 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getBucketIndexByAssetId(assetId: string) {
|
|
|
|
|
return this.assetToBucket[assetId]?.bucketIndex ?? null;
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-01 21:34:30 -04:00
|
|
|
async getRandomAsset(): Promise<AssetResponseDto | null> {
|
2024-03-05 16:43:24 +01:00
|
|
|
let index = Math.floor(
|
|
|
|
|
Math.random() * this.buckets.reduce((accumulator, bucket) => accumulator + bucket.bucketCount, 0),
|
|
|
|
|
);
|
2023-11-12 04:23:15 +03:00
|
|
|
for (const bucket of this.buckets) {
|
2024-03-05 16:43:24 +01:00
|
|
|
if (index < bucket.bucketCount) {
|
feat(web): Scroll to asset in gridview; increase gridview perf; reduce memory; scrollbar ticks in fixed position (#10646)
* Squashed
* Change strategy - now pre-measure buckets offscreen, so don't need to worry about sub-bucket scroll preservation
* Reduce jank on scroll, delay DOM updates until after scroll
* css opt, log measure time
* Trickle out queue while scrolling, flush when stopped
* yay
* Cleanup cleanup...
* everybody...
* everywhere...
* Clean up cleanup!
* Everybody do their share
* CLEANUP!
* package-lock ?
* dynamic measure, todo
* Fix web test
* type lint
* fix e2e
* e2e test
* Better scrollbar
* Tuning, and more tunables
* Tunable tweaks, more tunables
* Scrollbar dots and viewport events
* lint
* Tweaked tunnables, use requestIdleCallback for garbage tasks, bug fixes
* New tunables, and don't update url by default
* Bug fixes
* Bug fix, with debug
* Fix flickr, fix graybox bug, reduced debug
* Refactor/cleanup
* Fix
* naming
* Final cleanup
* review comment
* Forgot to update this after naming change
* scrubber works, with debug
* cleanup
* Rename scrollbar to scrubber
* rename to
* left over rename and change to previous album bar
* bugfix addassets, comments
* missing destroy(), cleanup
---------
Co-authored-by: Alex <alex.tran1502@gmail.com>
2024-08-21 22:15:21 -04:00
|
|
|
await this.loadBucket(bucket.bucketDate);
|
2023-11-12 04:23:15 +03:00
|
|
|
return bucket.assets[index] || null;
|
|
|
|
|
}
|
2023-11-01 21:34:30 -04:00
|
|
|
|
2024-03-05 16:43:24 +01:00
|
|
|
index -= bucket.bucketCount;
|
2023-11-01 21:34:30 -04:00
|
|
|
}
|
|
|
|
|
|
2023-11-12 04:23:15 +03:00
|
|
|
return null;
|
2023-11-01 21:34:30 -04:00
|
|
|
}
|
|
|
|
|
|
2024-03-15 17:11:29 +01:00
|
|
|
updateAssets(assets: AssetResponseDto[]) {
|
|
|
|
|
if (assets.length === 0) {
|
2023-08-03 11:44:12 -04:00
|
|
|
return;
|
|
|
|
|
}
|
2024-09-12 15:30:28 -04:00
|
|
|
const assetsToRecalculate: AssetResponseDto[] = [];
|
2023-08-03 11:44:12 -04:00
|
|
|
|
2024-03-15 17:11:29 +01:00
|
|
|
for (const _asset of assets) {
|
|
|
|
|
const asset = this.assets.find((asset) => asset.id === _asset.id);
|
|
|
|
|
if (!asset) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-12 15:30:28 -04:00
|
|
|
const recalculate = asset.localDateTime !== _asset.localDateTime;
|
2024-03-15 17:11:29 +01:00
|
|
|
Object.assign(asset, _asset);
|
|
|
|
|
|
|
|
|
|
if (recalculate) {
|
2024-09-12 15:30:28 -04:00
|
|
|
assetsToRecalculate.push(asset);
|
2024-03-15 17:11:29 +01:00
|
|
|
}
|
2024-02-29 18:44:30 +01:00
|
|
|
}
|
2023-08-04 23:26:28 -04:00
|
|
|
|
2024-09-12 15:30:28 -04:00
|
|
|
this.removeAssets(assetsToRecalculate.map((asset) => asset.id));
|
|
|
|
|
this.addAssetsToBuckets(assetsToRecalculate);
|
|
|
|
|
this.emit(assetsToRecalculate.length > 0);
|
2023-08-03 11:44:12 -04:00
|
|
|
}
|
|
|
|
|
|
2023-08-16 16:04:55 -04:00
|
|
|
removeAssets(ids: string[]) {
|
2024-03-02 01:49:31 +01:00
|
|
|
const idSet = new Set(ids);
|
2024-02-29 18:44:30 +01:00
|
|
|
|
2024-03-02 01:49:31 +01:00
|
|
|
// Iterate in reverse to allow array splicing.
|
|
|
|
|
for (let index = this.buckets.length - 1; index >= 0; index--) {
|
2024-02-02 04:18:00 +01:00
|
|
|
const bucket = this.buckets[index];
|
feat(web): Scroll to asset in gridview; increase gridview perf; reduce memory; scrollbar ticks in fixed position (#10646)
* Squashed
* Change strategy - now pre-measure buckets offscreen, so don't need to worry about sub-bucket scroll preservation
* Reduce jank on scroll, delay DOM updates until after scroll
* css opt, log measure time
* Trickle out queue while scrolling, flush when stopped
* yay
* Cleanup cleanup...
* everybody...
* everywhere...
* Clean up cleanup!
* Everybody do their share
* CLEANUP!
* package-lock ?
* dynamic measure, todo
* Fix web test
* type lint
* fix e2e
* e2e test
* Better scrollbar
* Tuning, and more tunables
* Tunable tweaks, more tunables
* Scrollbar dots and viewport events
* lint
* Tweaked tunnables, use requestIdleCallback for garbage tasks, bug fixes
* New tunables, and don't update url by default
* Bug fixes
* Bug fix, with debug
* Fix flickr, fix graybox bug, reduced debug
* Refactor/cleanup
* Fix
* naming
* Final cleanup
* review comment
* Forgot to update this after naming change
* scrubber works, with debug
* cleanup
* Rename scrollbar to scrubber
* rename to
* left over rename and change to previous album bar
* bugfix addassets, comments
* missing destroy(), cleanup
---------
Co-authored-by: Alex <alex.tran1502@gmail.com>
2024-08-21 22:15:21 -04:00
|
|
|
let changed = false;
|
2024-03-02 01:49:31 +01:00
|
|
|
for (let index_ = bucket.assets.length - 1; index_ >= 0; index_--) {
|
2024-02-02 04:18:00 +01:00
|
|
|
const asset = bucket.assets[index_];
|
2024-03-02 01:49:31 +01:00
|
|
|
if (!idSet.has(asset.id)) {
|
2023-08-03 11:44:12 -04:00
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-02 04:18:00 +01:00
|
|
|
bucket.assets.splice(index_, 1);
|
feat(web): Scroll to asset in gridview; increase gridview perf; reduce memory; scrollbar ticks in fixed position (#10646)
* Squashed
* Change strategy - now pre-measure buckets offscreen, so don't need to worry about sub-bucket scroll preservation
* Reduce jank on scroll, delay DOM updates until after scroll
* css opt, log measure time
* Trickle out queue while scrolling, flush when stopped
* yay
* Cleanup cleanup...
* everybody...
* everywhere...
* Clean up cleanup!
* Everybody do their share
* CLEANUP!
* package-lock ?
* dynamic measure, todo
* Fix web test
* type lint
* fix e2e
* e2e test
* Better scrollbar
* Tuning, and more tunables
* Tunable tweaks, more tunables
* Scrollbar dots and viewport events
* lint
* Tweaked tunnables, use requestIdleCallback for garbage tasks, bug fixes
* New tunables, and don't update url by default
* Bug fixes
* Bug fix, with debug
* Fix flickr, fix graybox bug, reduced debug
* Refactor/cleanup
* Fix
* naming
* Final cleanup
* review comment
* Forgot to update this after naming change
* scrubber works, with debug
* cleanup
* Rename scrollbar to scrubber
* rename to
* left over rename and change to previous album bar
* bugfix addassets, comments
* missing destroy(), cleanup
---------
Co-authored-by: Alex <alex.tran1502@gmail.com>
2024-08-21 22:15:21 -04:00
|
|
|
changed = true;
|
2024-03-16 14:22:15 +01:00
|
|
|
if (bucket.assets.length === 0) {
|
2024-02-02 04:18:00 +01:00
|
|
|
this.buckets.splice(index, 1);
|
2023-08-03 11:44:12 -04:00
|
|
|
}
|
|
|
|
|
}
|
feat(web): Scroll to asset in gridview; increase gridview perf; reduce memory; scrollbar ticks in fixed position (#10646)
* Squashed
* Change strategy - now pre-measure buckets offscreen, so don't need to worry about sub-bucket scroll preservation
* Reduce jank on scroll, delay DOM updates until after scroll
* css opt, log measure time
* Trickle out queue while scrolling, flush when stopped
* yay
* Cleanup cleanup...
* everybody...
* everywhere...
* Clean up cleanup!
* Everybody do their share
* CLEANUP!
* package-lock ?
* dynamic measure, todo
* Fix web test
* type lint
* fix e2e
* e2e test
* Better scrollbar
* Tuning, and more tunables
* Tunable tweaks, more tunables
* Scrollbar dots and viewport events
* lint
* Tweaked tunnables, use requestIdleCallback for garbage tasks, bug fixes
* New tunables, and don't update url by default
* Bug fixes
* Bug fix, with debug
* Fix flickr, fix graybox bug, reduced debug
* Refactor/cleanup
* Fix
* naming
* Final cleanup
* review comment
* Forgot to update this after naming change
* scrubber works, with debug
* cleanup
* Rename scrollbar to scrubber
* rename to
* left over rename and change to previous album bar
* bugfix addassets, comments
* missing destroy(), cleanup
---------
Co-authored-by: Alex <alex.tran1502@gmail.com>
2024-08-21 22:15:21 -04:00
|
|
|
if (changed) {
|
|
|
|
|
bucket.dateGroups = splitBucketIntoDateGroups(bucket, get(locale));
|
2025-02-22 21:16:06 +03:00
|
|
|
void this.updateGeometry(bucket, true);
|
feat(web): Scroll to asset in gridview; increase gridview perf; reduce memory; scrollbar ticks in fixed position (#10646)
* Squashed
* Change strategy - now pre-measure buckets offscreen, so don't need to worry about sub-bucket scroll preservation
* Reduce jank on scroll, delay DOM updates until after scroll
* css opt, log measure time
* Trickle out queue while scrolling, flush when stopped
* yay
* Cleanup cleanup...
* everybody...
* everywhere...
* Clean up cleanup!
* Everybody do their share
* CLEANUP!
* package-lock ?
* dynamic measure, todo
* Fix web test
* type lint
* fix e2e
* e2e test
* Better scrollbar
* Tuning, and more tunables
* Tunable tweaks, more tunables
* Scrollbar dots and viewport events
* lint
* Tweaked tunnables, use requestIdleCallback for garbage tasks, bug fixes
* New tunables, and don't update url by default
* Bug fixes
* Bug fix, with debug
* Fix flickr, fix graybox bug, reduced debug
* Refactor/cleanup
* Fix
* naming
* Final cleanup
* review comment
* Forgot to update this after naming change
* scrubber works, with debug
* cleanup
* Rename scrollbar to scrubber
* rename to
* left over rename and change to previous album bar
* bugfix addassets, comments
* missing destroy(), cleanup
---------
Co-authored-by: Alex <alex.tran1502@gmail.com>
2024-08-21 22:15:21 -04:00
|
|
|
}
|
2023-08-03 11:44:12 -04:00
|
|
|
}
|
2024-03-02 01:49:31 +01:00
|
|
|
|
2024-03-16 14:22:15 +01:00
|
|
|
this.emit(true);
|
2023-08-03 11:44:12 -04:00
|
|
|
}
|
|
|
|
|
|
2024-04-24 15:24:19 -04:00
|
|
|
async getPreviousAsset(asset: AssetResponseDto): Promise<AssetResponseDto | null> {
|
feat(web): Scroll to asset in gridview; increase gridview perf; reduce memory; scrollbar ticks in fixed position (#10646)
* Squashed
* Change strategy - now pre-measure buckets offscreen, so don't need to worry about sub-bucket scroll preservation
* Reduce jank on scroll, delay DOM updates until after scroll
* css opt, log measure time
* Trickle out queue while scrolling, flush when stopped
* yay
* Cleanup cleanup...
* everybody...
* everywhere...
* Clean up cleanup!
* Everybody do their share
* CLEANUP!
* package-lock ?
* dynamic measure, todo
* Fix web test
* type lint
* fix e2e
* e2e test
* Better scrollbar
* Tuning, and more tunables
* Tunable tweaks, more tunables
* Scrollbar dots and viewport events
* lint
* Tweaked tunnables, use requestIdleCallback for garbage tasks, bug fixes
* New tunables, and don't update url by default
* Bug fixes
* Bug fix, with debug
* Fix flickr, fix graybox bug, reduced debug
* Refactor/cleanup
* Fix
* naming
* Final cleanup
* review comment
* Forgot to update this after naming change
* scrubber works, with debug
* cleanup
* Rename scrollbar to scrubber
* rename to
* left over rename and change to previous album bar
* bugfix addassets, comments
* missing destroy(), cleanup
---------
Co-authored-by: Alex <alex.tran1502@gmail.com>
2024-08-21 22:15:21 -04:00
|
|
|
const info = await this.getBucketInfoForAsset(asset);
|
2023-08-03 11:44:12 -04:00
|
|
|
if (!info) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const { bucket, assetIndex, bucketIndex } = info;
|
|
|
|
|
|
|
|
|
|
if (assetIndex !== 0) {
|
2024-04-04 03:20:54 +02:00
|
|
|
return bucket.assets[assetIndex - 1];
|
2023-08-03 11:44:12 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (bucketIndex === 0) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const previousBucket = this.buckets[bucketIndex - 1];
|
feat(web): Scroll to asset in gridview; increase gridview perf; reduce memory; scrollbar ticks in fixed position (#10646)
* Squashed
* Change strategy - now pre-measure buckets offscreen, so don't need to worry about sub-bucket scroll preservation
* Reduce jank on scroll, delay DOM updates until after scroll
* css opt, log measure time
* Trickle out queue while scrolling, flush when stopped
* yay
* Cleanup cleanup...
* everybody...
* everywhere...
* Clean up cleanup!
* Everybody do their share
* CLEANUP!
* package-lock ?
* dynamic measure, todo
* Fix web test
* type lint
* fix e2e
* e2e test
* Better scrollbar
* Tuning, and more tunables
* Tunable tweaks, more tunables
* Scrollbar dots and viewport events
* lint
* Tweaked tunnables, use requestIdleCallback for garbage tasks, bug fixes
* New tunables, and don't update url by default
* Bug fixes
* Bug fix, with debug
* Fix flickr, fix graybox bug, reduced debug
* Refactor/cleanup
* Fix
* naming
* Final cleanup
* review comment
* Forgot to update this after naming change
* scrubber works, with debug
* cleanup
* Rename scrollbar to scrubber
* rename to
* left over rename and change to previous album bar
* bugfix addassets, comments
* missing destroy(), cleanup
---------
Co-authored-by: Alex <alex.tran1502@gmail.com>
2024-08-21 22:15:21 -04:00
|
|
|
await this.loadBucket(previousBucket.bucketDate);
|
2024-04-04 03:20:54 +02:00
|
|
|
return previousBucket.assets.at(-1) || null;
|
2023-08-03 11:44:12 -04:00
|
|
|
}
|
|
|
|
|
|
2024-04-24 15:24:19 -04:00
|
|
|
async getNextAsset(asset: AssetResponseDto): Promise<AssetResponseDto | null> {
|
feat(web): Scroll to asset in gridview; increase gridview perf; reduce memory; scrollbar ticks in fixed position (#10646)
* Squashed
* Change strategy - now pre-measure buckets offscreen, so don't need to worry about sub-bucket scroll preservation
* Reduce jank on scroll, delay DOM updates until after scroll
* css opt, log measure time
* Trickle out queue while scrolling, flush when stopped
* yay
* Cleanup cleanup...
* everybody...
* everywhere...
* Clean up cleanup!
* Everybody do their share
* CLEANUP!
* package-lock ?
* dynamic measure, todo
* Fix web test
* type lint
* fix e2e
* e2e test
* Better scrollbar
* Tuning, and more tunables
* Tunable tweaks, more tunables
* Scrollbar dots and viewport events
* lint
* Tweaked tunnables, use requestIdleCallback for garbage tasks, bug fixes
* New tunables, and don't update url by default
* Bug fixes
* Bug fix, with debug
* Fix flickr, fix graybox bug, reduced debug
* Refactor/cleanup
* Fix
* naming
* Final cleanup
* review comment
* Forgot to update this after naming change
* scrubber works, with debug
* cleanup
* Rename scrollbar to scrubber
* rename to
* left over rename and change to previous album bar
* bugfix addassets, comments
* missing destroy(), cleanup
---------
Co-authored-by: Alex <alex.tran1502@gmail.com>
2024-08-21 22:15:21 -04:00
|
|
|
const info = await this.getBucketInfoForAsset(asset);
|
2023-08-03 11:44:12 -04:00
|
|
|
if (!info) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const { bucket, assetIndex, bucketIndex } = info;
|
|
|
|
|
|
|
|
|
|
if (assetIndex !== bucket.assets.length - 1) {
|
2024-04-04 03:20:54 +02:00
|
|
|
return bucket.assets[assetIndex + 1];
|
2023-08-03 11:44:12 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (bucketIndex === this.buckets.length - 1) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const nextBucket = this.buckets[bucketIndex + 1];
|
feat(web): Scroll to asset in gridview; increase gridview perf; reduce memory; scrollbar ticks in fixed position (#10646)
* Squashed
* Change strategy - now pre-measure buckets offscreen, so don't need to worry about sub-bucket scroll preservation
* Reduce jank on scroll, delay DOM updates until after scroll
* css opt, log measure time
* Trickle out queue while scrolling, flush when stopped
* yay
* Cleanup cleanup...
* everybody...
* everywhere...
* Clean up cleanup!
* Everybody do their share
* CLEANUP!
* package-lock ?
* dynamic measure, todo
* Fix web test
* type lint
* fix e2e
* e2e test
* Better scrollbar
* Tuning, and more tunables
* Tunable tweaks, more tunables
* Scrollbar dots and viewport events
* lint
* Tweaked tunnables, use requestIdleCallback for garbage tasks, bug fixes
* New tunables, and don't update url by default
* Bug fixes
* Bug fix, with debug
* Fix flickr, fix graybox bug, reduced debug
* Refactor/cleanup
* Fix
* naming
* Final cleanup
* review comment
* Forgot to update this after naming change
* scrubber works, with debug
* cleanup
* Rename scrollbar to scrubber
* rename to
* left over rename and change to previous album bar
* bugfix addassets, comments
* missing destroy(), cleanup
---------
Co-authored-by: Alex <alex.tran1502@gmail.com>
2024-08-21 22:15:21 -04:00
|
|
|
await this.loadBucket(nextBucket.bucketDate);
|
2024-04-04 03:20:54 +02:00
|
|
|
return nextBucket.assets[0] || null;
|
2023-08-03 11:44:12 -04:00
|
|
|
}
|
|
|
|
|
|
2024-02-20 17:01:52 +01:00
|
|
|
triggerUpdate() {
|
|
|
|
|
this.emit(false);
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-03 11:44:12 -04:00
|
|
|
private emit(recalculate: boolean) {
|
|
|
|
|
if (recalculate) {
|
|
|
|
|
this.assets = this.buckets.flatMap(({ assets }) => assets);
|
|
|
|
|
|
|
|
|
|
const assetToBucket: Record<string, AssetLookup> = {};
|
2024-02-02 04:18:00 +01:00
|
|
|
for (let index = 0; index < this.buckets.length; index++) {
|
|
|
|
|
const bucket = this.buckets[index];
|
|
|
|
|
if (bucket.assets.length > 0) {
|
2024-03-05 16:43:24 +01:00
|
|
|
bucket.bucketCount = bucket.assets.length;
|
2023-11-12 04:23:15 +03:00
|
|
|
}
|
2024-02-02 04:18:00 +01:00
|
|
|
for (let index_ = 0; index_ < bucket.assets.length; index_++) {
|
|
|
|
|
const asset = bucket.assets[index_];
|
|
|
|
|
assetToBucket[asset.id] = { bucket, bucketIndex: index, assetIndex: index_ };
|
2023-08-03 11:44:12 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
this.assetToBucket = assetToBucket;
|
|
|
|
|
}
|
feat(web): Scroll to asset in gridview; increase gridview perf; reduce memory; scrollbar ticks in fixed position (#10646)
* Squashed
* Change strategy - now pre-measure buckets offscreen, so don't need to worry about sub-bucket scroll preservation
* Reduce jank on scroll, delay DOM updates until after scroll
* css opt, log measure time
* Trickle out queue while scrolling, flush when stopped
* yay
* Cleanup cleanup...
* everybody...
* everywhere...
* Clean up cleanup!
* Everybody do their share
* CLEANUP!
* package-lock ?
* dynamic measure, todo
* Fix web test
* type lint
* fix e2e
* e2e test
* Better scrollbar
* Tuning, and more tunables
* Tunable tweaks, more tunables
* Scrollbar dots and viewport events
* lint
* Tweaked tunnables, use requestIdleCallback for garbage tasks, bug fixes
* New tunables, and don't update url by default
* Bug fixes
* Bug fix, with debug
* Fix flickr, fix graybox bug, reduced debug
* Refactor/cleanup
* Fix
* naming
* Final cleanup
* review comment
* Forgot to update this after naming change
* scrubber works, with debug
* cleanup
* Rename scrollbar to scrubber
* rename to
* left over rename and change to previous album bar
* bugfix addassets, comments
* missing destroy(), cleanup
---------
Co-authored-by: Alex <alex.tran1502@gmail.com>
2024-08-21 22:15:21 -04:00
|
|
|
this.store$.set(this);
|
2023-08-03 11:44:12 -04:00
|
|
|
}
|
2024-09-18 15:22:34 -04:00
|
|
|
|
|
|
|
|
private isExcluded(asset: AssetResponseDto) {
|
|
|
|
|
return (
|
|
|
|
|
isMismatched(this.options.isArchived ?? false, asset.isArchived) ||
|
|
|
|
|
isMismatched(this.options.isFavorite, asset.isFavorite) ||
|
|
|
|
|
isMismatched(this.options.isTrashed ?? false, asset.isTrashed)
|
|
|
|
|
);
|
|
|
|
|
}
|
2022-09-04 08:34:39 -05:00
|
|
|
}
|
2024-01-01 17:18:22 +01:00
|
|
|
|
2024-03-21 13:14:13 +01:00
|
|
|
export const isSelectingAllAssets = writable(false);
|