2024-03-20 05:41:31 +01:00
|
|
|
import { sdkMock } from '$lib/__mocks__/sdk.mock';
|
2024-03-20 20:40:41 +01:00
|
|
|
import { AbortError } from '$lib/utils';
|
2024-03-20 05:41:31 +01:00
|
|
|
import { TimeBucketSize, type AssetResponseDto } from '@immich/sdk';
|
|
|
|
|
import { assetFactory } from '@test-data/factories/asset-factory';
|
2025-03-04 21:34:53 -05:00
|
|
|
import { AssetStore } from './assets-store.svelte';
|
2024-03-20 05:41:31 +01:00
|
|
|
|
|
|
|
|
describe('AssetStore', () => {
|
|
|
|
|
beforeEach(() => {
|
|
|
|
|
vi.resetAllMocks();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('init', () => {
|
|
|
|
|
let assetStore: AssetStore;
|
|
|
|
|
const bucketAssets: Record<string, AssetResponseDto[]> = {
|
|
|
|
|
'2024-03-01T00:00:00.000Z': assetFactory.buildList(1),
|
|
|
|
|
'2024-02-01T00:00:00.000Z': assetFactory.buildList(100),
|
|
|
|
|
'2024-01-01T00:00:00.000Z': assetFactory.buildList(3),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
beforeEach(async () => {
|
|
|
|
|
assetStore = new AssetStore({});
|
|
|
|
|
sdkMock.getTimeBuckets.mockResolvedValue([
|
|
|
|
|
{ count: 1, timeBucket: '2024-03-01T00:00:00.000Z' },
|
|
|
|
|
{ count: 100, timeBucket: '2024-02-01T00:00:00.000Z' },
|
|
|
|
|
{ count: 3, timeBucket: '2024-01-01T00:00:00.000Z' },
|
|
|
|
|
]);
|
|
|
|
|
sdkMock.getTimeBucket.mockImplementation(({ timeBucket }) => Promise.resolve(bucketAssets[timeBucket]));
|
|
|
|
|
|
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 assetStore.init();
|
|
|
|
|
await assetStore.updateViewport({ width: 1588, height: 1000 });
|
2024-03-20 05:41:31 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should load buckets in viewport', () => {
|
|
|
|
|
expect(sdkMock.getTimeBuckets).toBeCalledTimes(1);
|
|
|
|
|
expect(sdkMock.getTimeBuckets).toBeCalledWith({ size: TimeBucketSize.Month });
|
|
|
|
|
expect(sdkMock.getTimeBucket).toHaveBeenCalledTimes(2);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('calculates bucket height', () => {
|
|
|
|
|
expect(assetStore.buckets).toEqual(
|
|
|
|
|
expect.arrayContaining([
|
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
|
|
|
expect.objectContaining({ bucketDate: '2024-03-01T00:00:00.000Z', bucketHeight: 286 }),
|
|
|
|
|
expect.objectContaining({ bucketDate: '2024-02-01T00:00:00.000Z', bucketHeight: 3811 }),
|
|
|
|
|
expect.objectContaining({ bucketDate: '2024-01-01T00:00:00.000Z', bucketHeight: 286 }),
|
2024-03-20 05:41:31 +01:00
|
|
|
]),
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('calculates timeline 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
|
|
|
expect(assetStore.timelineHeight).toBe(4383);
|
2024-03-20 05:41:31 +01:00
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('loadBucket', () => {
|
|
|
|
|
let assetStore: AssetStore;
|
|
|
|
|
const bucketAssets: Record<string, AssetResponseDto[]> = {
|
|
|
|
|
'2024-01-03T00:00:00.000Z': assetFactory.buildList(1),
|
|
|
|
|
'2024-01-01T00:00:00.000Z': assetFactory.buildList(3),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
beforeEach(async () => {
|
|
|
|
|
assetStore = new AssetStore({});
|
|
|
|
|
sdkMock.getTimeBuckets.mockResolvedValue([
|
|
|
|
|
{ count: 1, timeBucket: '2024-01-03T00:00:00.000Z' },
|
|
|
|
|
{ count: 3, timeBucket: '2024-01-01T00:00:00.000Z' },
|
|
|
|
|
]);
|
2024-03-20 20:40:41 +01:00
|
|
|
sdkMock.getTimeBucket.mockImplementation(async ({ timeBucket }, { signal } = {}) => {
|
|
|
|
|
// Allow request to be aborted
|
|
|
|
|
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
|
|
|
if (signal?.aborted) {
|
|
|
|
|
throw new AbortError();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return bucketAssets[timeBucket];
|
|
|
|
|
});
|
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 assetStore.init();
|
|
|
|
|
await assetStore.updateViewport({ width: 0, height: 0 });
|
2024-03-20 05:41:31 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('loads a bucket', async () => {
|
|
|
|
|
expect(assetStore.getBucketByDate('2024-01-01T00:00:00.000Z')?.assets.length).toEqual(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
|
|
|
await assetStore.loadBucket('2024-01-01T00:00:00.000Z');
|
2024-03-20 05:41:31 +01:00
|
|
|
expect(sdkMock.getTimeBucket).toBeCalledTimes(1);
|
|
|
|
|
expect(assetStore.getBucketByDate('2024-01-01T00:00:00.000Z')?.assets.length).toEqual(3);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('ignores invalid buckets', async () => {
|
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 assetStore.loadBucket('2023-01-01T00:00:00.000Z');
|
2024-03-20 05:41:31 +01:00
|
|
|
expect(sdkMock.getTimeBucket).toBeCalledTimes(0);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('cancels bucket loading', async () => {
|
|
|
|
|
const bucket = assetStore.getBucketByDate('2024-01-01T00:00:00.000Z');
|
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 loadPromise = assetStore.loadBucket(bucket!.bucketDate);
|
2024-03-20 05:41:31 +01:00
|
|
|
|
2024-03-20 20:40:41 +01:00
|
|
|
const abortSpy = vi.spyOn(bucket!.cancelToken!, 'abort');
|
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?.cancel();
|
2024-03-20 05:41:31 +01:00
|
|
|
expect(abortSpy).toBeCalledTimes(1);
|
2024-03-20 20:40:41 +01:00
|
|
|
|
2024-03-20 05:41:31 +01:00
|
|
|
await loadPromise;
|
|
|
|
|
expect(assetStore.getBucketByDate('2024-01-01T00:00:00.000Z')?.assets.length).toEqual(0);
|
|
|
|
|
});
|
2024-03-20 20:40:41 +01:00
|
|
|
|
|
|
|
|
it('prevents loading buckets multiple times', async () => {
|
|
|
|
|
await Promise.all([
|
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
|
|
|
assetStore.loadBucket('2024-01-01T00:00:00.000Z'),
|
|
|
|
|
assetStore.loadBucket('2024-01-01T00:00:00.000Z'),
|
2024-03-20 20:40:41 +01:00
|
|
|
]);
|
|
|
|
|
expect(sdkMock.getTimeBucket).toBeCalledTimes(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 assetStore.loadBucket('2024-01-01T00:00:00.000Z');
|
2024-03-20 20:40:41 +01:00
|
|
|
expect(sdkMock.getTimeBucket).toBeCalledTimes(1);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('allows loading a canceled bucket', async () => {
|
|
|
|
|
const bucket = assetStore.getBucketByDate('2024-01-01T00:00:00.000Z');
|
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 loadPromise = assetStore.loadBucket(bucket!.bucketDate);
|
2024-03-20 20:40:41 +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
|
|
|
bucket?.cancel();
|
2024-03-20 20:40:41 +01:00
|
|
|
await loadPromise;
|
|
|
|
|
expect(bucket?.assets.length).toEqual(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
|
|
|
await assetStore.loadBucket(bucket!.bucketDate);
|
2024-03-20 20:40:41 +01:00
|
|
|
expect(bucket!.assets.length).toEqual(3);
|
|
|
|
|
});
|
2024-03-20 05:41:31 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('addAssets', () => {
|
|
|
|
|
let assetStore: AssetStore;
|
|
|
|
|
|
|
|
|
|
beforeEach(async () => {
|
|
|
|
|
assetStore = new AssetStore({});
|
|
|
|
|
sdkMock.getTimeBuckets.mockResolvedValue([]);
|
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 assetStore.init();
|
|
|
|
|
await assetStore.updateViewport({ width: 1588, height: 1000 });
|
2024-03-20 05:41:31 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('is empty initially', () => {
|
|
|
|
|
expect(assetStore.buckets.length).toEqual(0);
|
|
|
|
|
expect(assetStore.assets.length).toEqual(0);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('adds assets to new bucket', () => {
|
2024-09-12 15:30:28 -04:00
|
|
|
const asset = assetFactory.build({
|
|
|
|
|
localDateTime: '2024-01-20T12:00:00.000Z',
|
|
|
|
|
fileCreatedAt: '2024-01-20T12:00:00.000Z',
|
|
|
|
|
});
|
2024-03-20 05:41:31 +01:00
|
|
|
assetStore.addAssets([asset]);
|
|
|
|
|
|
|
|
|
|
expect(assetStore.buckets.length).toEqual(1);
|
|
|
|
|
expect(assetStore.assets.length).toEqual(1);
|
|
|
|
|
expect(assetStore.buckets[0].assets.length).toEqual(1);
|
|
|
|
|
expect(assetStore.buckets[0].bucketDate).toEqual('2024-01-01T00:00:00.000Z');
|
|
|
|
|
expect(assetStore.assets[0].id).toEqual(asset.id);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('adds assets to existing bucket', () => {
|
2024-09-12 15:30:28 -04:00
|
|
|
const [assetOne, assetTwo] = assetFactory.buildList(2, {
|
|
|
|
|
localDateTime: '2024-01-20T12:00:00.000Z',
|
|
|
|
|
fileCreatedAt: '2024-01-20T12:00:00.000Z',
|
|
|
|
|
});
|
2024-03-20 05:41:31 +01:00
|
|
|
assetStore.addAssets([assetOne]);
|
|
|
|
|
assetStore.addAssets([assetTwo]);
|
|
|
|
|
|
|
|
|
|
expect(assetStore.buckets.length).toEqual(1);
|
|
|
|
|
expect(assetStore.assets.length).toEqual(2);
|
|
|
|
|
expect(assetStore.buckets[0].assets.length).toEqual(2);
|
|
|
|
|
expect(assetStore.buckets[0].bucketDate).toEqual('2024-01-01T00:00:00.000Z');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('orders assets in buckets by descending date', () => {
|
2024-09-12 15:30:28 -04:00
|
|
|
const assetOne = assetFactory.build({
|
|
|
|
|
fileCreatedAt: '2024-01-20T12:00:00.000Z',
|
|
|
|
|
localDateTime: '2024-01-20T12:00:00.000Z',
|
|
|
|
|
});
|
|
|
|
|
const assetTwo = assetFactory.build({
|
|
|
|
|
fileCreatedAt: '2024-01-15T12:00:00.000Z',
|
|
|
|
|
localDateTime: '2024-01-15T12:00:00.000Z',
|
|
|
|
|
});
|
|
|
|
|
const assetThree = assetFactory.build({
|
|
|
|
|
fileCreatedAt: '2024-01-16T12:00:00.000Z',
|
|
|
|
|
localDateTime: '2024-01-16T12:00:00.000Z',
|
|
|
|
|
});
|
2024-03-20 05:41:31 +01:00
|
|
|
assetStore.addAssets([assetOne, assetTwo, assetThree]);
|
|
|
|
|
|
|
|
|
|
const bucket = assetStore.getBucketByDate('2024-01-01T00:00:00.000Z');
|
|
|
|
|
expect(bucket).not.toBeNull();
|
|
|
|
|
expect(bucket?.assets.length).toEqual(3);
|
|
|
|
|
expect(bucket?.assets[0].id).toEqual(assetOne.id);
|
|
|
|
|
expect(bucket?.assets[1].id).toEqual(assetThree.id);
|
|
|
|
|
expect(bucket?.assets[2].id).toEqual(assetTwo.id);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('orders buckets by descending date', () => {
|
2024-09-12 15:30:28 -04:00
|
|
|
const assetOne = assetFactory.build({ localDateTime: '2024-01-20T12:00:00.000Z' });
|
|
|
|
|
const assetTwo = assetFactory.build({ localDateTime: '2024-04-20T12:00:00.000Z' });
|
|
|
|
|
const assetThree = assetFactory.build({ localDateTime: '2023-01-20T12:00:00.000Z' });
|
2024-03-20 05:41:31 +01:00
|
|
|
assetStore.addAssets([assetOne, assetTwo, assetThree]);
|
|
|
|
|
|
|
|
|
|
expect(assetStore.buckets.length).toEqual(3);
|
|
|
|
|
expect(assetStore.buckets[0].bucketDate).toEqual('2024-04-01T00:00:00.000Z');
|
|
|
|
|
expect(assetStore.buckets[1].bucketDate).toEqual('2024-01-01T00:00:00.000Z');
|
|
|
|
|
expect(assetStore.buckets[2].bucketDate).toEqual('2023-01-01T00:00:00.000Z');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('updates existing asset', () => {
|
|
|
|
|
const updateAssetsSpy = vi.spyOn(assetStore, 'updateAssets');
|
|
|
|
|
const asset = assetFactory.build();
|
|
|
|
|
assetStore.addAssets([asset]);
|
|
|
|
|
|
|
|
|
|
assetStore.addAssets([asset]);
|
|
|
|
|
expect(updateAssetsSpy).toBeCalledWith([asset]);
|
|
|
|
|
expect(assetStore.assets.length).toEqual(1);
|
|
|
|
|
});
|
2024-06-15 19:44:18 +02:00
|
|
|
|
2025-03-04 21:34:53 -05:00
|
|
|
// disabled due to the wasm Justified Layout import
|
|
|
|
|
it.skip('ignores trashed assets when isTrashed is true', () => {
|
2024-06-15 19:44:18 +02:00
|
|
|
const asset = assetFactory.build({ isTrashed: false });
|
|
|
|
|
const trashedAsset = assetFactory.build({ isTrashed: true });
|
|
|
|
|
|
|
|
|
|
const assetStore = new AssetStore({ isTrashed: true });
|
|
|
|
|
assetStore.addAssets([asset, trashedAsset]);
|
|
|
|
|
expect(assetStore.assets).toEqual([trashedAsset]);
|
|
|
|
|
});
|
2024-03-20 05:41:31 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('updateAssets', () => {
|
|
|
|
|
let assetStore: AssetStore;
|
|
|
|
|
|
|
|
|
|
beforeEach(async () => {
|
|
|
|
|
assetStore = new AssetStore({});
|
|
|
|
|
sdkMock.getTimeBuckets.mockResolvedValue([]);
|
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 assetStore.init();
|
|
|
|
|
await assetStore.updateViewport({ width: 1588, height: 1000 });
|
2024-03-20 05:41:31 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('ignores non-existing assets', () => {
|
|
|
|
|
assetStore.updateAssets([assetFactory.build()]);
|
|
|
|
|
|
|
|
|
|
expect(assetStore.buckets.length).toEqual(0);
|
|
|
|
|
expect(assetStore.assets.length).toEqual(0);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('updates an asset', () => {
|
|
|
|
|
const asset = assetFactory.build({ isFavorite: false });
|
|
|
|
|
const updatedAsset = { ...asset, isFavorite: true };
|
|
|
|
|
|
|
|
|
|
assetStore.addAssets([asset]);
|
|
|
|
|
expect(assetStore.assets.length).toEqual(1);
|
|
|
|
|
expect(assetStore.assets[0].isFavorite).toEqual(false);
|
|
|
|
|
|
|
|
|
|
assetStore.updateAssets([updatedAsset]);
|
|
|
|
|
expect(assetStore.assets.length).toEqual(1);
|
|
|
|
|
expect(assetStore.assets[0].isFavorite).toEqual(true);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('replaces bucket date when asset date changes', () => {
|
2024-09-12 15:30:28 -04:00
|
|
|
const asset = assetFactory.build({ localDateTime: '2024-01-20T12:00:00.000Z' });
|
|
|
|
|
const updatedAsset = { ...asset, localDateTime: '2024-03-20T12:00:00.000Z' };
|
2024-03-20 05:41:31 +01:00
|
|
|
|
|
|
|
|
assetStore.addAssets([asset]);
|
|
|
|
|
expect(assetStore.buckets.length).toEqual(1);
|
|
|
|
|
expect(assetStore.getBucketByDate('2024-01-01T00:00:00.000Z')).not.toBeNull();
|
|
|
|
|
|
|
|
|
|
assetStore.updateAssets([updatedAsset]);
|
|
|
|
|
expect(assetStore.buckets.length).toEqual(1);
|
|
|
|
|
expect(assetStore.getBucketByDate('2024-01-01T00:00:00.000Z')).toBeNull();
|
|
|
|
|
expect(assetStore.getBucketByDate('2024-03-01T00:00:00.000Z')).not.toBeNull();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('removeAssets', () => {
|
|
|
|
|
let assetStore: AssetStore;
|
|
|
|
|
|
|
|
|
|
beforeEach(async () => {
|
|
|
|
|
assetStore = new AssetStore({});
|
|
|
|
|
sdkMock.getTimeBuckets.mockResolvedValue([]);
|
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 assetStore.init();
|
|
|
|
|
await assetStore.updateViewport({ width: 1588, height: 1000 });
|
2024-03-20 05:41:31 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('ignores invalid IDs', () => {
|
2024-09-12 15:30:28 -04:00
|
|
|
assetStore.addAssets(assetFactory.buildList(2, { localDateTime: '2024-01-20T12:00:00.000Z' }));
|
2024-03-20 05:41:31 +01:00
|
|
|
assetStore.removeAssets(['', 'invalid', '4c7d9acc']);
|
|
|
|
|
|
|
|
|
|
expect(assetStore.assets.length).toEqual(2);
|
|
|
|
|
expect(assetStore.buckets.length).toEqual(1);
|
|
|
|
|
expect(assetStore.buckets[0].assets.length).toEqual(2);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('removes asset from bucket', () => {
|
2024-09-12 15:30:28 -04:00
|
|
|
const [assetOne, assetTwo] = assetFactory.buildList(2, { localDateTime: '2024-01-20T12:00:00.000Z' });
|
2024-03-20 05:41:31 +01:00
|
|
|
assetStore.addAssets([assetOne, assetTwo]);
|
|
|
|
|
assetStore.removeAssets([assetOne.id]);
|
|
|
|
|
|
|
|
|
|
expect(assetStore.assets.length).toEqual(1);
|
|
|
|
|
expect(assetStore.buckets.length).toEqual(1);
|
|
|
|
|
expect(assetStore.buckets[0].assets.length).toEqual(1);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('removes bucket when empty', () => {
|
2024-09-12 15:30:28 -04:00
|
|
|
const assets = assetFactory.buildList(2, { localDateTime: '2024-01-20T12:00:00.000Z' });
|
2024-03-20 05:41:31 +01:00
|
|
|
assetStore.addAssets(assets);
|
|
|
|
|
assetStore.removeAssets(assets.map((asset) => asset.id));
|
|
|
|
|
|
|
|
|
|
expect(assetStore.assets.length).toEqual(0);
|
|
|
|
|
expect(assetStore.buckets.length).toEqual(0);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2025-03-12 02:18:14 +11:00
|
|
|
describe('firstAsset', () => {
|
|
|
|
|
let assetStore: AssetStore;
|
|
|
|
|
|
|
|
|
|
beforeEach(async () => {
|
|
|
|
|
assetStore = new AssetStore({});
|
|
|
|
|
sdkMock.getTimeBuckets.mockResolvedValue([]);
|
|
|
|
|
await assetStore.init();
|
|
|
|
|
await assetStore.updateViewport({ width: 0, height: 0 });
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('empty store returns null', () => {
|
|
|
|
|
expect(assetStore.getFirstAsset()).toBeNull();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('populated store returns first asset', () => {
|
|
|
|
|
const assetOne = assetFactory.build({
|
|
|
|
|
fileCreatedAt: '2024-01-20T12:00:00.000Z',
|
|
|
|
|
localDateTime: '2024-01-20T12:00:00.000Z',
|
|
|
|
|
});
|
|
|
|
|
const assetTwo = assetFactory.build({
|
|
|
|
|
fileCreatedAt: '2024-01-15T12:00:00.000Z',
|
|
|
|
|
localDateTime: '2024-01-15T12:00:00.000Z',
|
|
|
|
|
});
|
|
|
|
|
assetStore.addAssets([assetOne, assetTwo]);
|
|
|
|
|
expect(assetStore.getFirstAsset()).toEqual(assetOne);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2024-04-04 03:20:54 +02:00
|
|
|
describe('getPreviousAsset', () => {
|
2024-03-20 05:41:31 +01:00
|
|
|
let assetStore: AssetStore;
|
|
|
|
|
const bucketAssets: Record<string, AssetResponseDto[]> = {
|
|
|
|
|
'2024-03-01T00:00:00.000Z': assetFactory.buildList(1),
|
|
|
|
|
'2024-02-01T00:00:00.000Z': assetFactory.buildList(6),
|
|
|
|
|
'2024-01-01T00:00:00.000Z': assetFactory.buildList(3),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
beforeEach(async () => {
|
|
|
|
|
assetStore = new AssetStore({});
|
|
|
|
|
sdkMock.getTimeBuckets.mockResolvedValue([
|
|
|
|
|
{ count: 1, timeBucket: '2024-03-01T00:00:00.000Z' },
|
|
|
|
|
{ count: 6, timeBucket: '2024-02-01T00:00:00.000Z' },
|
|
|
|
|
{ count: 3, timeBucket: '2024-01-01T00:00:00.000Z' },
|
|
|
|
|
]);
|
|
|
|
|
sdkMock.getTimeBucket.mockImplementation(({ timeBucket }) => Promise.resolve(bucketAssets[timeBucket]));
|
|
|
|
|
|
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 assetStore.init();
|
|
|
|
|
await assetStore.updateViewport({ width: 0, height: 0 });
|
2024-03-20 05:41:31 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('returns null for invalid assetId', async () => {
|
2024-04-24 15:24:19 -04:00
|
|
|
expect(() => assetStore.getPreviousAsset({ id: 'invalid' } as AssetResponseDto)).not.toThrow();
|
|
|
|
|
expect(await assetStore.getPreviousAsset({ id: 'invalid' } as AssetResponseDto)).toBeNull();
|
2024-03-20 05:41:31 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('returns previous assetId', async () => {
|
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 assetStore.loadBucket('2024-01-01T00:00:00.000Z');
|
2024-03-20 05:41:31 +01:00
|
|
|
const bucket = assetStore.getBucketByDate('2024-01-01T00:00:00.000Z');
|
|
|
|
|
|
2024-04-24 15:24:19 -04:00
|
|
|
expect(await assetStore.getPreviousAsset(bucket!.assets[1])).toEqual(bucket!.assets[0]);
|
2024-03-20 05:41:31 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('returns previous assetId spanning multiple buckets', async () => {
|
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 assetStore.loadBucket('2024-02-01T00:00:00.000Z');
|
|
|
|
|
await assetStore.loadBucket('2024-03-01T00:00:00.000Z');
|
2024-03-20 05:41:31 +01:00
|
|
|
|
|
|
|
|
const bucket = assetStore.getBucketByDate('2024-02-01T00:00:00.000Z');
|
|
|
|
|
const previousBucket = assetStore.getBucketByDate('2024-03-01T00:00:00.000Z');
|
2024-04-24 15:24:19 -04:00
|
|
|
expect(await assetStore.getPreviousAsset(bucket!.assets[0])).toEqual(previousBucket!.assets[0]);
|
2024-03-20 05:41:31 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('loads previous bucket', async () => {
|
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 assetStore.loadBucket('2024-02-01T00:00:00.000Z');
|
2024-03-20 05:41:31 +01:00
|
|
|
|
|
|
|
|
const loadBucketSpy = vi.spyOn(assetStore, 'loadBucket');
|
|
|
|
|
const bucket = assetStore.getBucketByDate('2024-02-01T00:00:00.000Z');
|
|
|
|
|
const previousBucket = assetStore.getBucketByDate('2024-03-01T00:00:00.000Z');
|
2024-04-24 15:24:19 -04:00
|
|
|
expect(await assetStore.getPreviousAsset(bucket!.assets[0])).toEqual(previousBucket!.assets[0]);
|
2024-03-20 05:41:31 +01:00
|
|
|
expect(loadBucketSpy).toBeCalledTimes(1);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('skips removed assets', async () => {
|
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 assetStore.loadBucket('2024-01-01T00:00:00.000Z');
|
|
|
|
|
await assetStore.loadBucket('2024-02-01T00:00:00.000Z');
|
|
|
|
|
await assetStore.loadBucket('2024-03-01T00:00:00.000Z');
|
2024-03-20 05:41:31 +01:00
|
|
|
|
|
|
|
|
const [assetOne, assetTwo, assetThree] = assetStore.assets;
|
|
|
|
|
assetStore.removeAssets([assetTwo.id]);
|
2024-04-24 15:24:19 -04:00
|
|
|
expect(await assetStore.getPreviousAsset(assetThree)).toEqual(assetOne);
|
2024-03-20 05:41:31 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('returns null when no more assets', async () => {
|
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 assetStore.loadBucket('2024-03-01T00:00:00.000Z');
|
2024-04-24 15:24:19 -04:00
|
|
|
expect(await assetStore.getPreviousAsset(assetStore.assets[0])).toBeNull();
|
2024-03-20 05:41:31 +01:00
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('getBucketIndexByAssetId', () => {
|
|
|
|
|
let assetStore: AssetStore;
|
|
|
|
|
|
|
|
|
|
beforeEach(async () => {
|
|
|
|
|
assetStore = new AssetStore({});
|
|
|
|
|
sdkMock.getTimeBuckets.mockResolvedValue([]);
|
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 assetStore.init();
|
|
|
|
|
await assetStore.updateViewport({ width: 0, height: 0 });
|
2024-03-20 05:41:31 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('returns null for invalid buckets', () => {
|
|
|
|
|
expect(assetStore.getBucketByDate('invalid')).toBeNull();
|
|
|
|
|
expect(assetStore.getBucketByDate('2024-03-01T00:00:00.000Z')).toBeNull();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('returns the bucket index', () => {
|
2024-09-12 15:30:28 -04:00
|
|
|
const assetOne = assetFactory.build({ localDateTime: '2024-01-20T12:00:00.000Z' });
|
|
|
|
|
const assetTwo = assetFactory.build({ localDateTime: '2024-02-15T12:00:00.000Z' });
|
2024-03-20 05:41:31 +01:00
|
|
|
assetStore.addAssets([assetOne, assetTwo]);
|
|
|
|
|
|
|
|
|
|
expect(assetStore.getBucketIndexByAssetId(assetTwo.id)).toEqual(0);
|
|
|
|
|
expect(assetStore.getBucketIndexByAssetId(assetOne.id)).toEqual(1);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('ignores removed buckets', () => {
|
2024-09-12 15:30:28 -04:00
|
|
|
const assetOne = assetFactory.build({ localDateTime: '2024-01-20T12:00:00.000Z' });
|
|
|
|
|
const assetTwo = assetFactory.build({ localDateTime: '2024-02-15T12:00:00.000Z' });
|
2024-03-20 05:41:31 +01:00
|
|
|
assetStore.addAssets([assetOne, assetTwo]);
|
|
|
|
|
|
|
|
|
|
assetStore.removeAssets([assetTwo.id]);
|
|
|
|
|
expect(assetStore.getBucketIndexByAssetId(assetOne.id)).toEqual(0);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|