feat(web): enable websocket (#3765)

* send store event to page

* fix format

* add new asset to existing bucket

* format

* debouncing

* format

* load bucket

* feedback

* feat: listen to deletes and auto-subscribe on all asset grid pages

* feat: auto refresh on person thumbnail

* chore: skip upload event for now

* fix: person thumbnail event

* fix merge

* update handleAssetDeletion with websocket communication

* update info box on mount

* fix test

* fix test

* feat: event for trash asset

---------

Co-authored-by: Jason Rasmussen <jrasm91@gmail.com>
This commit is contained in:
Alex
2023-10-06 15:48:11 -05:00
committed by GitHub
parent 4dffae3f39
commit 36b21948bf
16 changed files with 279 additions and 136 deletions

View File

@@ -25,6 +25,7 @@
import { AppRoute } from '$lib/constants';
import { createAssetInteractionStore } from '$lib/stores/asset-interaction.store';
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 { onMount } from 'svelte';
@@ -54,6 +55,7 @@
});
const assetInteractionStore = createAssetInteractionStore();
const { selectedAssets, isMultiSelectState } = assetInteractionStore;
const { onPersonThumbnail } = websocketStore;
let viewMode: ViewMode = ViewMode.VIEW_ASSETS;
let isEditingName = false;
@@ -65,12 +67,15 @@
let potentialMergePeople: PersonResponseDto[] = [];
let personName = '';
let thumbnailData = api.getPeopleThumbnailUrl(data.person.id);
let name: string = data.person.name;
let suggestedPeople: PersonResponseDto[] = [];
$: isAllArchive = Array.from($selectedAssets).every((asset) => asset.isArchived);
$: isAllFavorite = Array.from($selectedAssets).every((asset) => asset.isFavorite);
$: $onPersonThumbnail === data.person.id &&
(thumbnailData = api.getPeopleThumbnailUrl(data.person.id) + `?now=${Date.now()}`);
$: {
suggestedPeople = !name
@@ -141,14 +146,8 @@
await api.personApi.updatePerson({ id: data.person.id, personUpdateDto: { featureFaceAssetId: asset.id } });
// TODO: Replace by Websocket in the future
notificationController.show({
message: 'Feature photo updated, refresh page to see changes',
type: NotificationType.Info,
});
notificationController.show({ message: 'Feature photo updated', type: NotificationType.Info });
assetInteractionStore.clearMultiselect();
// scroll to top
viewMode = ViewMode.VIEW_ASSETS;
};
@@ -376,7 +375,7 @@
<ImageThumbnail
circle
shadow
url={api.getPeopleThumbnailUrl(data.person.id)}
url={thumbnailData}
altText={data.person.name}
widthStyle="3.375rem"
heightStyle="3.375rem"