feat(web,server): add thumbhash support (#2649)

* add thumbhash: server generation and web impl

* move logic to infra & use byta in db

* remove unnecesary logs

* update generated API and simplify thumbhash gen

* fix check errors

* removed unnecessary library and css tag

* style edits

* syntax mistake

* update server test, change thumbhash job name

* fix tests

* Update server/src/domain/asset/response-dto/asset-response.dto.ts

Co-authored-by: Thomas <9749173+uhthomas@users.noreply.github.com>

* add unit test, change migration date

* change to official thumbhash impl

* update call method to not use eval

* "generate missing" looks for thumbhash

* improve queue & improve syntax

* update syntax again

* update tests

* fix thumbhash generation

* consolidate queueing to avoid duplication

* cover all types of incorrect thumbnail cases

* split out jest tasks

* put back thumbnail duration loading for images without thumbhash

* Remove stray package.json

---------

Co-authored-by: Luke McCarthy <mail@lukehmcc.com>
Co-authored-by: Thomas <9749173+uhthomas@users.noreply.github.com>
Co-authored-by: Alex Tran <alex.tran1502@gmail.com>
This commit is contained in:
Covalent
2023-06-17 23:22:31 -04:00
committed by GitHub
parent 3512140148
commit 3e804f16df
29 changed files with 354 additions and 29 deletions

View File

@@ -21,6 +21,7 @@ class AssetResponseDto {
required this.originalPath,
required this.originalFileName,
required this.resized,
required this.thumbhash,
required this.fileCreatedAt,
required this.fileModifiedAt,
required this.updatedAt,
@@ -52,6 +53,9 @@ class AssetResponseDto {
bool resized;
/// base64 encoded thumbhash
String? thumbhash;
DateTime fileCreatedAt;
DateTime fileModifiedAt;
@@ -101,6 +105,7 @@ class AssetResponseDto {
other.originalPath == originalPath &&
other.originalFileName == originalFileName &&
other.resized == resized &&
other.thumbhash == thumbhash &&
other.fileCreatedAt == fileCreatedAt &&
other.fileModifiedAt == fileModifiedAt &&
other.updatedAt == updatedAt &&
@@ -126,6 +131,7 @@ class AssetResponseDto {
(originalPath.hashCode) +
(originalFileName.hashCode) +
(resized.hashCode) +
(thumbhash == null ? 0 : thumbhash!.hashCode) +
(fileCreatedAt.hashCode) +
(fileModifiedAt.hashCode) +
(updatedAt.hashCode) +
@@ -141,7 +147,7 @@ class AssetResponseDto {
(checksum.hashCode);
@override
String toString() => 'AssetResponseDto[type=$type, id=$id, deviceAssetId=$deviceAssetId, ownerId=$ownerId, deviceId=$deviceId, originalPath=$originalPath, originalFileName=$originalFileName, resized=$resized, fileCreatedAt=$fileCreatedAt, fileModifiedAt=$fileModifiedAt, updatedAt=$updatedAt, isFavorite=$isFavorite, isArchived=$isArchived, mimeType=$mimeType, duration=$duration, exifInfo=$exifInfo, smartInfo=$smartInfo, livePhotoVideoId=$livePhotoVideoId, tags=$tags, people=$people, checksum=$checksum]';
String toString() => 'AssetResponseDto[type=$type, id=$id, deviceAssetId=$deviceAssetId, ownerId=$ownerId, deviceId=$deviceId, originalPath=$originalPath, originalFileName=$originalFileName, resized=$resized, thumbhash=$thumbhash, fileCreatedAt=$fileCreatedAt, fileModifiedAt=$fileModifiedAt, updatedAt=$updatedAt, isFavorite=$isFavorite, isArchived=$isArchived, mimeType=$mimeType, duration=$duration, exifInfo=$exifInfo, smartInfo=$smartInfo, livePhotoVideoId=$livePhotoVideoId, tags=$tags, people=$people, checksum=$checksum]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
@@ -153,6 +159,11 @@ class AssetResponseDto {
json[r'originalPath'] = this.originalPath;
json[r'originalFileName'] = this.originalFileName;
json[r'resized'] = this.resized;
if (this.thumbhash != null) {
json[r'thumbhash'] = this.thumbhash;
} else {
// json[r'thumbhash'] = null;
}
json[r'fileCreatedAt'] = this.fileCreatedAt.toUtc().toIso8601String();
json[r'fileModifiedAt'] = this.fileModifiedAt.toUtc().toIso8601String();
json[r'updatedAt'] = this.updatedAt.toUtc().toIso8601String();
@@ -212,6 +223,7 @@ class AssetResponseDto {
originalPath: mapValueOfType<String>(json, r'originalPath')!,
originalFileName: mapValueOfType<String>(json, r'originalFileName')!,
resized: mapValueOfType<bool>(json, r'resized')!,
thumbhash: mapValueOfType<String>(json, r'thumbhash'),
fileCreatedAt: mapDateTime(json, r'fileCreatedAt', '')!,
fileModifiedAt: mapDateTime(json, r'fileModifiedAt', '')!,
updatedAt: mapDateTime(json, r'updatedAt', '')!,
@@ -280,6 +292,7 @@ class AssetResponseDto {
'originalPath',
'originalFileName',
'resized',
'thumbhash',
'fileCreatedAt',
'fileModifiedAt',
'updatedAt',