Merge branch 'main' into feature/bottom-buttons-order
commit
ebed026d5a
|
|
@ -20,7 +20,7 @@
|
||||||
"@types/lodash-es": "^4.17.12",
|
"@types/lodash-es": "^4.17.12",
|
||||||
"@types/micromatch": "^4.0.9",
|
"@types/micromatch": "^4.0.9",
|
||||||
"@types/mock-fs": "^4.13.1",
|
"@types/mock-fs": "^4.13.1",
|
||||||
"@types/node": "^24.10.1",
|
"@types/node": "^24.10.3",
|
||||||
"@vitest/coverage-v8": "^3.0.0",
|
"@vitest/coverage-v8": "^3.0.0",
|
||||||
"byte-size": "^9.0.0",
|
"byte-size": "^9.0.0",
|
||||||
"cli-progress": "^3.12.0",
|
"cli-progress": "^3.12.0",
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@
|
||||||
"@playwright/test": "^1.44.1",
|
"@playwright/test": "^1.44.1",
|
||||||
"@socket.io/component-emitter": "^3.1.2",
|
"@socket.io/component-emitter": "^3.1.2",
|
||||||
"@types/luxon": "^3.4.2",
|
"@types/luxon": "^3.4.2",
|
||||||
"@types/node": "^24.10.1",
|
"@types/node": "^24.10.3",
|
||||||
"@types/oidc-provider": "^9.0.0",
|
"@types/oidc-provider": "^9.0.0",
|
||||||
"@types/pg": "^8.15.1",
|
"@types/pg": "^8.15.1",
|
||||||
"@types/pngjs": "^6.0.4",
|
"@types/pngjs": "^6.0.4",
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ class LikeActivityActionButton extends ConsumerWidget {
|
||||||
|
|
||||||
return BaseActionButton(
|
return BaseActionButton(
|
||||||
maxWidth: 60,
|
maxWidth: 60,
|
||||||
iconData: liked != null ? Icons.favorite : Icons.favorite_border,
|
iconData: liked != null ? Icons.thumb_up : Icons.thumb_up_off_alt,
|
||||||
label: "like".t(context: context),
|
label: "like".t(context: context),
|
||||||
onPressed: () => onTap(liked),
|
onPressed: () => onTap(liked),
|
||||||
iconOnly: iconOnly,
|
iconOnly: iconOnly,
|
||||||
|
|
@ -57,7 +57,7 @@ class LikeActivityActionButton extends ConsumerWidget {
|
||||||
|
|
||||||
// default to empty heart during loading
|
// default to empty heart during loading
|
||||||
loading: () => BaseActionButton(
|
loading: () => BaseActionButton(
|
||||||
iconData: Icons.favorite_border,
|
iconData: Icons.thumb_up_off_alt,
|
||||||
label: "like".t(context: context),
|
label: "like".t(context: context),
|
||||||
iconOnly: iconOnly,
|
iconOnly: iconOnly,
|
||||||
menuItem: menuItem,
|
menuItem: menuItem,
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,7 @@ class ActivitiesBottomSheet extends HookConsumerWidget {
|
||||||
expand: false,
|
expand: false,
|
||||||
shouldCloseOnMinExtent: false,
|
shouldCloseOnMinExtent: false,
|
||||||
resizeOnScroll: false,
|
resizeOnScroll: false,
|
||||||
backgroundColor: context.isDarkTheme ? Colors.black : Colors.white,
|
backgroundColor: context.isDarkTheme ? context.colorScheme.surface : Colors.white,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,7 @@ class AssetViewer extends ConsumerStatefulWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
const double _kBottomSheetMinimumExtent = 0.4;
|
const double _kBottomSheetMinimumExtent = 0.4;
|
||||||
const double _kBottomSheetSnapExtent = 0.7;
|
const double _kBottomSheetSnapExtent = 0.67;
|
||||||
|
|
||||||
class _AssetViewerState extends ConsumerState<AssetViewer> {
|
class _AssetViewerState extends ConsumerState<AssetViewer> {
|
||||||
static final _dummyListener = ImageStreamListener((image, _) => image.dispose());
|
static final _dummyListener = ImageStreamListener((image, _) => image.dispose());
|
||||||
|
|
@ -399,10 +399,14 @@ class _AssetViewerState extends ConsumerState<AssetViewer> {
|
||||||
final isDraggingDown = currentExtent < previousExtent;
|
final isDraggingDown = currentExtent < previousExtent;
|
||||||
previousExtent = currentExtent;
|
previousExtent = currentExtent;
|
||||||
// Closes the bottom sheet if the user is dragging down
|
// Closes the bottom sheet if the user is dragging down
|
||||||
if (isDraggingDown && delta.extent < 0.55) {
|
if (isDraggingDown && delta.extent < 0.67) {
|
||||||
if (dragInProgress) {
|
if (dragInProgress) {
|
||||||
blockGestures = true;
|
blockGestures = true;
|
||||||
}
|
}
|
||||||
|
// Jump to a lower position before starting close animation to prevent glitch
|
||||||
|
if (bottomSheetController.isAttached) {
|
||||||
|
bottomSheetController.jumpTo(0.67);
|
||||||
|
}
|
||||||
sheetCloseController?.close();
|
sheetCloseController?.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -480,7 +484,7 @@ class _AssetViewerState extends ConsumerState<AssetViewer> {
|
||||||
previousExtent = _kBottomSheetMinimumExtent;
|
previousExtent = _kBottomSheetMinimumExtent;
|
||||||
sheetCloseController = showBottomSheet(
|
sheetCloseController = showBottomSheet(
|
||||||
context: ctx,
|
context: ctx,
|
||||||
sheetAnimationStyle: const AnimationStyle(duration: Durations.short4, reverseDuration: Durations.short2),
|
sheetAnimationStyle: const AnimationStyle(duration: Durations.medium2, reverseDuration: Durations.medium2),
|
||||||
constraints: const BoxConstraints(maxWidth: double.infinity),
|
constraints: const BoxConstraints(maxWidth: double.infinity),
|
||||||
shape: const RoundedRectangleBorder(borderRadius: BorderRadius.vertical(top: Radius.circular(20.0))),
|
shape: const RoundedRectangleBorder(borderRadius: BorderRadius.vertical(top: Radius.circular(20.0))),
|
||||||
backgroundColor: ctx.colorScheme.surfaceContainerLowest,
|
backgroundColor: ctx.colorScheme.surfaceContainerLowest,
|
||||||
|
|
@ -688,16 +692,20 @@ class _AssetViewerState extends ConsumerState<AssetViewer> {
|
||||||
backgroundDecoration: BoxDecoration(color: backgroundColor),
|
backgroundDecoration: BoxDecoration(color: backgroundColor),
|
||||||
enablePanAlways: true,
|
enablePanAlways: true,
|
||||||
),
|
),
|
||||||
|
if (!showingBottomSheet)
|
||||||
|
const Positioned(
|
||||||
|
bottom: 0,
|
||||||
|
left: 0,
|
||||||
|
right: 0,
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
|
children: [AssetStackRow(), ViewerBottomBar()],
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
bottomNavigationBar: showingBottomSheet
|
|
||||||
? const SizedBox.shrink()
|
|
||||||
: const Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
mainAxisAlignment: MainAxisAlignment.end,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
||||||
children: [AssetStackRow(), ViewerBottomBar()],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ class AssetDetailBottomSheet extends ConsumerWidget {
|
||||||
expand: false,
|
expand: false,
|
||||||
shouldCloseOnMinExtent: false,
|
shouldCloseOnMinExtent: false,
|
||||||
resizeOnScroll: false,
|
resizeOnScroll: false,
|
||||||
backgroundColor: context.isDarkTheme ? Colors.black : Colors.white,
|
backgroundColor: context.isDarkTheme ? context.colorScheme.surface : Colors.white,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -299,7 +299,7 @@ class _AssetDetailBottomSheet extends ConsumerWidget {
|
||||||
// Appears in (Albums)
|
// Appears in (Albums)
|
||||||
Padding(padding: const EdgeInsets.only(top: 16.0), child: _buildAppearsInList(ref, context)),
|
Padding(padding: const EdgeInsets.only(top: 16.0), child: _buildAppearsInList(ref, context)),
|
||||||
// padding at the bottom to avoid cut-off
|
// padding at the bottom to avoid cut-off
|
||||||
const SizedBox(height: 100),
|
const SizedBox(height: 30),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,6 @@ import 'package:immich_mobile/presentation/widgets/action_buttons/stack_action_b
|
||||||
import 'package:immich_mobile/presentation/widgets/action_buttons/trash_action_button.widget.dart';
|
import 'package:immich_mobile/presentation/widgets/action_buttons/trash_action_button.widget.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/action_buttons/unarchive_action_button.widget.dart';
|
import 'package:immich_mobile/presentation/widgets/action_buttons/unarchive_action_button.widget.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/action_buttons/unstack_action_button.widget.dart';
|
import 'package:immich_mobile/presentation/widgets/action_buttons/unstack_action_button.widget.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/action_buttons/upload_action_button.widget.dart';
|
|
||||||
import 'package:immich_mobile/presentation/widgets/bottom_sheet/base_bottom_sheet.widget.dart';
|
import 'package:immich_mobile/presentation/widgets/bottom_sheet/base_bottom_sheet.widget.dart';
|
||||||
import 'package:immich_mobile/providers/server_info.provider.dart';
|
import 'package:immich_mobile/providers/server_info.provider.dart';
|
||||||
import 'package:immich_mobile/providers/timeline/multiselect.provider.dart';
|
import 'package:immich_mobile/providers/timeline/multiselect.provider.dart';
|
||||||
|
|
@ -47,10 +46,7 @@ class ArchiveBottomSheet extends ConsumerWidget {
|
||||||
if (multiselect.selectedAssets.length > 1) const StackActionButton(source: ActionSource.timeline),
|
if (multiselect.selectedAssets.length > 1) const StackActionButton(source: ActionSource.timeline),
|
||||||
if (multiselect.hasStacked) const UnStackActionButton(source: ActionSource.timeline),
|
if (multiselect.hasStacked) const UnStackActionButton(source: ActionSource.timeline),
|
||||||
],
|
],
|
||||||
if (multiselect.hasLocal) ...[
|
if (multiselect.hasMerged) const DeleteLocalActionButton(source: ActionSource.timeline),
|
||||||
const DeleteLocalActionButton(source: ActionSource.timeline),
|
|
||||||
const UploadActionButton(source: ActionSource.timeline),
|
|
||||||
],
|
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,7 @@ class _BaseDraggableScrollableSheetState extends ConsumerState<BaseBottomSheet>
|
||||||
child: CustomScrollView(
|
child: CustomScrollView(
|
||||||
controller: scrollController,
|
controller: scrollController,
|
||||||
slivers: [
|
slivers: [
|
||||||
const SliverPersistentHeader(delegate: _DragHandleDelegate(), pinned: true),
|
const SliverToBoxAdapter(child: _DragHandle()),
|
||||||
if (widget.actions.isNotEmpty)
|
if (widget.actions.isNotEmpty)
|
||||||
SliverToBoxAdapter(
|
SliverToBoxAdapter(
|
||||||
child: Column(
|
child: Column(
|
||||||
|
|
@ -108,31 +108,13 @@ class _BaseDraggableScrollableSheetState extends ConsumerState<BaseBottomSheet>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class _DragHandleDelegate extends SliverPersistentHeaderDelegate {
|
|
||||||
const _DragHandleDelegate();
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context, double shrinkOffset, bool overlapsContent) {
|
|
||||||
return const _DragHandle();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
bool shouldRebuild(_DragHandleDelegate oldDelegate) => false;
|
|
||||||
|
|
||||||
@override
|
|
||||||
double get minExtent => 50.0;
|
|
||||||
|
|
||||||
@override
|
|
||||||
double get maxExtent => 50.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
class _DragHandle extends StatelessWidget {
|
class _DragHandle extends StatelessWidget {
|
||||||
const _DragHandle();
|
const _DragHandle();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
height: 50,
|
height: 38,
|
||||||
child: Center(
|
child: Center(
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
width: 32,
|
width: 32,
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,6 @@ import 'package:immich_mobile/presentation/widgets/action_buttons/stack_action_b
|
||||||
import 'package:immich_mobile/presentation/widgets/action_buttons/trash_action_button.widget.dart';
|
import 'package:immich_mobile/presentation/widgets/action_buttons/trash_action_button.widget.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/action_buttons/unfavorite_action_button.widget.dart';
|
import 'package:immich_mobile/presentation/widgets/action_buttons/unfavorite_action_button.widget.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/action_buttons/unstack_action_button.widget.dart';
|
import 'package:immich_mobile/presentation/widgets/action_buttons/unstack_action_button.widget.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/action_buttons/upload_action_button.widget.dart';
|
|
||||||
import 'package:immich_mobile/presentation/widgets/album/album_selector.widget.dart';
|
import 'package:immich_mobile/presentation/widgets/album/album_selector.widget.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/bottom_sheet/base_bottom_sheet.widget.dart';
|
import 'package:immich_mobile/presentation/widgets/bottom_sheet/base_bottom_sheet.widget.dart';
|
||||||
import 'package:immich_mobile/providers/infrastructure/album.provider.dart';
|
import 'package:immich_mobile/providers/infrastructure/album.provider.dart';
|
||||||
|
|
@ -86,10 +85,7 @@ class FavoriteBottomSheet extends ConsumerWidget {
|
||||||
if (multiselect.selectedAssets.length > 1) const StackActionButton(source: ActionSource.timeline),
|
if (multiselect.selectedAssets.length > 1) const StackActionButton(source: ActionSource.timeline),
|
||||||
if (multiselect.hasStacked) const UnStackActionButton(source: ActionSource.timeline),
|
if (multiselect.hasStacked) const UnStackActionButton(source: ActionSource.timeline),
|
||||||
],
|
],
|
||||||
if (multiselect.hasLocal) ...[
|
if (multiselect.hasMerged) const DeleteLocalActionButton(source: ActionSource.timeline),
|
||||||
const DeleteLocalActionButton(source: ActionSource.timeline),
|
|
||||||
const UploadActionButton(source: ActionSource.timeline),
|
|
||||||
],
|
|
||||||
],
|
],
|
||||||
slivers: multiselect.hasRemote
|
slivers: multiselect.hasRemote
|
||||||
? [const AddToAlbumHeader(), AlbumSelector(onAlbumSelected: addAssetsToAlbum)]
|
? [const AddToAlbumHeader(), AlbumSelector(onAlbumSelected: addAssetsToAlbum)]
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@ import 'package:immich_mobile/presentation/widgets/action_buttons/share_link_act
|
||||||
import 'package:immich_mobile/presentation/widgets/action_buttons/stack_action_button.widget.dart';
|
import 'package:immich_mobile/presentation/widgets/action_buttons/stack_action_button.widget.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/action_buttons/trash_action_button.widget.dart';
|
import 'package:immich_mobile/presentation/widgets/action_buttons/trash_action_button.widget.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/action_buttons/unstack_action_button.widget.dart';
|
import 'package:immich_mobile/presentation/widgets/action_buttons/unstack_action_button.widget.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/action_buttons/upload_action_button.widget.dart';
|
|
||||||
import 'package:immich_mobile/presentation/widgets/album/album_selector.widget.dart';
|
import 'package:immich_mobile/presentation/widgets/album/album_selector.widget.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/bottom_sheet/base_bottom_sheet.widget.dart';
|
import 'package:immich_mobile/presentation/widgets/bottom_sheet/base_bottom_sheet.widget.dart';
|
||||||
import 'package:immich_mobile/providers/infrastructure/album.provider.dart';
|
import 'package:immich_mobile/providers/infrastructure/album.provider.dart';
|
||||||
|
|
@ -112,10 +111,7 @@ class _RemoteAlbumBottomSheetState extends ConsumerState<RemoteAlbumBottomSheet>
|
||||||
if (multiselect.hasStacked) const UnStackActionButton(source: ActionSource.timeline),
|
if (multiselect.hasStacked) const UnStackActionButton(source: ActionSource.timeline),
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
if (multiselect.hasLocal) ...[
|
if (multiselect.hasMerged) const DeleteLocalActionButton(source: ActionSource.timeline),
|
||||||
const DeleteLocalActionButton(source: ActionSource.timeline),
|
|
||||||
const UploadActionButton(source: ActionSource.timeline),
|
|
||||||
],
|
|
||||||
if (ownsAlbum) RemoveFromAlbumActionButton(source: ActionSource.timeline, albumId: widget.album.id),
|
if (ownsAlbum) RemoveFromAlbumActionButton(source: ActionSource.timeline, albumId: widget.album.id),
|
||||||
],
|
],
|
||||||
slivers: ownsAlbum
|
slivers: ownsAlbum
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ import 'package:easy_localization/easy_localization.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
|
import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
||||||
import 'package:immich_mobile/providers/activity.provider.dart';
|
import 'package:immich_mobile/providers/activity.provider.dart';
|
||||||
import 'package:immich_mobile/providers/album/current_album.provider.dart';
|
import 'package:immich_mobile/providers/album/current_album.provider.dart';
|
||||||
import 'package:immich_mobile/providers/asset_viewer/current_asset.provider.dart';
|
import 'package:immich_mobile/providers/asset_viewer/current_asset.provider.dart';
|
||||||
|
|
@ -68,11 +69,11 @@ class ActivityTextField extends HookConsumerWidget {
|
||||||
suffixIcon: Padding(
|
suffixIcon: Padding(
|
||||||
padding: const EdgeInsets.only(right: 10),
|
padding: const EdgeInsets.only(right: 10),
|
||||||
child: IconButton(
|
child: IconButton(
|
||||||
icon: Icon(liked ? Icons.favorite_rounded : Icons.favorite_border_rounded),
|
icon: Icon(liked ? Icons.thumb_up : Icons.thumb_up_off_alt),
|
||||||
onPressed: liked ? removeLike : addLike,
|
onPressed: liked ? removeLike : addLike,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
suffixIconColor: liked ? Colors.red[700] : null,
|
suffixIconColor: liked ? context.primaryColor : null,
|
||||||
hintText: !isEnabled ? 'shared_album_activities_input_disable'.tr() : 'say_something'.tr(),
|
hintText: !isEnabled ? 'shared_album_activities_input_disable'.tr() : 'say_something'.tr(),
|
||||||
hintStyle: TextStyle(fontWeight: FontWeight.normal, fontSize: 14, color: Colors.grey[600]),
|
hintStyle: TextStyle(fontWeight: FontWeight.normal, fontSize: 14, color: Colors.grey[600]),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ class ActivityTile extends HookConsumerWidget {
|
||||||
? Container(
|
? Container(
|
||||||
width: isBottomSheet ? 30 : 44,
|
width: isBottomSheet ? 30 : 44,
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
child: Icon(Icons.favorite_rounded, color: Colors.red[700]),
|
child: Icon(Icons.thumb_up, color: context.primaryColor),
|
||||||
)
|
)
|
||||||
: isBottomSheet
|
: isBottomSheet
|
||||||
? UserCircleAvatar(user: activity.user, size: 30, radius: 15)
|
? UserCircleAvatar(user: activity.user, size: 30, radius: 15)
|
||||||
|
|
|
||||||
|
|
@ -67,8 +67,8 @@ class CommentBubble extends ConsumerWidget {
|
||||||
bottom: 6,
|
bottom: 6,
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: const EdgeInsets.all(4),
|
padding: const EdgeInsets.all(4),
|
||||||
decoration: BoxDecoration(color: Colors.white.withValues(alpha: 0.7), shape: BoxShape.circle),
|
decoration: BoxDecoration(color: context.colorScheme.surfaceContainer, shape: BoxShape.circle),
|
||||||
child: Icon(Icons.favorite, color: Colors.red[600], size: 18),
|
child: Icon(Icons.thumb_up, color: context.primaryColor, size: 18),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|
@ -81,8 +81,8 @@ class CommentBubble extends ConsumerWidget {
|
||||||
if (isLike && !showThumbnail) {
|
if (isLike && !showThumbnail) {
|
||||||
likes = Container(
|
likes = Container(
|
||||||
padding: const EdgeInsets.all(8),
|
padding: const EdgeInsets.all(8),
|
||||||
decoration: BoxDecoration(color: Colors.white.withValues(alpha: 0.7), shape: BoxShape.circle),
|
decoration: BoxDecoration(color: context.colorScheme.surfaceContainer, shape: BoxShape.circle),
|
||||||
child: Icon(Icons.favorite, color: Colors.red[600], size: 18),
|
child: Icon(Icons.thumb_up, color: context.primaryColor, size: 18),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -77,15 +77,15 @@ void main() {
|
||||||
overrides: overrides,
|
overrides: overrides,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(find.widgetWithIcon(IconButton, Icons.favorite_rounded), findsOneWidget);
|
expect(find.widgetWithIcon(IconButton, Icons.thumb_up), findsOneWidget);
|
||||||
expect(find.widgetWithIcon(IconButton, Icons.favorite_border_rounded), findsNothing);
|
expect(find.widgetWithIcon(IconButton, Icons.thumb_up_off_alt), findsNothing);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Bordered icon if likedId == null', (tester) async {
|
testWidgets('Bordered icon if likedId == null', (tester) async {
|
||||||
await tester.pumpConsumerWidget(ActivityTextField(onSubmit: (_) {}), overrides: overrides);
|
await tester.pumpConsumerWidget(ActivityTextField(onSubmit: (_) {}), overrides: overrides);
|
||||||
|
|
||||||
expect(find.widgetWithIcon(IconButton, Icons.favorite_border_rounded), findsOneWidget);
|
expect(find.widgetWithIcon(IconButton, Icons.thumb_up_off_alt), findsOneWidget);
|
||||||
expect(find.widgetWithIcon(IconButton, Icons.favorite_rounded), findsNothing);
|
expect(find.widgetWithIcon(IconButton, Icons.thumb_up), findsNothing);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Adds new like', (tester) async {
|
testWidgets('Adds new like', (tester) async {
|
||||||
|
|
|
||||||
|
|
@ -91,17 +91,17 @@ void main() {
|
||||||
group('Like Activity', () {
|
group('Like Activity', () {
|
||||||
final activity = Activity(id: '1', createdAt: DateTime(100), type: ActivityType.like, user: UserStub.admin);
|
final activity = Activity(id: '1', createdAt: DateTime(100), type: ActivityType.like, user: UserStub.admin);
|
||||||
|
|
||||||
testWidgets('Like contains filled heart as leading', (tester) async {
|
testWidgets('Like contains filled thumbs-up as leading', (tester) async {
|
||||||
await tester.pumpConsumerWidget(ActivityTile(activity), overrides: overrides);
|
await tester.pumpConsumerWidget(ActivityTile(activity), overrides: overrides);
|
||||||
|
|
||||||
// Leading widget should not be null
|
// Leading widget should not be null
|
||||||
final listTile = tester.widget<ListTile>(find.byType(ListTile));
|
final listTile = tester.widget<ListTile>(find.byType(ListTile));
|
||||||
expect(listTile.leading, isNotNull);
|
expect(listTile.leading, isNotNull);
|
||||||
|
|
||||||
// And should have a favorite icon
|
// And should have a thumb_up icon
|
||||||
final favoIconFinder = find.widgetWithIcon(listTile.leading!.runtimeType, Icons.favorite_rounded);
|
final thumbUpIconFinder = find.widgetWithIcon(listTile.leading!.runtimeType, Icons.thumb_up);
|
||||||
|
|
||||||
expect(favoIconFinder, findsOneWidget);
|
expect(thumbUpIconFinder, findsOneWidget);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Like title is center aligned', (tester) async {
|
testWidgets('Like title is center aligned', (tester) async {
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
"@oazapfts/runtime": "^1.0.2"
|
"@oazapfts/runtime": "^1.0.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^24.10.1",
|
"@types/node": "^24.10.3",
|
||||||
"typescript": "^5.3.3"
|
"typescript": "^5.3.3"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ importers:
|
||||||
specifier: ^4.13.1
|
specifier: ^4.13.1
|
||||||
version: 4.13.4
|
version: 4.13.4
|
||||||
'@types/node':
|
'@types/node':
|
||||||
specifier: ^24.10.1
|
specifier: ^24.10.3
|
||||||
version: 24.10.4
|
version: 24.10.4
|
||||||
'@vitest/coverage-v8':
|
'@vitest/coverage-v8':
|
||||||
specifier: ^3.0.0
|
specifier: ^3.0.0
|
||||||
|
|
@ -214,7 +214,7 @@ importers:
|
||||||
specifier: ^3.4.2
|
specifier: ^3.4.2
|
||||||
version: 3.7.1
|
version: 3.7.1
|
||||||
'@types/node':
|
'@types/node':
|
||||||
specifier: ^24.10.1
|
specifier: ^24.10.3
|
||||||
version: 24.10.4
|
version: 24.10.4
|
||||||
'@types/oidc-provider':
|
'@types/oidc-provider':
|
||||||
specifier: ^9.0.0
|
specifier: ^9.0.0
|
||||||
|
|
@ -299,7 +299,7 @@ importers:
|
||||||
version: 1.1.0
|
version: 1.1.0
|
||||||
devDependencies:
|
devDependencies:
|
||||||
'@types/node':
|
'@types/node':
|
||||||
specifier: ^24.10.1
|
specifier: ^24.10.3
|
||||||
version: 24.10.4
|
version: 24.10.4
|
||||||
typescript:
|
typescript:
|
||||||
specifier: ^5.3.3
|
specifier: ^5.3.3
|
||||||
|
|
@ -615,7 +615,7 @@ importers:
|
||||||
specifier: ^2.0.0
|
specifier: ^2.0.0
|
||||||
version: 2.0.0
|
version: 2.0.0
|
||||||
'@types/node':
|
'@types/node':
|
||||||
specifier: ^24.10.1
|
specifier: ^24.10.3
|
||||||
version: 24.10.4
|
version: 24.10.4
|
||||||
'@types/nodemailer':
|
'@types/nodemailer':
|
||||||
specifier: ^7.0.0
|
specifier: ^7.0.0
|
||||||
|
|
@ -16567,7 +16567,7 @@ snapshots:
|
||||||
|
|
||||||
'@types/connect-history-api-fallback@1.5.4':
|
'@types/connect-history-api-fallback@1.5.4':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@types/express-serve-static-core': 4.19.7
|
'@types/express-serve-static-core': 5.1.0
|
||||||
'@types/node': 24.10.4
|
'@types/node': 24.10.4
|
||||||
|
|
||||||
'@types/connect@3.4.38':
|
'@types/connect@3.4.38':
|
||||||
|
|
@ -16813,7 +16813,7 @@ snapshots:
|
||||||
|
|
||||||
'@types/pg-pool@2.0.6':
|
'@types/pg-pool@2.0.6':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@types/pg': 8.15.6
|
'@types/pg': 8.16.0
|
||||||
|
|
||||||
'@types/pg@8.15.6':
|
'@types/pg@8.15.6':
|
||||||
dependencies:
|
dependencies:
|
||||||
|
|
|
||||||
|
|
@ -134,7 +134,7 @@
|
||||||
"@types/luxon": "^3.6.2",
|
"@types/luxon": "^3.6.2",
|
||||||
"@types/mock-fs": "^4.13.1",
|
"@types/mock-fs": "^4.13.1",
|
||||||
"@types/multer": "^2.0.0",
|
"@types/multer": "^2.0.0",
|
||||||
"@types/node": "^24.10.1",
|
"@types/node": "^24.10.3",
|
||||||
"@types/nodemailer": "^7.0.0",
|
"@types/nodemailer": "^7.0.0",
|
||||||
"@types/picomatch": "^4.0.0",
|
"@types/picomatch": "^4.0.0",
|
||||||
"@types/pngjs": "^6.0.5",
|
"@types/pngjs": "^6.0.5",
|
||||||
|
|
|
||||||
|
|
@ -240,7 +240,7 @@ export type Session = {
|
||||||
isPendingSyncReset: boolean;
|
isPendingSyncReset: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type Exif = Omit<Selectable<AssetExifTable>, 'updatedAt' | 'updateId'>;
|
export type Exif = Omit<Selectable<AssetExifTable>, 'updatedAt' | 'updateId' | 'lockedProperties'>;
|
||||||
|
|
||||||
export type Person = {
|
export type Person = {
|
||||||
createdAt: Date;
|
createdAt: Date;
|
||||||
|
|
@ -465,3 +465,13 @@ export const columns = {
|
||||||
'plugin.updatedAt as updatedAt',
|
'plugin.updatedAt as updatedAt',
|
||||||
],
|
],
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
export type LockableProperty = (typeof lockableProperties)[number];
|
||||||
|
export const lockableProperties = [
|
||||||
|
'description',
|
||||||
|
'dateTimeOriginal',
|
||||||
|
'latitude',
|
||||||
|
'longitude',
|
||||||
|
'rating',
|
||||||
|
'timeZone',
|
||||||
|
] as const;
|
||||||
|
|
|
||||||
|
|
@ -50,9 +50,11 @@ select
|
||||||
where
|
where
|
||||||
"asset"."id" = "tag_asset"."assetId"
|
"asset"."id" = "tag_asset"."assetId"
|
||||||
) as agg
|
) as agg
|
||||||
) as "tags"
|
) as "tags",
|
||||||
|
to_json("asset_exif") as "exifInfo"
|
||||||
from
|
from
|
||||||
"asset"
|
"asset"
|
||||||
|
inner join "asset_exif" on "asset"."id" = "asset_exif"."assetId"
|
||||||
where
|
where
|
||||||
"asset"."id" = $2::uuid
|
"asset"."id" = $2::uuid
|
||||||
limit
|
limit
|
||||||
|
|
@ -224,6 +226,14 @@ from
|
||||||
where
|
where
|
||||||
"asset"."id" = $2
|
"asset"."id" = $2
|
||||||
|
|
||||||
|
-- AssetJobRepository.getLockedPropertiesForMetadataExtraction
|
||||||
|
select
|
||||||
|
"asset_exif"."lockedProperties"
|
||||||
|
from
|
||||||
|
"asset_exif"
|
||||||
|
where
|
||||||
|
"asset_exif"."assetId" = $1
|
||||||
|
|
||||||
-- AssetJobRepository.getAlbumThumbnailFiles
|
-- AssetJobRepository.getAlbumThumbnailFiles
|
||||||
select
|
select
|
||||||
"asset_file"."id",
|
"asset_file"."id",
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,49 @@
|
||||||
-- NOTE: This file is auto generated by ./sql-generator
|
-- NOTE: This file is auto generated by ./sql-generator
|
||||||
|
|
||||||
|
-- AssetRepository.upsertExif
|
||||||
|
insert into
|
||||||
|
"asset_exif" ("dateTimeOriginal", "lockedProperties")
|
||||||
|
values
|
||||||
|
($1, $2)
|
||||||
|
on conflict ("assetId") do update
|
||||||
|
set
|
||||||
|
"dateTimeOriginal" = "excluded"."dateTimeOriginal",
|
||||||
|
"lockedProperties" = nullif(
|
||||||
|
array(
|
||||||
|
select distinct
|
||||||
|
unnest("asset_exif"."lockedProperties" || $3)
|
||||||
|
),
|
||||||
|
'{}'
|
||||||
|
)
|
||||||
|
|
||||||
-- AssetRepository.updateAllExif
|
-- AssetRepository.updateAllExif
|
||||||
update "asset_exif"
|
update "asset_exif"
|
||||||
set
|
set
|
||||||
"model" = $1
|
"model" = $1,
|
||||||
|
"lockedProperties" = nullif(
|
||||||
|
array(
|
||||||
|
select distinct
|
||||||
|
unnest("asset_exif"."lockedProperties" || $2)
|
||||||
|
),
|
||||||
|
'{}'
|
||||||
|
)
|
||||||
where
|
where
|
||||||
"assetId" in ($2)
|
"assetId" in ($3)
|
||||||
|
|
||||||
-- AssetRepository.updateDateTimeOriginal
|
-- AssetRepository.updateDateTimeOriginal
|
||||||
update "asset_exif"
|
update "asset_exif"
|
||||||
set
|
set
|
||||||
"dateTimeOriginal" = "dateTimeOriginal" + $1::interval,
|
"dateTimeOriginal" = "dateTimeOriginal" + $1::interval,
|
||||||
"timeZone" = $2
|
"timeZone" = $2,
|
||||||
|
"lockedProperties" = nullif(
|
||||||
|
array(
|
||||||
|
select distinct
|
||||||
|
unnest("asset_exif"."lockedProperties" || $3)
|
||||||
|
),
|
||||||
|
'{}'
|
||||||
|
)
|
||||||
where
|
where
|
||||||
"assetId" in ($3)
|
"assetId" in ($4)
|
||||||
returning
|
returning
|
||||||
"assetId",
|
"assetId",
|
||||||
"dateTimeOriginal",
|
"dateTimeOriginal",
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,7 @@ export class AssetJobRepository {
|
||||||
.whereRef('asset.id', '=', 'tag_asset.assetId'),
|
.whereRef('asset.id', '=', 'tag_asset.assetId'),
|
||||||
).as('tags'),
|
).as('tags'),
|
||||||
)
|
)
|
||||||
|
.$call(withExifInner)
|
||||||
.limit(1)
|
.limit(1)
|
||||||
.executeTakeFirst();
|
.executeTakeFirst();
|
||||||
}
|
}
|
||||||
|
|
@ -128,6 +129,16 @@ export class AssetJobRepository {
|
||||||
.executeTakeFirst();
|
.executeTakeFirst();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GenerateSql({ params: [DummyValue.UUID] })
|
||||||
|
async getLockedPropertiesForMetadataExtraction(assetId: string) {
|
||||||
|
return this.db
|
||||||
|
.selectFrom('asset_exif')
|
||||||
|
.select('asset_exif.lockedProperties')
|
||||||
|
.where('asset_exif.assetId', '=', assetId)
|
||||||
|
.executeTakeFirst()
|
||||||
|
.then((row) => row?.lockedProperties ?? []);
|
||||||
|
}
|
||||||
|
|
||||||
@GenerateSql({ params: [DummyValue.UUID, AssetFileType.Thumbnail] })
|
@GenerateSql({ params: [DummyValue.UUID, AssetFileType.Thumbnail] })
|
||||||
getAlbumThumbnailFiles(id: string, fileType?: AssetFileType) {
|
getAlbumThumbnailFiles(id: string, fileType?: AssetFileType) {
|
||||||
return this.db
|
return this.db
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
import { Insertable, Kysely, NotNull, Selectable, sql, Updateable, UpdateResult } from 'kysely';
|
import { ExpressionBuilder, Insertable, Kysely, NotNull, Selectable, sql, Updateable, UpdateResult } from 'kysely';
|
||||||
import { isEmpty, isUndefined, omitBy } from 'lodash';
|
import { isEmpty, isUndefined, omitBy } from 'lodash';
|
||||||
import { InjectKysely } from 'nestjs-kysely';
|
import { InjectKysely } from 'nestjs-kysely';
|
||||||
import { Stack } from 'src/database';
|
import { LockableProperty, Stack } from 'src/database';
|
||||||
import { Chunked, ChunkedArray, DummyValue, GenerateSql } from 'src/decorators';
|
import { Chunked, ChunkedArray, DummyValue, GenerateSql } from 'src/decorators';
|
||||||
import { AuthDto } from 'src/dtos/auth.dto';
|
import { AuthDto } from 'src/dtos/auth.dto';
|
||||||
import { AssetFileType, AssetMetadataKey, AssetOrder, AssetStatus, AssetType, AssetVisibility } from 'src/enum';
|
import { AssetFileType, AssetMetadataKey, AssetOrder, AssetStatus, AssetType, AssetVisibility } from 'src/enum';
|
||||||
|
|
@ -113,51 +113,77 @@ interface GetByIdsRelations {
|
||||||
tags?: boolean;
|
tags?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const distinctLocked = <T extends LockableProperty[] | null>(eb: ExpressionBuilder<DB, 'asset_exif'>, columns: T) =>
|
||||||
|
sql<T>`nullif(array(select distinct unnest(${eb.ref('asset_exif.lockedProperties')} || ${columns})), '{}')`;
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class AssetRepository {
|
export class AssetRepository {
|
||||||
constructor(@InjectKysely() private db: Kysely<DB>) {}
|
constructor(@InjectKysely() private db: Kysely<DB>) {}
|
||||||
|
|
||||||
async upsertExif(exif: Insertable<AssetExifTable>): Promise<void> {
|
@GenerateSql({
|
||||||
const value = { ...exif, assetId: asUuid(exif.assetId) };
|
params: [
|
||||||
|
{ dateTimeOriginal: DummyValue.DATE, lockedProperties: ['dateTimeOriginal'] },
|
||||||
|
{ lockedPropertiesBehavior: 'append' },
|
||||||
|
],
|
||||||
|
})
|
||||||
|
async upsertExif(
|
||||||
|
exif: Insertable<AssetExifTable>,
|
||||||
|
{ lockedPropertiesBehavior }: { lockedPropertiesBehavior: 'override' | 'append' | 'skip' },
|
||||||
|
): Promise<void> {
|
||||||
await this.db
|
await this.db
|
||||||
.insertInto('asset_exif')
|
.insertInto('asset_exif')
|
||||||
.values(value)
|
.values(exif)
|
||||||
.onConflict((oc) =>
|
.onConflict((oc) =>
|
||||||
oc.column('assetId').doUpdateSet((eb) =>
|
oc.column('assetId').doUpdateSet((eb) => {
|
||||||
removeUndefinedKeys(
|
const updateLocked = <T extends keyof AssetExifTable>(col: T) => eb.ref(`excluded.${col}`);
|
||||||
{
|
const skipLocked = <T extends keyof AssetExifTable>(col: T) =>
|
||||||
description: eb.ref('excluded.description'),
|
eb
|
||||||
exifImageWidth: eb.ref('excluded.exifImageWidth'),
|
.case()
|
||||||
exifImageHeight: eb.ref('excluded.exifImageHeight'),
|
.when(sql`${col}`, '=', eb.fn.any('asset_exif.lockedProperties'))
|
||||||
fileSizeInByte: eb.ref('excluded.fileSizeInByte'),
|
.then(eb.ref(`asset_exif.${col}`))
|
||||||
orientation: eb.ref('excluded.orientation'),
|
.else(eb.ref(`excluded.${col}`))
|
||||||
dateTimeOriginal: eb.ref('excluded.dateTimeOriginal'),
|
.end();
|
||||||
modifyDate: eb.ref('excluded.modifyDate'),
|
const ref = lockedPropertiesBehavior === 'skip' ? skipLocked : updateLocked;
|
||||||
timeZone: eb.ref('excluded.timeZone'),
|
return {
|
||||||
latitude: eb.ref('excluded.latitude'),
|
...removeUndefinedKeys(
|
||||||
longitude: eb.ref('excluded.longitude'),
|
{
|
||||||
projectionType: eb.ref('excluded.projectionType'),
|
description: ref('description'),
|
||||||
city: eb.ref('excluded.city'),
|
exifImageWidth: ref('exifImageWidth'),
|
||||||
livePhotoCID: eb.ref('excluded.livePhotoCID'),
|
exifImageHeight: ref('exifImageHeight'),
|
||||||
autoStackId: eb.ref('excluded.autoStackId'),
|
fileSizeInByte: ref('fileSizeInByte'),
|
||||||
state: eb.ref('excluded.state'),
|
orientation: ref('orientation'),
|
||||||
country: eb.ref('excluded.country'),
|
dateTimeOriginal: ref('dateTimeOriginal'),
|
||||||
make: eb.ref('excluded.make'),
|
modifyDate: ref('modifyDate'),
|
||||||
model: eb.ref('excluded.model'),
|
timeZone: ref('timeZone'),
|
||||||
lensModel: eb.ref('excluded.lensModel'),
|
latitude: ref('latitude'),
|
||||||
fNumber: eb.ref('excluded.fNumber'),
|
longitude: ref('longitude'),
|
||||||
focalLength: eb.ref('excluded.focalLength'),
|
projectionType: ref('projectionType'),
|
||||||
iso: eb.ref('excluded.iso'),
|
city: ref('city'),
|
||||||
exposureTime: eb.ref('excluded.exposureTime'),
|
livePhotoCID: ref('livePhotoCID'),
|
||||||
profileDescription: eb.ref('excluded.profileDescription'),
|
autoStackId: ref('autoStackId'),
|
||||||
colorspace: eb.ref('excluded.colorspace'),
|
state: ref('state'),
|
||||||
bitsPerSample: eb.ref('excluded.bitsPerSample'),
|
country: ref('country'),
|
||||||
rating: eb.ref('excluded.rating'),
|
make: ref('make'),
|
||||||
fps: eb.ref('excluded.fps'),
|
model: ref('model'),
|
||||||
},
|
lensModel: ref('lensModel'),
|
||||||
value,
|
fNumber: ref('fNumber'),
|
||||||
),
|
focalLength: ref('focalLength'),
|
||||||
),
|
iso: ref('iso'),
|
||||||
|
exposureTime: ref('exposureTime'),
|
||||||
|
profileDescription: ref('profileDescription'),
|
||||||
|
colorspace: ref('colorspace'),
|
||||||
|
bitsPerSample: ref('bitsPerSample'),
|
||||||
|
rating: ref('rating'),
|
||||||
|
fps: ref('fps'),
|
||||||
|
lockedProperties:
|
||||||
|
lockedPropertiesBehavior === 'append'
|
||||||
|
? distinctLocked(eb, exif.lockedProperties ?? null)
|
||||||
|
: ref('lockedProperties'),
|
||||||
|
},
|
||||||
|
exif,
|
||||||
|
),
|
||||||
|
};
|
||||||
|
}),
|
||||||
)
|
)
|
||||||
.execute();
|
.execute();
|
||||||
}
|
}
|
||||||
|
|
@ -169,19 +195,26 @@ export class AssetRepository {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.db.updateTable('asset_exif').set(options).where('assetId', 'in', ids).execute();
|
await this.db
|
||||||
|
.updateTable('asset_exif')
|
||||||
|
.set((eb) => ({
|
||||||
|
...options,
|
||||||
|
lockedProperties: distinctLocked(eb, Object.keys(options) as LockableProperty[]),
|
||||||
|
}))
|
||||||
|
.where('assetId', 'in', ids)
|
||||||
|
.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
@GenerateSql({ params: [[DummyValue.UUID], DummyValue.NUMBER, DummyValue.STRING] })
|
@GenerateSql({ params: [[DummyValue.UUID], DummyValue.NUMBER, DummyValue.STRING] })
|
||||||
@Chunked()
|
@Chunked()
|
||||||
async updateDateTimeOriginal(
|
updateDateTimeOriginal(ids: string[], delta?: number, timeZone?: string) {
|
||||||
ids: string[],
|
return this.db
|
||||||
delta?: number,
|
|
||||||
timeZone?: string,
|
|
||||||
): Promise<{ assetId: string; dateTimeOriginal: Date | null; timeZone: string | null }[]> {
|
|
||||||
return await this.db
|
|
||||||
.updateTable('asset_exif')
|
.updateTable('asset_exif')
|
||||||
.set({ dateTimeOriginal: sql`"dateTimeOriginal" + ${(delta ?? 0) + ' minute'}::interval`, timeZone })
|
.set((eb) => ({
|
||||||
|
dateTimeOriginal: sql`"dateTimeOriginal" + ${(delta ?? 0) + ' minute'}::interval`,
|
||||||
|
timeZone,
|
||||||
|
lockedProperties: distinctLocked(eb, ['dateTimeOriginal', 'timeZone']),
|
||||||
|
}))
|
||||||
.where('assetId', 'in', ids)
|
.where('assetId', 'in', ids)
|
||||||
.returning(['assetId', 'dateTimeOriginal', 'timeZone'])
|
.returning(['assetId', 'dateTimeOriginal', 'timeZone'])
|
||||||
.execute();
|
.execute();
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
import { Kysely, sql } from 'kysely';
|
||||||
|
|
||||||
|
export async function up(db: Kysely<any>): Promise<void> {
|
||||||
|
await sql`ALTER TABLE "asset_exif" ADD "lockedProperties" character varying[];`.execute(db);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function down(db: Kysely<any>): Promise<void> {
|
||||||
|
await sql`ALTER TABLE "asset_exif" DROP COLUMN "lockedProperties";`.execute(db);
|
||||||
|
}
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { LockableProperty } from 'src/database';
|
||||||
import { UpdatedAtTrigger, UpdateIdColumn } from 'src/decorators';
|
import { UpdatedAtTrigger, UpdateIdColumn } from 'src/decorators';
|
||||||
import { AssetTable } from 'src/schema/tables/asset.table';
|
import { AssetTable } from 'src/schema/tables/asset.table';
|
||||||
import { Column, ForeignKeyColumn, Generated, Int8, Table, Timestamp, UpdateDateColumn } from 'src/sql-tools';
|
import { Column, ForeignKeyColumn, Generated, Int8, Table, Timestamp, UpdateDateColumn } from 'src/sql-tools';
|
||||||
|
|
@ -97,4 +98,7 @@ export class AssetExifTable {
|
||||||
|
|
||||||
@UpdateIdColumn({ index: true })
|
@UpdateIdColumn({ index: true })
|
||||||
updateId!: Generated<string>;
|
updateId!: Generated<string>;
|
||||||
|
|
||||||
|
@Column({ type: 'character varying', array: true, nullable: true })
|
||||||
|
lockedProperties!: Array<LockableProperty> | null;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -370,7 +370,10 @@ export class AssetMediaService extends BaseService {
|
||||||
: this.assetRepository.deleteFile({ assetId, type: AssetFileType.Sidecar }));
|
: this.assetRepository.deleteFile({ assetId, type: AssetFileType.Sidecar }));
|
||||||
|
|
||||||
await this.storageRepository.utimes(file.originalPath, new Date(), new Date(dto.fileModifiedAt));
|
await this.storageRepository.utimes(file.originalPath, new Date(), new Date(dto.fileModifiedAt));
|
||||||
await this.assetRepository.upsertExif({ assetId, fileSizeInByte: file.size });
|
await this.assetRepository.upsertExif(
|
||||||
|
{ assetId, fileSizeInByte: file.size },
|
||||||
|
{ lockedPropertiesBehavior: 'override' },
|
||||||
|
);
|
||||||
await this.jobRepository.queue({
|
await this.jobRepository.queue({
|
||||||
name: JobName.AssetExtractMetadata,
|
name: JobName.AssetExtractMetadata,
|
||||||
data: { id: assetId, source: 'upload' },
|
data: { id: assetId, source: 'upload' },
|
||||||
|
|
@ -399,7 +402,10 @@ export class AssetMediaService extends BaseService {
|
||||||
});
|
});
|
||||||
|
|
||||||
const { size } = await this.storageRepository.stat(created.originalPath);
|
const { size } = await this.storageRepository.stat(created.originalPath);
|
||||||
await this.assetRepository.upsertExif({ assetId: created.id, fileSizeInByte: size });
|
await this.assetRepository.upsertExif(
|
||||||
|
{ assetId: created.id, fileSizeInByte: size },
|
||||||
|
{ lockedPropertiesBehavior: 'override' },
|
||||||
|
);
|
||||||
await this.jobRepository.queue({ name: JobName.AssetExtractMetadata, data: { id: created.id, source: 'copy' } });
|
await this.jobRepository.queue({ name: JobName.AssetExtractMetadata, data: { id: created.id, source: 'copy' } });
|
||||||
return created;
|
return created;
|
||||||
}
|
}
|
||||||
|
|
@ -440,7 +446,10 @@ export class AssetMediaService extends BaseService {
|
||||||
await this.storageRepository.utimes(sidecarFile.originalPath, new Date(), new Date(dto.fileModifiedAt));
|
await this.storageRepository.utimes(sidecarFile.originalPath, new Date(), new Date(dto.fileModifiedAt));
|
||||||
}
|
}
|
||||||
await this.storageRepository.utimes(file.originalPath, new Date(), new Date(dto.fileModifiedAt));
|
await this.storageRepository.utimes(file.originalPath, new Date(), new Date(dto.fileModifiedAt));
|
||||||
await this.assetRepository.upsertExif({ assetId: asset.id, fileSizeInByte: file.size });
|
await this.assetRepository.upsertExif(
|
||||||
|
{ assetId: asset.id, fileSizeInByte: file.size },
|
||||||
|
{ lockedPropertiesBehavior: 'override' },
|
||||||
|
);
|
||||||
|
|
||||||
await this.eventRepository.emit('AssetCreate', { asset });
|
await this.eventRepository.emit('AssetCreate', { asset });
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -225,7 +225,10 @@ describe(AssetService.name, () => {
|
||||||
|
|
||||||
await sut.update(authStub.admin, 'asset-1', { description: 'Test description' });
|
await sut.update(authStub.admin, 'asset-1', { description: 'Test description' });
|
||||||
|
|
||||||
expect(mocks.asset.upsertExif).toHaveBeenCalledWith({ assetId: 'asset-1', description: 'Test description' });
|
expect(mocks.asset.upsertExif).toHaveBeenCalledWith(
|
||||||
|
{ assetId: 'asset-1', description: 'Test description', lockedProperties: ['description'] },
|
||||||
|
{ lockedPropertiesBehavior: 'append' },
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should update the exif rating', async () => {
|
it('should update the exif rating', async () => {
|
||||||
|
|
@ -235,7 +238,14 @@ describe(AssetService.name, () => {
|
||||||
|
|
||||||
await sut.update(authStub.admin, 'asset-1', { rating: 3 });
|
await sut.update(authStub.admin, 'asset-1', { rating: 3 });
|
||||||
|
|
||||||
expect(mocks.asset.upsertExif).toHaveBeenCalledWith({ assetId: 'asset-1', rating: 3 });
|
expect(mocks.asset.upsertExif).toHaveBeenCalledWith(
|
||||||
|
{
|
||||||
|
assetId: 'asset-1',
|
||||||
|
rating: 3,
|
||||||
|
lockedProperties: ['rating'],
|
||||||
|
},
|
||||||
|
{ lockedPropertiesBehavior: 'append' },
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should fail linking a live video if the motion part could not be found', async () => {
|
it('should fail linking a live video if the motion part could not be found', async () => {
|
||||||
|
|
@ -427,9 +437,7 @@ describe(AssetService.name, () => {
|
||||||
});
|
});
|
||||||
expect(mocks.asset.updateAll).toHaveBeenCalled();
|
expect(mocks.asset.updateAll).toHaveBeenCalled();
|
||||||
expect(mocks.asset.updateAllExif).toHaveBeenCalledWith(['asset-1'], { latitude: 0, longitude: 0 });
|
expect(mocks.asset.updateAllExif).toHaveBeenCalledWith(['asset-1'], { latitude: 0, longitude: 0 });
|
||||||
expect(mocks.job.queueAll).toHaveBeenCalledWith([
|
expect(mocks.job.queueAll).toHaveBeenCalledWith([{ name: JobName.SidecarWrite, data: { id: 'asset-1' } }]);
|
||||||
{ name: JobName.SidecarWrite, data: { id: 'asset-1', latitude: 0, longitude: 0 } },
|
|
||||||
]);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should update exif table if latitude field is provided', async () => {
|
it('should update exif table if latitude field is provided', async () => {
|
||||||
|
|
@ -450,9 +458,7 @@ describe(AssetService.name, () => {
|
||||||
latitude: 30,
|
latitude: 30,
|
||||||
longitude: 50,
|
longitude: 50,
|
||||||
});
|
});
|
||||||
expect(mocks.job.queueAll).toHaveBeenCalledWith([
|
expect(mocks.job.queueAll).toHaveBeenCalledWith([{ name: JobName.SidecarWrite, data: { id: 'asset-1' } }]);
|
||||||
{ name: JobName.SidecarWrite, data: { id: 'asset-1', dateTimeOriginal, latitude: 30, longitude: 50 } },
|
|
||||||
]);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should update Assets table if duplicateId is provided as null', async () => {
|
it('should update Assets table if duplicateId is provided as null', async () => {
|
||||||
|
|
@ -482,18 +488,7 @@ describe(AssetService.name, () => {
|
||||||
timeZone,
|
timeZone,
|
||||||
});
|
});
|
||||||
expect(mocks.asset.updateDateTimeOriginal).toHaveBeenCalledWith(['asset-1'], dateTimeRelative, timeZone);
|
expect(mocks.asset.updateDateTimeOriginal).toHaveBeenCalledWith(['asset-1'], dateTimeRelative, timeZone);
|
||||||
expect(mocks.job.queueAll).toHaveBeenCalledWith([
|
expect(mocks.job.queueAll).toHaveBeenCalledWith([{ name: JobName.SidecarWrite, data: { id: 'asset-1' } }]);
|
||||||
{
|
|
||||||
name: JobName.SidecarWrite,
|
|
||||||
data: {
|
|
||||||
id: 'asset-1',
|
|
||||||
dateTimeOriginal: '2020-02-25T06:41:00.000+02:00',
|
|
||||||
description: undefined,
|
|
||||||
latitude: undefined,
|
|
||||||
longitude: undefined,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
]);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,9 +30,10 @@ import {
|
||||||
QueueName,
|
QueueName,
|
||||||
} from 'src/enum';
|
} from 'src/enum';
|
||||||
import { BaseService } from 'src/services/base.service';
|
import { BaseService } from 'src/services/base.service';
|
||||||
import { ISidecarWriteJob, JobItem, JobOf } from 'src/types';
|
import { JobItem, JobOf } from 'src/types';
|
||||||
import { requireElevatedPermission } from 'src/utils/access';
|
import { requireElevatedPermission } from 'src/utils/access';
|
||||||
import { getAssetFiles, getMyPartnerIds, onAfterUnlink, onBeforeLink, onBeforeUnlink } from 'src/utils/asset.util';
|
import { getAssetFiles, getMyPartnerIds, onAfterUnlink, onBeforeLink, onBeforeUnlink } from 'src/utils/asset.util';
|
||||||
|
import { updateLockedColumns } from 'src/utils/database';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class AssetService extends BaseService {
|
export class AssetService extends BaseService {
|
||||||
|
|
@ -142,56 +143,26 @@ export class AssetService extends BaseService {
|
||||||
} = dto;
|
} = dto;
|
||||||
await this.requireAccess({ auth, permission: Permission.AssetUpdate, ids });
|
await this.requireAccess({ auth, permission: Permission.AssetUpdate, ids });
|
||||||
|
|
||||||
const assetDto = { isFavorite, visibility, duplicateId };
|
const assetDto = _.omitBy({ isFavorite, visibility, duplicateId }, _.isUndefined);
|
||||||
const exifDto = { latitude, longitude, rating, description, dateTimeOriginal };
|
const exifDto = _.omitBy({ latitude, longitude, rating, description, dateTimeOriginal }, _.isUndefined);
|
||||||
|
|
||||||
const isExifChanged = Object.values(exifDto).some((v) => v !== undefined);
|
if (Object.keys(exifDto).length > 0) {
|
||||||
if (isExifChanged) {
|
|
||||||
await this.assetRepository.updateAllExif(ids, exifDto);
|
await this.assetRepository.updateAllExif(ids, exifDto);
|
||||||
}
|
}
|
||||||
|
|
||||||
const assets =
|
if ((dateTimeRelative !== undefined && dateTimeRelative !== 0) || timeZone !== undefined) {
|
||||||
(dateTimeRelative !== undefined && dateTimeRelative !== 0) || timeZone !== undefined
|
await this.assetRepository.updateDateTimeOriginal(ids, dateTimeRelative, timeZone);
|
||||||
? await this.assetRepository.updateDateTimeOriginal(ids, dateTimeRelative, timeZone)
|
|
||||||
: undefined;
|
|
||||||
|
|
||||||
const dateTimesWithTimezone = assets
|
|
||||||
? assets.map((asset) => {
|
|
||||||
const isoString = asset.dateTimeOriginal?.toISOString();
|
|
||||||
let dateTime = isoString ? DateTime.fromISO(isoString) : null;
|
|
||||||
|
|
||||||
if (dateTime && asset.timeZone) {
|
|
||||||
dateTime = dateTime.setZone(asset.timeZone);
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
assetId: asset.assetId,
|
|
||||||
dateTimeOriginal: dateTime?.toISO() ?? null,
|
|
||||||
};
|
|
||||||
})
|
|
||||||
: ids.map((id) => ({ assetId: id, dateTimeOriginal }));
|
|
||||||
|
|
||||||
if (dateTimesWithTimezone.length > 0) {
|
|
||||||
await this.jobRepository.queueAll(
|
|
||||||
dateTimesWithTimezone.map(({ assetId: id, dateTimeOriginal }) => ({
|
|
||||||
name: JobName.SidecarWrite,
|
|
||||||
data: {
|
|
||||||
...exifDto,
|
|
||||||
id,
|
|
||||||
dateTimeOriginal: dateTimeOriginal ?? undefined,
|
|
||||||
},
|
|
||||||
})),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const isAssetChanged = Object.values(assetDto).some((v) => v !== undefined);
|
if (Object.keys(assetDto).length > 0) {
|
||||||
if (isAssetChanged) {
|
|
||||||
await this.assetRepository.updateAll(ids, assetDto);
|
await this.assetRepository.updateAll(ids, assetDto);
|
||||||
|
|
||||||
if (visibility === AssetVisibility.Locked) {
|
|
||||||
await this.albumRepository.removeAssetsFromAll(ids);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (visibility === AssetVisibility.Locked) {
|
||||||
|
await this.albumRepository.removeAssetsFromAll(ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
await this.jobRepository.queueAll(ids.map((id) => ({ name: JobName.SidecarWrite, data: { id } })));
|
||||||
}
|
}
|
||||||
|
|
||||||
async copy(
|
async copy(
|
||||||
|
|
@ -456,12 +427,25 @@ export class AssetService extends BaseService {
|
||||||
return asset;
|
return asset;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async updateExif(dto: ISidecarWriteJob) {
|
private async updateExif(dto: {
|
||||||
|
id: string;
|
||||||
|
description?: string;
|
||||||
|
dateTimeOriginal?: string;
|
||||||
|
latitude?: number;
|
||||||
|
longitude?: number;
|
||||||
|
rating?: number;
|
||||||
|
}) {
|
||||||
const { id, description, dateTimeOriginal, latitude, longitude, rating } = dto;
|
const { id, description, dateTimeOriginal, latitude, longitude, rating } = dto;
|
||||||
const writes = _.omitBy({ description, dateTimeOriginal, latitude, longitude, rating }, _.isUndefined);
|
const writes = _.omitBy({ description, dateTimeOriginal, latitude, longitude, rating }, _.isUndefined);
|
||||||
if (Object.keys(writes).length > 0) {
|
if (Object.keys(writes).length > 0) {
|
||||||
await this.assetRepository.upsertExif({ assetId: id, ...writes });
|
await this.assetRepository.upsertExif(
|
||||||
await this.jobRepository.queue({ name: JobName.SidecarWrite, data: { id, ...writes } });
|
updateLockedColumns({
|
||||||
|
assetId: id,
|
||||||
|
...writes,
|
||||||
|
}),
|
||||||
|
{ lockedPropertiesBehavior: 'append' },
|
||||||
|
);
|
||||||
|
await this.jobRepository.queue({ name: JobName.SidecarWrite, data: { id } });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -187,7 +187,9 @@ describe(MetadataService.name, () => {
|
||||||
|
|
||||||
await sut.handleMetadataExtraction({ id: assetStub.image.id });
|
await sut.handleMetadataExtraction({ id: assetStub.image.id });
|
||||||
expect(mocks.assetJob.getForMetadataExtraction).toHaveBeenCalledWith(assetStub.sidecar.id);
|
expect(mocks.assetJob.getForMetadataExtraction).toHaveBeenCalledWith(assetStub.sidecar.id);
|
||||||
expect(mocks.asset.upsertExif).toHaveBeenCalledWith(expect.objectContaining({ dateTimeOriginal: sidecarDate }));
|
expect(mocks.asset.upsertExif).toHaveBeenCalledWith(expect.objectContaining({ dateTimeOriginal: sidecarDate }), {
|
||||||
|
lockedPropertiesBehavior: 'skip',
|
||||||
|
});
|
||||||
expect(mocks.asset.update).toHaveBeenCalledWith(
|
expect(mocks.asset.update).toHaveBeenCalledWith(
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
id: assetStub.image.id,
|
id: assetStub.image.id,
|
||||||
|
|
@ -214,6 +216,7 @@ describe(MetadataService.name, () => {
|
||||||
expect(mocks.assetJob.getForMetadataExtraction).toHaveBeenCalledWith(assetStub.image.id);
|
expect(mocks.assetJob.getForMetadataExtraction).toHaveBeenCalledWith(assetStub.image.id);
|
||||||
expect(mocks.asset.upsertExif).toHaveBeenCalledWith(
|
expect(mocks.asset.upsertExif).toHaveBeenCalledWith(
|
||||||
expect.objectContaining({ dateTimeOriginal: fileModifiedAt }),
|
expect.objectContaining({ dateTimeOriginal: fileModifiedAt }),
|
||||||
|
{ lockedPropertiesBehavior: 'skip' },
|
||||||
);
|
);
|
||||||
expect(mocks.asset.update).toHaveBeenCalledWith({
|
expect(mocks.asset.update).toHaveBeenCalledWith({
|
||||||
id: assetStub.image.id,
|
id: assetStub.image.id,
|
||||||
|
|
@ -238,7 +241,10 @@ describe(MetadataService.name, () => {
|
||||||
|
|
||||||
await sut.handleMetadataExtraction({ id: assetStub.image.id });
|
await sut.handleMetadataExtraction({ id: assetStub.image.id });
|
||||||
expect(mocks.assetJob.getForMetadataExtraction).toHaveBeenCalledWith(assetStub.image.id);
|
expect(mocks.assetJob.getForMetadataExtraction).toHaveBeenCalledWith(assetStub.image.id);
|
||||||
expect(mocks.asset.upsertExif).toHaveBeenCalledWith(expect.objectContaining({ dateTimeOriginal: fileCreatedAt }));
|
expect(mocks.asset.upsertExif).toHaveBeenCalledWith(
|
||||||
|
expect.objectContaining({ dateTimeOriginal: fileCreatedAt }),
|
||||||
|
{ lockedPropertiesBehavior: 'skip' },
|
||||||
|
);
|
||||||
expect(mocks.asset.update).toHaveBeenCalledWith({
|
expect(mocks.asset.update).toHaveBeenCalledWith({
|
||||||
id: assetStub.image.id,
|
id: assetStub.image.id,
|
||||||
duration: null,
|
duration: null,
|
||||||
|
|
@ -258,6 +264,7 @@ describe(MetadataService.name, () => {
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
dateTimeOriginal: new Date('2022-01-01T00:00:00.000Z'),
|
dateTimeOriginal: new Date('2022-01-01T00:00:00.000Z'),
|
||||||
}),
|
}),
|
||||||
|
{ lockedPropertiesBehavior: 'skip' },
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(mocks.asset.update).toHaveBeenCalledWith(
|
expect(mocks.asset.update).toHaveBeenCalledWith(
|
||||||
|
|
@ -281,7 +288,9 @@ describe(MetadataService.name, () => {
|
||||||
|
|
||||||
await sut.handleMetadataExtraction({ id: assetStub.image.id });
|
await sut.handleMetadataExtraction({ id: assetStub.image.id });
|
||||||
expect(mocks.assetJob.getForMetadataExtraction).toHaveBeenCalledWith(assetStub.image.id);
|
expect(mocks.assetJob.getForMetadataExtraction).toHaveBeenCalledWith(assetStub.image.id);
|
||||||
expect(mocks.asset.upsertExif).toHaveBeenCalledWith(expect.objectContaining({ iso: 160 }));
|
expect(mocks.asset.upsertExif).toHaveBeenCalledWith(expect.objectContaining({ iso: 160 }), {
|
||||||
|
lockedPropertiesBehavior: 'skip',
|
||||||
|
});
|
||||||
expect(mocks.asset.update).toHaveBeenCalledWith({
|
expect(mocks.asset.update).toHaveBeenCalledWith({
|
||||||
id: assetStub.image.id,
|
id: assetStub.image.id,
|
||||||
duration: null,
|
duration: null,
|
||||||
|
|
@ -310,6 +319,7 @@ describe(MetadataService.name, () => {
|
||||||
expect(mocks.assetJob.getForMetadataExtraction).toHaveBeenCalledWith(assetStub.image.id);
|
expect(mocks.assetJob.getForMetadataExtraction).toHaveBeenCalledWith(assetStub.image.id);
|
||||||
expect(mocks.asset.upsertExif).toHaveBeenCalledWith(
|
expect(mocks.asset.upsertExif).toHaveBeenCalledWith(
|
||||||
expect.objectContaining({ city: null, state: null, country: null }),
|
expect.objectContaining({ city: null, state: null, country: null }),
|
||||||
|
{ lockedPropertiesBehavior: 'skip' },
|
||||||
);
|
);
|
||||||
expect(mocks.asset.update).toHaveBeenCalledWith({
|
expect(mocks.asset.update).toHaveBeenCalledWith({
|
||||||
id: assetStub.withLocation.id,
|
id: assetStub.withLocation.id,
|
||||||
|
|
@ -339,6 +349,7 @@ describe(MetadataService.name, () => {
|
||||||
expect(mocks.assetJob.getForMetadataExtraction).toHaveBeenCalledWith(assetStub.image.id);
|
expect(mocks.assetJob.getForMetadataExtraction).toHaveBeenCalledWith(assetStub.image.id);
|
||||||
expect(mocks.asset.upsertExif).toHaveBeenCalledWith(
|
expect(mocks.asset.upsertExif).toHaveBeenCalledWith(
|
||||||
expect.objectContaining({ city: 'City', state: 'State', country: 'Country' }),
|
expect.objectContaining({ city: 'City', state: 'State', country: 'Country' }),
|
||||||
|
{ lockedPropertiesBehavior: 'skip' },
|
||||||
);
|
);
|
||||||
expect(mocks.asset.update).toHaveBeenCalledWith({
|
expect(mocks.asset.update).toHaveBeenCalledWith({
|
||||||
id: assetStub.withLocation.id,
|
id: assetStub.withLocation.id,
|
||||||
|
|
@ -358,7 +369,10 @@ describe(MetadataService.name, () => {
|
||||||
|
|
||||||
await sut.handleMetadataExtraction({ id: assetStub.image.id });
|
await sut.handleMetadataExtraction({ id: assetStub.image.id });
|
||||||
expect(mocks.assetJob.getForMetadataExtraction).toHaveBeenCalledWith(assetStub.image.id);
|
expect(mocks.assetJob.getForMetadataExtraction).toHaveBeenCalledWith(assetStub.image.id);
|
||||||
expect(mocks.asset.upsertExif).toHaveBeenCalledWith(expect.objectContaining({ latitude: null, longitude: null }));
|
expect(mocks.asset.upsertExif).toHaveBeenCalledWith(
|
||||||
|
expect.objectContaining({ latitude: null, longitude: null }),
|
||||||
|
{ lockedPropertiesBehavior: 'skip' },
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should extract tags from TagsList', async () => {
|
it('should extract tags from TagsList', async () => {
|
||||||
|
|
@ -571,6 +585,7 @@ describe(MetadataService.name, () => {
|
||||||
expect(mocks.assetJob.getForMetadataExtraction).toHaveBeenCalledWith(assetStub.video.id);
|
expect(mocks.assetJob.getForMetadataExtraction).toHaveBeenCalledWith(assetStub.video.id);
|
||||||
expect(mocks.asset.upsertExif).toHaveBeenCalledWith(
|
expect(mocks.asset.upsertExif).toHaveBeenCalledWith(
|
||||||
expect.objectContaining({ orientation: ExifOrientation.Rotate270CW.toString() }),
|
expect.objectContaining({ orientation: ExifOrientation.Rotate270CW.toString() }),
|
||||||
|
{ lockedPropertiesBehavior: 'skip' },
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -879,37 +894,40 @@ describe(MetadataService.name, () => {
|
||||||
|
|
||||||
await sut.handleMetadataExtraction({ id: assetStub.image.id });
|
await sut.handleMetadataExtraction({ id: assetStub.image.id });
|
||||||
expect(mocks.assetJob.getForMetadataExtraction).toHaveBeenCalledWith(assetStub.image.id);
|
expect(mocks.assetJob.getForMetadataExtraction).toHaveBeenCalledWith(assetStub.image.id);
|
||||||
expect(mocks.asset.upsertExif).toHaveBeenCalledWith({
|
expect(mocks.asset.upsertExif).toHaveBeenCalledWith(
|
||||||
assetId: assetStub.image.id,
|
{
|
||||||
bitsPerSample: expect.any(Number),
|
assetId: assetStub.image.id,
|
||||||
autoStackId: null,
|
bitsPerSample: expect.any(Number),
|
||||||
colorspace: tags.ColorSpace,
|
autoStackId: null,
|
||||||
dateTimeOriginal: dateForTest,
|
colorspace: tags.ColorSpace,
|
||||||
description: tags.ImageDescription,
|
dateTimeOriginal: dateForTest,
|
||||||
exifImageHeight: null,
|
description: tags.ImageDescription,
|
||||||
exifImageWidth: null,
|
exifImageHeight: null,
|
||||||
exposureTime: tags.ExposureTime,
|
exifImageWidth: null,
|
||||||
fNumber: null,
|
exposureTime: tags.ExposureTime,
|
||||||
fileSizeInByte: 123_456,
|
fNumber: null,
|
||||||
focalLength: tags.FocalLength,
|
fileSizeInByte: 123_456,
|
||||||
fps: null,
|
focalLength: tags.FocalLength,
|
||||||
iso: tags.ISO,
|
fps: null,
|
||||||
latitude: null,
|
iso: tags.ISO,
|
||||||
lensModel: tags.LensModel,
|
latitude: null,
|
||||||
livePhotoCID: tags.MediaGroupUUID,
|
lensModel: tags.LensModel,
|
||||||
longitude: null,
|
livePhotoCID: tags.MediaGroupUUID,
|
||||||
make: tags.Make,
|
longitude: null,
|
||||||
model: tags.Model,
|
make: tags.Make,
|
||||||
modifyDate: expect.any(Date),
|
model: tags.Model,
|
||||||
orientation: tags.Orientation?.toString(),
|
modifyDate: expect.any(Date),
|
||||||
profileDescription: tags.ProfileDescription,
|
orientation: tags.Orientation?.toString(),
|
||||||
projectionType: 'EQUIRECTANGULAR',
|
profileDescription: tags.ProfileDescription,
|
||||||
timeZone: tags.tz,
|
projectionType: 'EQUIRECTANGULAR',
|
||||||
rating: tags.Rating,
|
timeZone: tags.tz,
|
||||||
country: null,
|
rating: tags.Rating,
|
||||||
state: null,
|
country: null,
|
||||||
city: null,
|
state: null,
|
||||||
});
|
city: null,
|
||||||
|
},
|
||||||
|
{ lockedPropertiesBehavior: 'skip' },
|
||||||
|
);
|
||||||
expect(mocks.asset.update).toHaveBeenCalledWith(
|
expect(mocks.asset.update).toHaveBeenCalledWith(
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
id: assetStub.image.id,
|
id: assetStub.image.id,
|
||||||
|
|
@ -943,6 +961,7 @@ describe(MetadataService.name, () => {
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
timeZone: 'UTC+0',
|
timeZone: 'UTC+0',
|
||||||
}),
|
}),
|
||||||
|
{ lockedPropertiesBehavior: 'skip' },
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -1103,6 +1122,7 @@ describe(MetadataService.name, () => {
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
description: '',
|
description: '',
|
||||||
}),
|
}),
|
||||||
|
{ lockedPropertiesBehavior: 'skip' },
|
||||||
);
|
);
|
||||||
|
|
||||||
mockReadTags({ ImageDescription: ' my\n description' });
|
mockReadTags({ ImageDescription: ' my\n description' });
|
||||||
|
|
@ -1111,6 +1131,7 @@ describe(MetadataService.name, () => {
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
description: 'my\n description',
|
description: 'my\n description',
|
||||||
}),
|
}),
|
||||||
|
{ lockedPropertiesBehavior: 'skip' },
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -1123,6 +1144,7 @@ describe(MetadataService.name, () => {
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
description: '1000',
|
description: '1000',
|
||||||
}),
|
}),
|
||||||
|
{ lockedPropertiesBehavior: 'skip' },
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -1346,6 +1368,7 @@ describe(MetadataService.name, () => {
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
modifyDate: expect.any(Date),
|
modifyDate: expect.any(Date),
|
||||||
}),
|
}),
|
||||||
|
{ lockedPropertiesBehavior: 'skip' },
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -1358,6 +1381,7 @@ describe(MetadataService.name, () => {
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
rating: null,
|
rating: null,
|
||||||
}),
|
}),
|
||||||
|
{ lockedPropertiesBehavior: 'skip' },
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -1370,6 +1394,7 @@ describe(MetadataService.name, () => {
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
rating: 5,
|
rating: 5,
|
||||||
}),
|
}),
|
||||||
|
{ lockedPropertiesBehavior: 'skip' },
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -1382,6 +1407,7 @@ describe(MetadataService.name, () => {
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
rating: -1,
|
rating: -1,
|
||||||
}),
|
}),
|
||||||
|
{ lockedPropertiesBehavior: 'skip' },
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -1503,7 +1529,9 @@ describe(MetadataService.name, () => {
|
||||||
mockReadTags(exif);
|
mockReadTags(exif);
|
||||||
|
|
||||||
await sut.handleMetadataExtraction({ id: assetStub.image.id });
|
await sut.handleMetadataExtraction({ id: assetStub.image.id });
|
||||||
expect(mocks.asset.upsertExif).toHaveBeenCalledWith(expect.objectContaining(expected));
|
expect(mocks.asset.upsertExif).toHaveBeenCalledWith(expect.objectContaining(expected), {
|
||||||
|
lockedPropertiesBehavior: 'skip',
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it.each([
|
it.each([
|
||||||
|
|
@ -1529,6 +1557,7 @@ describe(MetadataService.name, () => {
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
lensModel: expected,
|
lensModel: expected,
|
||||||
}),
|
}),
|
||||||
|
{ lockedPropertiesBehavior: 'skip' },
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
@ -1637,12 +1666,14 @@ describe(MetadataService.name, () => {
|
||||||
|
|
||||||
describe('handleSidecarWrite', () => {
|
describe('handleSidecarWrite', () => {
|
||||||
it('should skip assets that no longer exist', async () => {
|
it('should skip assets that no longer exist', async () => {
|
||||||
|
mocks.assetJob.getLockedPropertiesForMetadataExtraction.mockResolvedValue([]);
|
||||||
mocks.assetJob.getForSidecarWriteJob.mockResolvedValue(void 0);
|
mocks.assetJob.getForSidecarWriteJob.mockResolvedValue(void 0);
|
||||||
await expect(sut.handleSidecarWrite({ id: 'asset-123' })).resolves.toBe(JobStatus.Failed);
|
await expect(sut.handleSidecarWrite({ id: 'asset-123' })).resolves.toBe(JobStatus.Failed);
|
||||||
expect(mocks.metadata.writeTags).not.toHaveBeenCalled();
|
expect(mocks.metadata.writeTags).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should skip jobs with no metadata', async () => {
|
it('should skip jobs with no metadata', async () => {
|
||||||
|
mocks.assetJob.getLockedPropertiesForMetadataExtraction.mockResolvedValue([]);
|
||||||
const asset = factory.jobAssets.sidecarWrite();
|
const asset = factory.jobAssets.sidecarWrite();
|
||||||
mocks.assetJob.getForSidecarWriteJob.mockResolvedValue(asset);
|
mocks.assetJob.getForSidecarWriteJob.mockResolvedValue(asset);
|
||||||
await expect(sut.handleSidecarWrite({ id: asset.id })).resolves.toBe(JobStatus.Skipped);
|
await expect(sut.handleSidecarWrite({ id: asset.id })).resolves.toBe(JobStatus.Skipped);
|
||||||
|
|
@ -1655,20 +1686,22 @@ describe(MetadataService.name, () => {
|
||||||
const gps = 12;
|
const gps = 12;
|
||||||
const date = '2023-11-22T04:56:12.196Z';
|
const date = '2023-11-22T04:56:12.196Z';
|
||||||
|
|
||||||
|
mocks.assetJob.getLockedPropertiesForMetadataExtraction.mockResolvedValue([
|
||||||
|
'description',
|
||||||
|
'latitude',
|
||||||
|
'longitude',
|
||||||
|
'dateTimeOriginal',
|
||||||
|
]);
|
||||||
mocks.assetJob.getForSidecarWriteJob.mockResolvedValue(asset);
|
mocks.assetJob.getForSidecarWriteJob.mockResolvedValue(asset);
|
||||||
await expect(
|
await expect(
|
||||||
sut.handleSidecarWrite({
|
sut.handleSidecarWrite({
|
||||||
id: asset.id,
|
id: asset.id,
|
||||||
description,
|
|
||||||
latitude: gps,
|
|
||||||
longitude: gps,
|
|
||||||
dateTimeOriginal: date,
|
|
||||||
}),
|
}),
|
||||||
).resolves.toBe(JobStatus.Success);
|
).resolves.toBe(JobStatus.Success);
|
||||||
expect(mocks.metadata.writeTags).toHaveBeenCalledWith(asset.files[0].path, {
|
expect(mocks.metadata.writeTags).toHaveBeenCalledWith(asset.files[0].path, {
|
||||||
|
DateTimeOriginal: date,
|
||||||
Description: description,
|
Description: description,
|
||||||
ImageDescription: description,
|
ImageDescription: description,
|
||||||
DateTimeOriginal: date,
|
|
||||||
GPSLatitude: gps,
|
GPSLatitude: gps,
|
||||||
GPSLongitude: gps,
|
GPSLongitude: gps,
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -290,7 +290,7 @@ export class MetadataService extends BaseService {
|
||||||
};
|
};
|
||||||
|
|
||||||
const promises: Promise<unknown>[] = [
|
const promises: Promise<unknown>[] = [
|
||||||
this.assetRepository.upsertExif(exifData),
|
this.assetRepository.upsertExif(exifData, { lockedPropertiesBehavior: 'skip' }),
|
||||||
this.assetRepository.update({
|
this.assetRepository.update({
|
||||||
id: asset.id,
|
id: asset.id,
|
||||||
duration: this.getDuration(exifTags),
|
duration: this.getDuration(exifTags),
|
||||||
|
|
@ -393,22 +393,34 @@ export class MetadataService extends BaseService {
|
||||||
|
|
||||||
@OnJob({ name: JobName.SidecarWrite, queue: QueueName.Sidecar })
|
@OnJob({ name: JobName.SidecarWrite, queue: QueueName.Sidecar })
|
||||||
async handleSidecarWrite(job: JobOf<JobName.SidecarWrite>): Promise<JobStatus> {
|
async handleSidecarWrite(job: JobOf<JobName.SidecarWrite>): Promise<JobStatus> {
|
||||||
const { id, description, dateTimeOriginal, latitude, longitude, rating, tags } = job;
|
const { id, tags } = job;
|
||||||
const asset = await this.assetJobRepository.getForSidecarWriteJob(id);
|
const asset = await this.assetJobRepository.getForSidecarWriteJob(id);
|
||||||
if (!asset) {
|
if (!asset) {
|
||||||
return JobStatus.Failed;
|
return JobStatus.Failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const lockedProperties = await this.assetJobRepository.getLockedPropertiesForMetadataExtraction(id);
|
||||||
const tagsList = (asset.tags || []).map((tag) => tag.value);
|
const tagsList = (asset.tags || []).map((tag) => tag.value);
|
||||||
|
|
||||||
const { sidecarFile } = getAssetFiles(asset.files);
|
const { sidecarFile } = getAssetFiles(asset.files);
|
||||||
const sidecarPath = sidecarFile?.path || `${asset.originalPath}.xmp`;
|
const sidecarPath = sidecarFile?.path || `${asset.originalPath}.xmp`;
|
||||||
|
|
||||||
|
const { description, dateTimeOriginal, latitude, longitude, rating } = _.pick(
|
||||||
|
{
|
||||||
|
description: asset.exifInfo.description,
|
||||||
|
dateTimeOriginal: asset.exifInfo.dateTimeOriginal,
|
||||||
|
latitude: asset.exifInfo.latitude,
|
||||||
|
longitude: asset.exifInfo.longitude,
|
||||||
|
rating: asset.exifInfo.rating,
|
||||||
|
},
|
||||||
|
lockedProperties,
|
||||||
|
);
|
||||||
|
|
||||||
const exif = _.omitBy(
|
const exif = _.omitBy(
|
||||||
<Tags>{
|
<Tags>{
|
||||||
Description: description,
|
Description: description,
|
||||||
ImageDescription: description,
|
ImageDescription: description,
|
||||||
DateTimeOriginal: dateTimeOriginal,
|
DateTimeOriginal: dateTimeOriginal ? String(dateTimeOriginal) : undefined,
|
||||||
GPSLatitude: latitude,
|
GPSLatitude: latitude,
|
||||||
GPSLongitude: longitude,
|
GPSLongitude: longitude,
|
||||||
Rating: rating,
|
Rating: rating,
|
||||||
|
|
|
||||||
|
|
@ -222,11 +222,6 @@ export interface IDeleteFilesJob extends IBaseJob {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ISidecarWriteJob extends IEntityJob {
|
export interface ISidecarWriteJob extends IEntityJob {
|
||||||
description?: string;
|
|
||||||
dateTimeOriginal?: string;
|
|
||||||
latitude?: number;
|
|
||||||
longitude?: number;
|
|
||||||
rating?: number;
|
|
||||||
tags?: true;
|
tags?: true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ import { PostgresJSDialect } from 'kysely-postgres-js';
|
||||||
import { jsonArrayFrom, jsonObjectFrom } from 'kysely/helpers/postgres';
|
import { jsonArrayFrom, jsonObjectFrom } from 'kysely/helpers/postgres';
|
||||||
import { parse } from 'pg-connection-string';
|
import { parse } from 'pg-connection-string';
|
||||||
import postgres, { Notice, PostgresError } from 'postgres';
|
import postgres, { Notice, PostgresError } from 'postgres';
|
||||||
import { columns, Exif, Person } from 'src/database';
|
import { columns, Exif, lockableProperties, LockableProperty, Person } from 'src/database';
|
||||||
import { AssetFileType, AssetVisibility, DatabaseExtension, DatabaseSslMode } from 'src/enum';
|
import { AssetFileType, AssetVisibility, DatabaseExtension, DatabaseSslMode } from 'src/enum';
|
||||||
import { AssetSearchBuilderOptions } from 'src/repositories/search.repository';
|
import { AssetSearchBuilderOptions } from 'src/repositories/search.repository';
|
||||||
import { DB } from 'src/schema';
|
import { DB } from 'src/schema';
|
||||||
|
|
@ -488,3 +488,10 @@ export function vectorIndexQuery({ vectorExtension, table, indexName, lists }: V
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const updateLockedColumns = <T extends Record<string, unknown> & { lockedProperties?: LockableProperty[] }>(
|
||||||
|
exif: T,
|
||||||
|
) => {
|
||||||
|
exif.lockedProperties = lockableProperties.filter((property) => property in exif);
|
||||||
|
return exif;
|
||||||
|
};
|
||||||
|
|
|
||||||
|
|
@ -202,7 +202,7 @@ export class MediumTestContext<S extends BaseService = BaseService> {
|
||||||
}
|
}
|
||||||
|
|
||||||
async newExif(dto: Insertable<AssetExifTable>) {
|
async newExif(dto: Insertable<AssetExifTable>) {
|
||||||
const result = await this.get(AssetRepository).upsertExif(dto);
|
const result = await this.get(AssetRepository).upsertExif(dto, { lockedPropertiesBehavior: 'override' });
|
||||||
return { result };
|
return { result };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -268,4 +268,65 @@ describe(AssetService.name, () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('update', () => {
|
||||||
|
it('should update dateTimeOriginal', async () => {
|
||||||
|
const { sut, ctx } = setup();
|
||||||
|
ctx.getMock(JobRepository).queue.mockResolvedValue();
|
||||||
|
const { user } = await ctx.newUser();
|
||||||
|
const auth = factory.auth({ user });
|
||||||
|
const { asset } = await ctx.newAsset({ ownerId: user.id });
|
||||||
|
await ctx.newExif({ assetId: asset.id, description: 'test' });
|
||||||
|
|
||||||
|
await expect(
|
||||||
|
ctx.database
|
||||||
|
.selectFrom('asset_exif')
|
||||||
|
.select('lockedProperties')
|
||||||
|
.where('assetId', '=', asset.id)
|
||||||
|
.executeTakeFirstOrThrow(),
|
||||||
|
).resolves.toEqual({ lockedProperties: null });
|
||||||
|
await sut.update(auth, asset.id, { dateTimeOriginal: '2023-11-19T18:11:00.000-07:00' });
|
||||||
|
|
||||||
|
await expect(
|
||||||
|
ctx.database
|
||||||
|
.selectFrom('asset_exif')
|
||||||
|
.select('lockedProperties')
|
||||||
|
.where('assetId', '=', asset.id)
|
||||||
|
.executeTakeFirstOrThrow(),
|
||||||
|
).resolves.toEqual({ lockedProperties: ['dateTimeOriginal'] });
|
||||||
|
await expect(ctx.get(AssetRepository).getById(asset.id, { exifInfo: true })).resolves.toEqual(
|
||||||
|
expect.objectContaining({
|
||||||
|
exifInfo: expect.objectContaining({ dateTimeOriginal: '2023-11-20T01:11:00+00:00' }),
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('updateAll', () => {
|
||||||
|
it('should relatively update assets', async () => {
|
||||||
|
const { sut, ctx } = setup();
|
||||||
|
ctx.getMock(JobRepository).queueAll.mockResolvedValue();
|
||||||
|
const { user } = await ctx.newUser();
|
||||||
|
const auth = factory.auth({ user });
|
||||||
|
const { asset } = await ctx.newAsset({ ownerId: user.id });
|
||||||
|
await ctx.newExif({ assetId: asset.id, dateTimeOriginal: '2023-11-19T18:11:00' });
|
||||||
|
|
||||||
|
await sut.updateAll(auth, { ids: [asset.id], dateTimeRelative: -11 });
|
||||||
|
|
||||||
|
await expect(
|
||||||
|
ctx.database
|
||||||
|
.selectFrom('asset_exif')
|
||||||
|
.select('lockedProperties')
|
||||||
|
.where('assetId', '=', asset.id)
|
||||||
|
.executeTakeFirstOrThrow(),
|
||||||
|
).resolves.toEqual({ lockedProperties: ['timeZone', 'dateTimeOriginal'] });
|
||||||
|
await expect(ctx.get(AssetRepository).getById(asset.id, { exifInfo: true })).resolves.toEqual(
|
||||||
|
expect.objectContaining({
|
||||||
|
exifInfo: expect.objectContaining({
|
||||||
|
dateTimeOriginal: '2023-11-19T18:00:00+00:00',
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -95,6 +95,7 @@ describe(MetadataService.name, () => {
|
||||||
dateTimeOriginal: new Date(expected.dateTimeOriginal),
|
dateTimeOriginal: new Date(expected.dateTimeOriginal),
|
||||||
timeZone: expected.timeZone,
|
timeZone: expected.timeZone,
|
||||||
}),
|
}),
|
||||||
|
{ lockedPropertiesBehavior: 'skip' },
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(mocks.asset.update).toHaveBeenCalledWith(
|
expect(mocks.asset.update).toHaveBeenCalledWith(
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ import { Kysely } from 'kysely';
|
||||||
import { AlbumUserRole, SyncEntityType, SyncRequestType } from 'src/enum';
|
import { AlbumUserRole, SyncEntityType, SyncRequestType } from 'src/enum';
|
||||||
import { AssetRepository } from 'src/repositories/asset.repository';
|
import { AssetRepository } from 'src/repositories/asset.repository';
|
||||||
import { DB } from 'src/schema';
|
import { DB } from 'src/schema';
|
||||||
|
import { updateLockedColumns } from 'src/utils/database';
|
||||||
import { SyncTestContext } from 'test/medium.factory';
|
import { SyncTestContext } from 'test/medium.factory';
|
||||||
import { factory } from 'test/small.factory';
|
import { factory } from 'test/small.factory';
|
||||||
import { getKyselyDB, wait } from 'test/utils';
|
import { getKyselyDB, wait } from 'test/utils';
|
||||||
|
|
@ -288,10 +289,13 @@ describe(SyncRequestType.AlbumAssetExifsV1, () => {
|
||||||
|
|
||||||
// update the asset
|
// update the asset
|
||||||
const assetRepository = ctx.get(AssetRepository);
|
const assetRepository = ctx.get(AssetRepository);
|
||||||
await assetRepository.upsertExif({
|
await assetRepository.upsertExif(
|
||||||
assetId: asset.id,
|
updateLockedColumns({
|
||||||
city: 'New City',
|
assetId: asset.id,
|
||||||
});
|
city: 'New City',
|
||||||
|
}),
|
||||||
|
{ lockedPropertiesBehavior: 'append' },
|
||||||
|
);
|
||||||
|
|
||||||
await expect(ctx.syncStream(auth, [SyncRequestType.AlbumAssetExifsV1])).resolves.toEqual([
|
await expect(ctx.syncStream(auth, [SyncRequestType.AlbumAssetExifsV1])).resolves.toEqual([
|
||||||
{
|
{
|
||||||
|
|
@ -346,10 +350,13 @@ describe(SyncRequestType.AlbumAssetExifsV1, () => {
|
||||||
|
|
||||||
// update the asset
|
// update the asset
|
||||||
const assetRepository = ctx.get(AssetRepository);
|
const assetRepository = ctx.get(AssetRepository);
|
||||||
await assetRepository.upsertExif({
|
await assetRepository.upsertExif(
|
||||||
assetId: assetDelayedExif.id,
|
updateLockedColumns({
|
||||||
city: 'Delayed Exif',
|
assetId: assetDelayedExif.id,
|
||||||
});
|
city: 'Delayed Exif',
|
||||||
|
}),
|
||||||
|
{ lockedPropertiesBehavior: 'append' },
|
||||||
|
);
|
||||||
|
|
||||||
await expect(ctx.syncStream(auth, [SyncRequestType.AlbumAssetExifsV1])).resolves.toEqual([
|
await expect(ctx.syncStream(auth, [SyncRequestType.AlbumAssetExifsV1])).resolves.toEqual([
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import {
|
||||||
AuthApiKey,
|
AuthApiKey,
|
||||||
AuthSharedLink,
|
AuthSharedLink,
|
||||||
AuthUser,
|
AuthUser,
|
||||||
|
Exif,
|
||||||
Library,
|
Library,
|
||||||
Memory,
|
Memory,
|
||||||
Partner,
|
Partner,
|
||||||
|
|
@ -319,18 +320,28 @@ const versionHistoryFactory = () => ({
|
||||||
version: '1.123.45',
|
version: '1.123.45',
|
||||||
});
|
});
|
||||||
|
|
||||||
const assetSidecarWriteFactory = () => ({
|
const assetSidecarWriteFactory = () => {
|
||||||
id: newUuid(),
|
const id = newUuid();
|
||||||
originalPath: '/path/to/original-path.jpg.xmp',
|
return {
|
||||||
tags: [],
|
id,
|
||||||
files: [
|
originalPath: '/path/to/original-path.jpg.xmp',
|
||||||
{
|
tags: [],
|
||||||
id: newUuid(),
|
files: [
|
||||||
path: '/path/to/original-path.jpg.xmp',
|
{
|
||||||
type: AssetFileType.Sidecar,
|
id: newUuid(),
|
||||||
},
|
path: '/path/to/original-path.jpg.xmp',
|
||||||
],
|
type: AssetFileType.Sidecar,
|
||||||
});
|
},
|
||||||
|
],
|
||||||
|
exifInfo: {
|
||||||
|
assetId: id,
|
||||||
|
description: 'this is a description',
|
||||||
|
latitude: 12,
|
||||||
|
longitude: 12,
|
||||||
|
dateTimeOriginal: '2023-11-22T04:56:12.196Z',
|
||||||
|
} as unknown as Exif,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
const assetOcrFactory = (
|
const assetOcrFactory = (
|
||||||
ocr: {
|
ocr: {
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,8 @@
|
||||||
import { AssetInteraction } from '$lib/stores/asset-interaction.svelte';
|
import { AssetInteraction } from '$lib/stores/asset-interaction.svelte';
|
||||||
import { assetViewingStore } from '$lib/stores/asset-viewing.store';
|
import { assetViewingStore } from '$lib/stores/asset-viewing.store';
|
||||||
import { dragAndDropFilesStore } from '$lib/stores/drag-and-drop-files.store';
|
import { dragAndDropFilesStore } from '$lib/stores/drag-and-drop-files.store';
|
||||||
|
import { mobileDevice } from '$lib/stores/mobile-device.svelte';
|
||||||
|
import { SlideshowNavigation, SlideshowState, slideshowStore } from '$lib/stores/slideshow.store';
|
||||||
import { handlePromiseError } from '$lib/utils';
|
import { handlePromiseError } from '$lib/utils';
|
||||||
import { cancelMultiselect } from '$lib/utils/asset-utils';
|
import { cancelMultiselect } from '$lib/utils/asset-utils';
|
||||||
import { fileUploadHandler, openFileUploadDialog } from '$lib/utils/file-uploader';
|
import { fileUploadHandler, openFileUploadDialog } from '$lib/utils/file-uploader';
|
||||||
|
|
@ -22,7 +24,6 @@
|
||||||
import ControlAppBar from '../shared-components/control-app-bar.svelte';
|
import ControlAppBar from '../shared-components/control-app-bar.svelte';
|
||||||
import ThemeButton from '../shared-components/theme-button.svelte';
|
import ThemeButton from '../shared-components/theme-button.svelte';
|
||||||
import AlbumSummary from './album-summary.svelte';
|
import AlbumSummary from './album-summary.svelte';
|
||||||
import { SlideshowNavigation, SlideshowState, slideshowStore } from '$lib/stores/slideshow.store';
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
sharedLink: SharedLinkResponseDto;
|
sharedLink: SharedLinkResponseDto;
|
||||||
|
|
@ -110,7 +111,7 @@
|
||||||
<ControlAppBar showBackButton={false}>
|
<ControlAppBar showBackButton={false}>
|
||||||
{#snippet leading()}
|
{#snippet leading()}
|
||||||
<a data-sveltekit-preload-data="hover" class="ms-4" href="/">
|
<a data-sveltekit-preload-data="hover" class="ms-4" href="/">
|
||||||
<Logo variant="inline" class="min-w-min" />
|
<Logo variant={mobileDevice.maxMd ? 'icon' : 'inline'} class="min-w-10" />
|
||||||
</a>
|
</a>
|
||||||
{/snippet}
|
{/snippet}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
import { locale } from '$lib/stores/preferences.store';
|
import { locale } from '$lib/stores/preferences.store';
|
||||||
import type { ActivityResponseDto } from '@immich/sdk';
|
import type { ActivityResponseDto } from '@immich/sdk';
|
||||||
import { Icon } from '@immich/ui';
|
import { Icon } from '@immich/ui';
|
||||||
import { mdiCommentOutline, mdiHeart, mdiHeartOutline } from '@mdi/js';
|
import { mdiCommentOutline, mdiThumbUp, mdiThumbUpOutline } from '@mdi/js';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
isLiked: ActivityResponseDto | null;
|
isLiked: ActivityResponseDto | null;
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
<div class="w-full flex p-4 items-center justify-center rounded-full gap-5 bg-subtle border bg-opacity-60">
|
<div class="w-full flex p-4 items-center justify-center rounded-full gap-5 bg-subtle border bg-opacity-60">
|
||||||
<button type="button" class={disabled ? 'cursor-not-allowed' : ''} onclick={onFavorite} {disabled}>
|
<button type="button" class={disabled ? 'cursor-not-allowed' : ''} onclick={onFavorite} {disabled}>
|
||||||
<div class="flex gap-2 items-center justify-center">
|
<div class="flex gap-2 items-center justify-center">
|
||||||
<Icon icon={isLiked ? mdiHeart : mdiHeartOutline} size="24" class={isLiked ? 'text-red-400' : 'text-fg'} />
|
<Icon icon={isLiked ? mdiThumbUp : mdiThumbUpOutline} size="24" class={isLiked ? 'text-primary' : 'text-fg'} />
|
||||||
{#if numberOfLikes}
|
{#if numberOfLikes}
|
||||||
<div class="text-l">{numberOfLikes.toLocaleString($locale)}</div>
|
<div class="text-l">{numberOfLikes.toLocaleString($locale)}</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
import { isTenMinutesApart } from '$lib/utils/timesince';
|
import { isTenMinutesApart } from '$lib/utils/timesince';
|
||||||
import { ReactionType, type ActivityResponseDto, type AssetTypeEnum, type UserResponseDto } from '@immich/sdk';
|
import { ReactionType, type ActivityResponseDto, type AssetTypeEnum, type UserResponseDto } from '@immich/sdk';
|
||||||
import { Icon, IconButton, LoadingSpinner, toastManager } from '@immich/ui';
|
import { Icon, IconButton, LoadingSpinner, toastManager } from '@immich/ui';
|
||||||
import { mdiClose, mdiDeleteOutline, mdiDotsVertical, mdiHeart, mdiSend } from '@mdi/js';
|
import { mdiClose, mdiDeleteOutline, mdiDotsVertical, mdiSend, mdiThumbUp } from '@mdi/js';
|
||||||
import * as luxon from 'luxon';
|
import * as luxon from 'luxon';
|
||||||
import { t } from 'svelte-i18n';
|
import { t } from 'svelte-i18n';
|
||||||
import UserAvatar from '../shared-components/user-avatar.svelte';
|
import UserAvatar from '../shared-components/user-avatar.svelte';
|
||||||
|
|
@ -181,7 +181,7 @@
|
||||||
{:else if reaction.type === ReactionType.Like}
|
{:else if reaction.type === ReactionType.Like}
|
||||||
<div class="relative">
|
<div class="relative">
|
||||||
<div class="flex py-3 ps-3 mt-3 gap-4 items-center text-sm">
|
<div class="flex py-3 ps-3 mt-3 gap-4 items-center text-sm">
|
||||||
<div class="text-red-600"><Icon icon={mdiHeart} size="20" /></div>
|
<div class="text-primary"><Icon icon={mdiThumbUp} size="20" /></div>
|
||||||
|
|
||||||
<div class="w-full" title={`${reaction.user.name} (${reaction.user.email})`}>
|
<div class="w-full" title={`${reaction.user.name} (${reaction.user.email})`}>
|
||||||
{$t('user_liked', {
|
{$t('user_liked', {
|
||||||
|
|
@ -254,7 +254,7 @@
|
||||||
shortcut: { key: 'Enter' },
|
shortcut: { key: 'Enter' },
|
||||||
onShortcut: () => handleSendComment(),
|
onShortcut: () => handleSendComment(),
|
||||||
}}
|
}}
|
||||||
class="h-[18px] {disabled
|
class="h-4.5 {disabled
|
||||||
? 'cursor-not-allowed'
|
? 'cursor-not-allowed'
|
||||||
: ''} w-full max-h-56 pe-2 items-center overflow-y-auto leading-4 outline-none resize-none bg-gray-200"
|
: ''} w-full max-h-56 pe-2 items-center overflow-y-auto leading-4 outline-none resize-none bg-gray-200"
|
||||||
></textarea>
|
></textarea>
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@
|
||||||
import type { Viewport } from '$lib/managers/timeline-manager/types';
|
import type { Viewport } from '$lib/managers/timeline-manager/types';
|
||||||
import { AssetInteraction } from '$lib/stores/asset-interaction.svelte';
|
import { AssetInteraction } from '$lib/stores/asset-interaction.svelte';
|
||||||
import { dragAndDropFilesStore } from '$lib/stores/drag-and-drop-files.store';
|
import { dragAndDropFilesStore } from '$lib/stores/drag-and-drop-files.store';
|
||||||
|
import { mobileDevice } from '$lib/stores/mobile-device.svelte';
|
||||||
import { handlePromiseError } from '$lib/utils';
|
import { handlePromiseError } from '$lib/utils';
|
||||||
import { cancelMultiselect, downloadArchive } from '$lib/utils/asset-utils';
|
import { cancelMultiselect, downloadArchive } from '$lib/utils/asset-utils';
|
||||||
import { fileUploadHandler, openFileUploadDialog } from '$lib/utils/file-uploader';
|
import { fileUploadHandler, openFileUploadDialog } from '$lib/utils/file-uploader';
|
||||||
|
|
@ -108,7 +109,7 @@
|
||||||
<ControlAppBar onClose={() => goto(AppRoute.PHOTOS)} backIcon={mdiArrowLeft} showBackButton={false}>
|
<ControlAppBar onClose={() => goto(AppRoute.PHOTOS)} backIcon={mdiArrowLeft} showBackButton={false}>
|
||||||
{#snippet leading()}
|
{#snippet leading()}
|
||||||
<a data-sveltekit-preload-data="hover" class="ms-4" href="/">
|
<a data-sveltekit-preload-data="hover" class="ms-4" href="/">
|
||||||
<Logo variant="inline" />
|
<Logo variant={mobileDevice.maxMd ? 'icon' : 'inline'} class="min-w-10" />
|
||||||
</a>
|
</a>
|
||||||
{/snippet}
|
{/snippet}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
import { getSharedLinkActions } from '$lib/services/shared-link.service';
|
import { getSharedLinkActions } from '$lib/services/shared-link.service';
|
||||||
import { locale } from '$lib/stores/preferences.store';
|
import { locale } from '$lib/stores/preferences.store';
|
||||||
import { SharedLinkType, type SharedLinkResponseDto } from '@immich/sdk';
|
import { SharedLinkType, type SharedLinkResponseDto } from '@immich/sdk';
|
||||||
import { Badge, ContextMenuButton, MenuItemType, Text } from '@immich/ui';
|
import { ContextMenuButton, MenuItemType, Text } from '@immich/ui';
|
||||||
import { DateTime, type ToRelativeUnit } from 'luxon';
|
import { DateTime, type ToRelativeUnit } from 'luxon';
|
||||||
import { t } from 'svelte-i18n';
|
import { t } from 'svelte-i18n';
|
||||||
|
|
||||||
|
|
@ -32,6 +32,28 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
const { Edit, Copy, Delete } = $derived(getSharedLinkActions($t, sharedLink));
|
const { Edit, Copy, Delete } = $derived(getSharedLinkActions($t, sharedLink));
|
||||||
|
|
||||||
|
const capabilities = $derived.by(() => {
|
||||||
|
const items = [];
|
||||||
|
|
||||||
|
if (sharedLink.allowUpload) {
|
||||||
|
items.push($t('upload'));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sharedLink.allowDownload) {
|
||||||
|
items.push($t('download'));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sharedLink.showMetadata) {
|
||||||
|
items.push($t('exif'));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sharedLink.password) {
|
||||||
|
items.push($t('password'));
|
||||||
|
}
|
||||||
|
|
||||||
|
return items;
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
|
|
@ -44,50 +66,41 @@
|
||||||
>
|
>
|
||||||
<ShareCover class="transition-all duration-300 hover:shadow-lg" {sharedLink} />
|
<ShareCover class="transition-all duration-300 hover:shadow-lg" {sharedLink} />
|
||||||
|
|
||||||
<div class="flex flex-col gap-2">
|
<div class="flex flex-col gap-4 justify-between">
|
||||||
<Text size="large" color="primary" class="flex place-items-center gap-2 break-all">
|
<div class="flex flex-col">
|
||||||
{#if sharedLink.type === SharedLinkType.Album}
|
<Text size="tiny" color={isExpired ? 'danger' : 'muted'} class="font-medium">
|
||||||
{sharedLink.album?.albumName}
|
{#if isExpired}
|
||||||
{:else if sharedLink.type === SharedLinkType.Individual}
|
{$t('expired')}
|
||||||
{$t('individual_share')}
|
{:else if expiresAt}
|
||||||
{/if}
|
|
||||||
</Text>
|
|
||||||
|
|
||||||
<div class="flex flex-wrap gap-1">
|
|
||||||
{#if isExpired}
|
|
||||||
<Badge size="small" color="danger">{$t('expired')}</Badge>
|
|
||||||
{:else if expiresAt}
|
|
||||||
<Badge size="small" color="secondary">
|
|
||||||
{$t('expires_date', { values: { date: getCountDownExpirationDate(expiresAt, now) } })}
|
{$t('expires_date', { values: { date: getCountDownExpirationDate(expiresAt, now) } })}
|
||||||
</Badge>
|
{:else}
|
||||||
{:else}
|
{$t('expires_date', { values: { date: '∞' } })}
|
||||||
<Badge size="small" color="secondary">{$t('expires_date', { values: { date: '∞' } })}</Badge>
|
{/if}
|
||||||
{/if}
|
</Text>
|
||||||
|
|
||||||
{#if sharedLink.slug}
|
<Text size="large" color="primary" class="flex place-items-center gap-2 break-all font-medium">
|
||||||
<Badge size="small" color="secondary">{$t('custom_url')}</Badge>
|
{#if sharedLink.type === SharedLinkType.Album}
|
||||||
{/if}
|
{sharedLink.album?.albumName}
|
||||||
|
{:else if sharedLink.type === SharedLinkType.Individual}
|
||||||
|
{$t('individual_share')}
|
||||||
|
{/if}
|
||||||
|
</Text>
|
||||||
|
|
||||||
{#if sharedLink.allowUpload}
|
{#if sharedLink.description}
|
||||||
<Badge size="small" color="secondary">{$t('upload')}</Badge>
|
<Text size="small" class="line-clamp-1">{sharedLink.description}</Text>
|
||||||
{/if}
|
|
||||||
|
|
||||||
{#if sharedLink.showMetadata && sharedLink.allowDownload}
|
|
||||||
<Badge size="small" color="secondary">{$t('download')}</Badge>
|
|
||||||
{/if}
|
|
||||||
|
|
||||||
{#if sharedLink.showMetadata}
|
|
||||||
<Badge size="small" color="secondary">{$t('exif')}</Badge>
|
|
||||||
{/if}
|
|
||||||
|
|
||||||
{#if sharedLink.password}
|
|
||||||
<Badge size="small" color="secondary">{$t('password')}</Badge>
|
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{#if sharedLink.description}
|
<div class="flex flex-wrap items-center gap-2">
|
||||||
<Text size="small" class="line-clamp-1">{sharedLink.description}</Text>
|
{#each capabilities as capability, index (index)}
|
||||||
{/if}
|
<Text size="small" color="primary" class="font-medium">
|
||||||
|
{capability}
|
||||||
|
</Text>
|
||||||
|
{#if index < capabilities.length - 1}
|
||||||
|
<Text size="small" color="muted">•</Text>
|
||||||
|
{/if}
|
||||||
|
{/each}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</svelte:element>
|
</svelte:element>
|
||||||
<div class="flex flex-auto flex-col place-content-center place-items-end text-end ms-4">
|
<div class="flex flex-auto flex-col place-content-center place-items-end text-end ms-4">
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
import { page } from '$app/state';
|
import { page } from '$app/state';
|
||||||
import UserPageLayout from '$lib/components/layouts/user-page-layout.svelte';
|
import UserPageLayout from '$lib/components/layouts/user-page-layout.svelte';
|
||||||
import OnEvents from '$lib/components/OnEvents.svelte';
|
import OnEvents from '$lib/components/OnEvents.svelte';
|
||||||
import SharedLinkCard from '$lib/components/sharedlinks-page/shared-link-card.svelte';
|
import SharedLinkCard from '$lib/components/sharedlinks-page/SharedLinkCard.svelte';
|
||||||
import { AppRoute } from '$lib/constants';
|
import { AppRoute } from '$lib/constants';
|
||||||
import GroupTab from '$lib/elements/GroupTab.svelte';
|
import GroupTab from '$lib/elements/GroupTab.svelte';
|
||||||
import SharedLinkUpdateModal from '$lib/modals/SharedLinkUpdateModal.svelte';
|
import SharedLinkUpdateModal from '$lib/modals/SharedLinkUpdateModal.svelte';
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue