refactor: always use the same bucket size (#4662)

This commit is contained in:
Jason Rasmussen 2023-10-26 14:55:10 -04:00 committed by GitHub
parent 0167407370
commit c76c1d6bf8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 17 additions and 21 deletions

View file

@ -5,7 +5,7 @@
import { dragAndDropFilesStore } from '$lib/stores/drag-and-drop-files.store';
import { locale } from '$lib/stores/preferences.store';
import { fileUploadHandler, openFileUploadDialog } from '$lib/utils/file-uploader';
import { TimeBucketSize, type AlbumResponseDto, type SharedLinkResponseDto } from '@api';
import type { AlbumResponseDto, SharedLinkResponseDto } from '@api';
import { onDestroy, onMount } from 'svelte';
import { dateFormats } from '../../constants';
import { createAssetInteractionStore } from '../../stores/asset-interaction.store';
@ -27,7 +27,7 @@
let { isViewing: showAssetViewer } = assetViewingStore;
const assetStore = new AssetStore({ size: TimeBucketSize.Month, albumId: album.id });
const assetStore = new AssetStore({ albumId: album.id });
const assetInteractionStore = createAssetInteractionStore();
const { isMultiSelectState, selectedAssets } = assetInteractionStore;

View file

@ -1,4 +1,4 @@
import { api, AssetApiGetTimeBucketsRequest, AssetResponseDto } from '@api';
import { api, AssetApiGetTimeBucketsRequest, AssetResponseDto, TimeBucketSize } from '@api';
import { throttle } from 'lodash-es';
import { DateTime } from 'luxon';
import { Unsubscriber, writable } from 'svelte/store';
@ -12,7 +12,7 @@ export enum BucketPosition {
Unknown = 'unknown',
}
export type AssetStoreOptions = AssetApiGetTimeBucketsRequest;
export type AssetStoreOptions = Omit<AssetApiGetTimeBucketsRequest, 'size'>;
export interface Viewport {
width: number;
@ -64,6 +64,7 @@ export class AssetStore {
private assetToBucket: Record<string, AssetLookup> = {};
private pendingChanges: PendingChange[] = [];
private unsubscribers: Unsubscriber[] = [];
private options: AssetApiGetTimeBucketsRequest;
initialized = false;
timelineHeight = 0;
@ -71,7 +72,8 @@ export class AssetStore {
assets: AssetResponseDto[] = [];
albumAssets: Set<string> = new Set();
constructor(private options: AssetStoreOptions, private albumId?: string) {
constructor(options: AssetStoreOptions, private albumId?: string) {
this.options = { ...options, size: TimeBucketSize.Month };
this.store$.set(this);
}

View file

@ -34,7 +34,7 @@
import { downloadArchive } from '$lib/utils/asset-utils';
import { openFileUploadDialog } from '$lib/utils/file-uploader';
import { handleError } from '$lib/utils/handle-error';
import { TimeBucketSize, UserResponseDto, api } from '@api';
import { UserResponseDto, api } from '@api';
import Icon from '$lib/components/elements/icon.svelte';
import type { PageData } from './$types';
import { clickOutside } from '$lib/utils/click-outside';
@ -76,11 +76,11 @@
let currentAlbumName = '';
let contextMenuPosition: { x: number; y: number } = { x: 0, y: 0 };
const assetStore = new AssetStore({ size: TimeBucketSize.Month, albumId: album.id });
const assetStore = new AssetStore({ albumId: album.id });
const assetInteractionStore = createAssetInteractionStore();
const { isMultiSelectState, selectedAssets } = assetInteractionStore;
const timelineStore = new AssetStore({ size: TimeBucketSize.Month, isArchived: false }, album.id);
const timelineStore = new AssetStore({ isArchived: false }, album.id);
const timelineInteractionStore = createAssetInteractionStore();
const { selectedAssets: timelineSelected } = timelineInteractionStore;

View file

@ -14,13 +14,12 @@
import { AssetAction } from '$lib/constants';
import { createAssetInteractionStore } from '$lib/stores/asset-interaction.store';
import { AssetStore } from '$lib/stores/assets.store';
import { TimeBucketSize } from '@api';
import type { PageData } from './$types';
import { mdiPlus, mdiDotsVertical } from '@mdi/js';
export let data: PageData;
const assetStore = new AssetStore({ size: TimeBucketSize.Month, isArchived: true });
const assetStore = new AssetStore({ isArchived: true });
const assetInteractionStore = createAssetInteractionStore();
const { isMultiSelectState, selectedAssets } = assetInteractionStore;

View file

@ -14,13 +14,12 @@
import { AssetAction } from '$lib/constants';
import { createAssetInteractionStore } from '$lib/stores/asset-interaction.store';
import { AssetStore } from '$lib/stores/assets.store';
import { TimeBucketSize } from '@api';
import type { PageData } from './$types';
import { mdiDotsVertical, mdiPlus } from '@mdi/js';
export let data: PageData;
const assetStore = new AssetStore({ size: TimeBucketSize.Month, isFavorite: true });
const assetStore = new AssetStore({ isFavorite: true });
const assetInteractionStore = createAssetInteractionStore();
const { isMultiSelectState, selectedAssets } = assetInteractionStore;

View file

@ -10,14 +10,13 @@
import { AppRoute } from '$lib/constants';
import { createAssetInteractionStore } from '$lib/stores/asset-interaction.store';
import { AssetStore } from '$lib/stores/assets.store';
import { TimeBucketSize } from '@api';
import { onDestroy } from 'svelte';
import type { PageData } from './$types';
import { mdiPlus, mdiArrowLeft } from '@mdi/js';
export let data: PageData;
const assetStore = new AssetStore({ size: TimeBucketSize.Month, userId: data.partner.id, isArchived: false });
const assetStore = new AssetStore({ userId: data.partner.id, isArchived: false });
const assetInteractionStore = createAssetInteractionStore();
const { isMultiSelectState, selectedAssets } = assetInteractionStore;

View file

@ -27,7 +27,7 @@
import { AssetStore } from '$lib/stores/assets.store';
import { websocketStore } from '$lib/stores/websocket';
import { handleError } from '$lib/utils/handle-error';
import { AssetResponseDto, PersonResponseDto, TimeBucketSize, api } from '@api';
import { AssetResponseDto, PersonResponseDto, api } from '@api';
import { onMount } from 'svelte';
import type { PageData } from './$types';
import { clickOutside } from '$lib/utils/click-outside';
@ -49,7 +49,6 @@
}
let assetStore = new AssetStore({
size: TimeBucketSize.Month,
isArchived: false,
personId: data.person.id,
});
@ -153,7 +152,6 @@
}
if (previousPersonId !== data.person.id) {
assetStore = new AssetStore({
size: TimeBucketSize.Month,
isArchived: false,
personId: data.person.id,
});

View file

@ -17,7 +17,6 @@
import { createAssetInteractionStore } from '$lib/stores/asset-interaction.store';
import { AssetStore } from '$lib/stores/assets.store';
import { openFileUploadDialog } from '$lib/utils/file-uploader';
import { TimeBucketSize } from '@api';
import type { PageData } from './$types';
import { assetViewingStore } from '$lib/stores/asset-viewing.store';
import { mdiDotsVertical, mdiPlus } from '@mdi/js';
@ -26,7 +25,7 @@
let { isViewing: showAssetViewer } = assetViewingStore;
let handleEscapeKey = false;
const assetStore = new AssetStore({ size: TimeBucketSize.Month, isArchived: false });
const assetStore = new AssetStore({ isArchived: false });
const assetInteractionStore = createAssetInteractionStore();
const { isMultiSelectState, selectedAssets } = assetInteractionStore;

View file

@ -15,7 +15,7 @@
} from '$lib/components/shared-components/notification/notification';
import LinkButton from '$lib/components/elements/buttons/link-button.svelte';
import { AssetStore } from '$lib/stores/assets.store';
import { api, TimeBucketSize } from '@api';
import { api } from '@api';
import Icon from '$lib/components/elements/icon.svelte';
import type { PageData } from './$types';
import { featureFlags, serverConfig } from '$lib/stores/server-config.store';
@ -28,7 +28,7 @@
$: $featureFlags.trash || goto(AppRoute.PHOTOS);
const assetStore = new AssetStore({ size: TimeBucketSize.Month, isTrashed: true });
const assetStore = new AssetStore({ isTrashed: true });
const assetInteractionStore = createAssetInteractionStore();
const { isMultiSelectState, selectedAssets } = assetInteractionStore;
let isShowEmptyConfirmation = false;