mirror of
https://github.com/KevinMidboe/immich.git
synced 2025-12-08 20:29:05 +00:00
feat: manual stack assets (#4198)
This commit is contained in:
@@ -148,6 +148,16 @@ export class AssetEntity {
|
||||
|
||||
@OneToMany(() => AssetFaceEntity, (assetFace) => assetFace.asset)
|
||||
faces!: AssetFaceEntity[];
|
||||
|
||||
@Column({ nullable: true })
|
||||
stackParentId?: string | null;
|
||||
|
||||
@ManyToOne(() => AssetEntity, (asset) => asset.stack, { nullable: true, onDelete: 'SET NULL', onUpdate: 'CASCADE' })
|
||||
@JoinColumn({ name: 'stackParentId' })
|
||||
stackParent?: AssetEntity | null;
|
||||
|
||||
@OneToMany(() => AssetEntity, (asset) => asset.stackParent)
|
||||
stack?: AssetEntity[];
|
||||
}
|
||||
|
||||
export enum AssetType {
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class AddStackParentIdToAssets1695354433573 implements MigrationInterface {
|
||||
name = 'AddStackParentIdToAssets1695354433573'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE "assets" ADD "stackParentId" uuid`);
|
||||
await queryRunner.query(`ALTER TABLE "assets" ADD CONSTRAINT "FK_b463c8edb01364bf2beba08ef19" FOREIGN KEY ("stackParentId") REFERENCES "assets"("id") ON DELETE SET NULL ON UPDATE CASCADE`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE "assets" DROP CONSTRAINT "FK_b463c8edb01364bf2beba08ef19"`);
|
||||
await queryRunner.query(`ALTER TABLE "assets" DROP COLUMN "stackParentId"`);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -112,6 +112,7 @@ export class AssetRepository implements IAssetRepository {
|
||||
faces: {
|
||||
person: true,
|
||||
},
|
||||
stack: true,
|
||||
},
|
||||
withDeleted: true,
|
||||
});
|
||||
@@ -192,6 +193,7 @@ export class AssetRepository implements IAssetRepository {
|
||||
person: true,
|
||||
},
|
||||
library: true,
|
||||
stack: true,
|
||||
},
|
||||
// We are specifically asking for this asset. Return it even if it is soft deleted
|
||||
withDeleted: true,
|
||||
@@ -538,6 +540,12 @@ export class AssetRepository implements IAssetRepository {
|
||||
.andWhere('person.id = :personId', { personId });
|
||||
}
|
||||
|
||||
// Hide stack children only in main timeline
|
||||
// Uncomment after adding support for stacked assets in web client
|
||||
// if (!isArchived && !isFavorite && !personId && !albumId && !isTrashed) {
|
||||
// builder = builder.andWhere('asset.stackParent IS NULL');
|
||||
// }
|
||||
|
||||
return builder;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user