1
0
forked from Cutlery/immich

Merge branch 'fix-stacking' of github.com:immich-app/immich into fix-stacking

This commit is contained in:
Alex Tran
2024-02-22 09:21:55 -06:00
13 changed files with 36 additions and 41 deletions
+1
View File
@@ -0,0 +1 @@
3.13.6
+1
View File
@@ -0,0 +1 @@
3.13.6
+1
View File
@@ -0,0 +1 @@
C:/Users/alext/fvm/versions/3.13.6
+1 -1
View File
@@ -180,4 +180,4 @@ SPEC CHECKSUMS:
PODFILE CHECKSUM: 64c9b5291666c0ca3caabdfe9865c141ac40321d
COCOAPODS: 1.12.1
COCOAPODS: 1.11.3
@@ -162,7 +162,6 @@ class WebsocketNotifier extends StateNotifier<WebsocketState> {
socket.on('on_asset_trash', _handleServerUpdates);
socket.on('on_asset_restore', _handleServerUpdates);
socket.on('on_asset_update', _handleServerUpdates);
socket.on('on_asset_stack_update', _handleServerUpdates);
socket.on('on_asset_hidden', _handleOnAssetHidden);
socket.on('on_new_release', _handleReleaseUpdates);
} catch (e) {
@@ -58,6 +58,18 @@ class AssetService {
final assetDto = await _apiService.assetApi
.getAllAssets(userId: user.id, updatedAfter: since);
if (assetDto == null) return (null, null);
print("AssetDto length: ${assetDto.length} ");
for (final e in assetDto) {
print("AssetDto: ${e.stackParentId}");
var b = Asset.remote(e);
print("e.stackParentId ${e.stackParentId}");
print("e.id ${e.id}");
print(
"e.stackParentId == e.id ? null : e.stackParentId, ${e.stackParentId == e.id ? null : e.stackParentId}",
);
print("Mapped asset ${b.stackParentId}");
}
return (assetDto.map(Asset.remote).toList(), deleted.ids);
}
@@ -82,6 +94,7 @@ class AssetService {
if (assets == null) {
return null;
}
allAssets.addAll(assets.map(Asset.remote));
if (assets.length < chunkSize) {
break;
@@ -706,7 +706,7 @@ describe(AssetService.name, () => {
stackParentId: 'parent',
});
expect(communicationMock.send).toHaveBeenCalledWith(ClientEvent.ASSET_STACK_UPDATE, authStub.user1.user.id, [
expect(communicationMock.send).toHaveBeenCalledWith(ClientEvent.ASSET_UPDATE, authStub.user1.user.id, [
'asset-1',
'parent',
]);
+2 -6
View File
@@ -381,7 +381,7 @@ export class AssetService {
.flatMap((stack) => (stack ? [stack] : []))
.filter((stack) => stack.assets.length < 2);
await Promise.all(stacksToDelete.map((as) => this.assetStackRepository.delete(as.id)));
this.communicationRepository.send(ClientEvent.ASSET_STACK_UPDATE, auth.user.id, ids);
this.communicationRepository.send(ClientEvent.ASSET_UPDATE, auth.user.id, ids);
}
async handleAssetDeletionCheck() {
@@ -499,11 +499,7 @@ export class AssetService {
primaryAssetId: newParentId,
});
this.communicationRepository.send(ClientEvent.ASSET_STACK_UPDATE, auth.user.id, [
...childIds,
newParentId,
oldParentId,
]);
this.communicationRepository.send(ClientEvent.ASSET_UPDATE, auth.user.id, [...childIds, newParentId, oldParentId]);
await this.assetRepository.updateAll([oldParentId, newParentId, ...childIds], { updatedAt: new Date() });
}
@@ -1,5 +1,3 @@
import { AssetResponseDto, ReleaseNotification, ServerVersionResponseDto } from '@app/domain';
export const ICommunicationRepository = 'ICommunicationRepository';
export enum ClientEvent {
@@ -9,7 +7,6 @@ export enum ClientEvent {
ASSET_UPDATE = 'on_asset_update',
ASSET_HIDDEN = 'on_asset_hidden',
ASSET_RESTORE = 'on_asset_restore',
ASSET_STACK_UPDATE = 'on_asset_stack_update',
PERSON_THUMBNAIL = 'on_person_thumbnail',
SERVER_VERSION = 'on_server_version',
CONFIG_UPDATE = 'on_config_update',
@@ -20,26 +17,12 @@ export enum ServerEvent {
CONFIG_UPDATE = 'config:update',
}
export interface ClientEventMap {
[ClientEvent.UPLOAD_SUCCESS]: AssetResponseDto;
[ClientEvent.ASSET_DELETE]: string;
[ClientEvent.ASSET_TRASH]: string[];
[ClientEvent.ASSET_UPDATE]: AssetResponseDto;
[ClientEvent.ASSET_HIDDEN]: string;
[ClientEvent.ASSET_RESTORE]: string[];
[ClientEvent.ASSET_STACK_UPDATE]: string[];
[ClientEvent.PERSON_THUMBNAIL]: string;
[ClientEvent.SERVER_VERSION]: ServerVersionResponseDto;
[ClientEvent.CONFIG_UPDATE]: Record<string, never>;
[ClientEvent.NEW_RELEASE]: ReleaseNotification;
}
export type OnConnectCallback = (userId: string) => Promise<void>;
export type OnServerEventCallback = () => Promise<void>;
export interface ICommunicationRepository {
send<E extends keyof ClientEventMap>(event: E, userId: string, data: ClientEventMap[E]): void;
broadcast<E extends keyof ClientEventMap>(event: E, data: ClientEventMap[E]): void;
send(event: ClientEvent, userId: string, data: any): void;
broadcast(event: ClientEvent, data: any): void;
on(event: 'connect', callback: OnConnectCallback): void;
on(event: ServerEvent, callback: OnServerEventCallback): void;
sendServerEvent(event: ServerEvent): void;
@@ -157,7 +157,9 @@ type BaseAssetSearchOptions = SearchDateOptions &
export type AssetSearchOptions = BaseAssetSearchOptions & SearchRelationOptions;
export type AssetSearchOneToOneRelationOptions = BaseAssetSearchOptions & SearchOneToOneRelationOptions;
export type AssetSearchOneToOneRelationOptions = BaseAssetSearchOptions &
SearchOneToOneRelationOptions &
SearchRelationOptions;
export type AssetSearchBuilderOptions = Omit<AssetSearchOptions, 'orderDirection'>;
@@ -1,6 +1,5 @@
import { FeatureFlags, IVersion, type VersionType } from '@app/domain';
import { FeatureFlags, IVersion } from '@app/domain';
import { ApiProperty, ApiResponseProperty } from '@nestjs/swagger';
import type { DateTime } from 'luxon';
import { SystemConfigThemeDto } from '../system-config/dto/system-config-theme.dto';
export class ServerPingResponse {
@@ -106,10 +105,3 @@ export class ServerFeaturesDto implements FeatureFlags {
sidecar!: boolean;
search!: boolean;
}
export interface ReleaseNotification {
isAvailable: VersionType;
checkedAt: DateTime<boolean> | null;
serverVersion: ServerVersionResponseDto;
releaseVersion: ServerVersionResponseDto;
}
@@ -116,9 +116,17 @@ export class AssetService {
await this.access.requirePermission(auth, Permission.TIMELINE_READ, userId);
const assets = await this.assetRepository.getAllByFileCreationDate(
{ take: dto.take ?? 1000, skip: dto.skip },
{ ...dto, userIds: [userId], withDeleted: true, orderDirection: 'DESC', withExif: true, isVisible: true },
{
...dto,
userIds: [userId],
withDeleted: true,
orderDirection: 'DESC',
withExif: true,
isVisible: true,
withStacked: true,
},
);
return assets.items.map((asset) => mapAsset(asset));
return assets.items.map((asset) => mapAsset(asset, { withStack: true }));
}
async serveThumbnail(auth: AuthDto, assetId: string, dto: GetAssetThumbnailDto): Promise<ImmichFileResponse> {
-1
View File
@@ -17,7 +17,6 @@ export interface Events {
on_asset_update: (asset: AssetResponseDto) => void;
on_asset_hidden: (assetId: string) => void;
on_asset_restore: (assetIds: string[]) => void;
on_asset_stack_update: (assetIds: string[]) => void;
on_person_thumbnail: (personId: string) => void;
on_server_version: (serverVersion: ServerVersionResponseDto) => void;
on_config_update: () => void;