mirror of
https://github.com/immich-app/immich.git
synced 2025-12-18 01:11:07 +03:00
Compare commits
13 Commits
feat/disab
...
feature/bo
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ebed026d5a | ||
|
|
c15998e805 | ||
|
|
e966ee5544 | ||
|
|
de36f9a215 | ||
|
|
8ceb68e240 | ||
|
|
75734b45a0 | ||
|
|
a9bee498c4 | ||
|
|
6b4cc4e65e | ||
|
|
e49239e7e9 | ||
|
|
939c222728 | ||
|
|
c38ecab1a6 | ||
|
|
76fd68957c | ||
|
|
7d4de5f2e2 |
@@ -7,3 +7,5 @@ enum AssetVisibilityEnum { timeline, hidden, archive, locked }
|
||||
enum SortUserBy { id }
|
||||
|
||||
enum ActionSource { timeline, viewer }
|
||||
|
||||
enum ButtonPosition { bottomBar, kebabMenu, other }
|
||||
|
||||
@@ -8,7 +8,10 @@ import 'package:immich_mobile/providers/infrastructure/asset_viewer/current_asse
|
||||
import 'package:immich_mobile/routing/router.dart';
|
||||
|
||||
class EditImageActionButton extends ConsumerWidget {
|
||||
const EditImageActionButton({super.key});
|
||||
final bool iconOnly;
|
||||
final bool menuItem;
|
||||
|
||||
const EditImageActionButton({super.key, this.iconOnly = false, this.menuItem = false});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
@@ -27,6 +30,8 @@ class EditImageActionButton extends ConsumerWidget {
|
||||
iconData: Icons.tune,
|
||||
label: "edit".t(context: context),
|
||||
onPressed: onPress,
|
||||
iconOnly: iconOnly,
|
||||
menuItem: menuItem,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:immich_mobile/domain/models/events.model.dart';
|
||||
import 'package:immich_mobile/domain/utils/event_stream.dart';
|
||||
import 'package:immich_mobile/extensions/translate_extensions.dart';
|
||||
import 'package:immich_mobile/presentation/widgets/action_buttons/base_action_button.widget.dart';
|
||||
|
||||
class OpenActivityActionButton extends ConsumerWidget {
|
||||
const OpenActivityActionButton({super.key, this.iconOnly = false, this.menuItem = false});
|
||||
|
||||
final bool iconOnly;
|
||||
final bool menuItem;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
return BaseActionButton(
|
||||
iconData: Icons.chat_outlined,
|
||||
label: "activity".t(context: context),
|
||||
onPressed: () => EventStream.shared.emit(const ViewerOpenBottomSheetEvent(activitiesMode: true)),
|
||||
iconOnly: iconOnly,
|
||||
menuItem: menuItem,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -2,18 +2,18 @@ import 'package:flutter/material.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:immich_mobile/constants/enums.dart';
|
||||
import 'package:immich_mobile/domain/models/asset/base_asset.model.dart';
|
||||
import 'package:immich_mobile/domain/models/setting.model.dart';
|
||||
import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
||||
import 'package:immich_mobile/presentation/widgets/action_buttons/delete_action_button.widget.dart';
|
||||
import 'package:immich_mobile/presentation/widgets/action_buttons/delete_local_action_button.widget.dart';
|
||||
import 'package:immich_mobile/presentation/widgets/action_buttons/edit_image_action_button.widget.dart';
|
||||
import 'package:immich_mobile/presentation/widgets/action_buttons/share_action_button.widget.dart';
|
||||
import 'package:immich_mobile/presentation/widgets/action_buttons/upload_action_button.widget.dart';
|
||||
import 'package:immich_mobile/presentation/widgets/action_buttons/add_action_button.widget.dart';
|
||||
import 'package:immich_mobile/presentation/widgets/asset_viewer/asset_viewer.state.dart';
|
||||
import 'package:immich_mobile/providers/infrastructure/asset_viewer/current_asset.provider.dart';
|
||||
import 'package:immich_mobile/providers/infrastructure/current_album.provider.dart';
|
||||
import 'package:immich_mobile/providers/infrastructure/readonly_mode.provider.dart';
|
||||
import 'package:immich_mobile/providers/infrastructure/setting.provider.dart';
|
||||
import 'package:immich_mobile/providers/infrastructure/timeline.provider.dart';
|
||||
import 'package:immich_mobile/providers/routes.provider.dart';
|
||||
import 'package:immich_mobile/providers/server_info.provider.dart';
|
||||
import 'package:immich_mobile/providers/user.provider.dart';
|
||||
import 'package:immich_mobile/utils/action_button.utils.dart';
|
||||
import 'package:immich_mobile/widgets/asset_viewer/video_controls.dart';
|
||||
|
||||
class ViewerBottomBar extends ConsumerWidget {
|
||||
@@ -33,6 +33,11 @@ class ViewerBottomBar extends ConsumerWidget {
|
||||
int opacity = ref.watch(assetViewerProvider.select((state) => state.backgroundOpacity));
|
||||
final showControls = ref.watch(assetViewerProvider.select((s) => s.showingControls));
|
||||
final isInLockedView = ref.watch(inLockedViewProvider);
|
||||
final album = ref.watch(currentRemoteAlbumProvider);
|
||||
final isArchived = asset is RemoteAsset && asset.visibility == AssetVisibility.archive;
|
||||
final advancedTroubleshooting = ref.watch(settingsProvider.notifier).get(Setting.advancedTroubleshooting);
|
||||
final timelineOrigin = ref.read(timelineServiceProvider).origin;
|
||||
final isTrashEnable = ref.watch(serverInfoProvider.select((state) => state.serverFeatures.trash));
|
||||
|
||||
if (!showControls) {
|
||||
opacity = 0;
|
||||
@@ -40,21 +45,22 @@ class ViewerBottomBar extends ConsumerWidget {
|
||||
|
||||
final originalTheme = context.themeData;
|
||||
|
||||
final actions = <Widget>[
|
||||
const ShareActionButton(source: ActionSource.viewer),
|
||||
final buttonContext = ActionButtonContext(
|
||||
asset: asset,
|
||||
isOwner: isOwner,
|
||||
isArchived: isArchived,
|
||||
isTrashEnabled: isTrashEnable,
|
||||
isStacked: asset is RemoteAsset && asset.stackId != null,
|
||||
isInLockedView: isInLockedView,
|
||||
currentAlbum: album,
|
||||
advancedTroubleshooting: advancedTroubleshooting,
|
||||
source: ActionSource.viewer,
|
||||
timelineOrigin: timelineOrigin,
|
||||
originalTheme: originalTheme,
|
||||
buttonPosition: ButtonPosition.bottomBar,
|
||||
);
|
||||
|
||||
if (!isInLockedView) ...[
|
||||
if (asset.isLocalOnly) const UploadActionButton(source: ActionSource.viewer),
|
||||
if (asset.type == AssetType.image) const EditImageActionButton(),
|
||||
if (asset.hasRemote) AddActionButton(originalTheme: originalTheme),
|
||||
|
||||
if (isOwner) ...[
|
||||
asset.isLocalOnly
|
||||
? const DeleteLocalActionButton(source: ActionSource.viewer)
|
||||
: const DeleteActionButton(source: ActionSource.viewer, showConfirmation: true),
|
||||
],
|
||||
],
|
||||
];
|
||||
final actions = ActionButtonBuilder.buildViewerBottomBar(buttonContext, context, ref);
|
||||
|
||||
return IgnorePointer(
|
||||
ignoring: opacity < 255,
|
||||
@@ -80,7 +86,11 @@ class ViewerBottomBar extends ConsumerWidget {
|
||||
children: [
|
||||
if (asset.isVideo) const VideoControls(),
|
||||
if (!isReadonlyModeEnabled)
|
||||
Row(mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: actions),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: actions.map((action) => Expanded(child: action)).toList(),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -3,8 +3,6 @@ import 'package:flutter/material.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:immich_mobile/constants/enums.dart';
|
||||
import 'package:immich_mobile/domain/models/asset/base_asset.model.dart';
|
||||
import 'package:immich_mobile/domain/models/events.model.dart';
|
||||
import 'package:immich_mobile/domain/utils/event_stream.dart';
|
||||
import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
||||
import 'package:immich_mobile/presentation/widgets/action_buttons/favorite_action_button.widget.dart';
|
||||
import 'package:immich_mobile/presentation/widgets/action_buttons/motion_photo_action_button.widget.dart';
|
||||
@@ -51,13 +49,6 @@ class ViewerTopAppBar extends ConsumerWidget implements PreferredSizeWidget {
|
||||
|
||||
final actions = <Widget>[
|
||||
if (asset.isMotionPhoto) const MotionPhotoActionButton(iconOnly: true),
|
||||
if (album != null && album.isActivityEnabled && album.isShared)
|
||||
IconButton(
|
||||
icon: const Icon(Icons.chat_outlined),
|
||||
onPressed: () {
|
||||
EventStream.shared.emit(const ViewerOpenBottomSheetEvent(activitiesMode: true));
|
||||
},
|
||||
),
|
||||
|
||||
if (asset.hasRemote && isOwner && !asset.isFavorite)
|
||||
const FavoriteActionButton(source: ActionSource.viewer, iconOnly: true),
|
||||
|
||||
@@ -17,6 +17,7 @@ import 'package:immich_mobile/presentation/widgets/action_buttons/delete_local_a
|
||||
import 'package:immich_mobile/presentation/widgets/action_buttons/delete_permanent_action_button.widget.dart';
|
||||
import 'package:immich_mobile/presentation/widgets/action_buttons/download_action_button.widget.dart';
|
||||
import 'package:immich_mobile/presentation/widgets/action_buttons/like_activity_action_button.widget.dart';
|
||||
import 'package:immich_mobile/presentation/widgets/action_buttons/open_activity_action_button.widget.dart';
|
||||
import 'package:immich_mobile/presentation/widgets/action_buttons/move_to_lock_folder_action_button.widget.dart';
|
||||
import 'package:immich_mobile/presentation/widgets/action_buttons/remove_from_album_action_button.widget.dart';
|
||||
import 'package:immich_mobile/presentation/widgets/action_buttons/remove_from_lock_folder_action_button.widget.dart';
|
||||
@@ -27,6 +28,8 @@ import 'package:immich_mobile/presentation/widgets/action_buttons/trash_action_b
|
||||
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/upload_action_button.widget.dart';
|
||||
import 'package:immich_mobile/presentation/widgets/action_buttons/edit_image_action_button.widget.dart';
|
||||
import 'package:immich_mobile/presentation/widgets/action_buttons/add_action_button.widget.dart';
|
||||
import 'package:immich_mobile/routing/router.dart';
|
||||
|
||||
class ActionButtonContext {
|
||||
@@ -42,6 +45,7 @@ class ActionButtonContext {
|
||||
final bool isCasting;
|
||||
final TimelineOrigin timelineOrigin;
|
||||
final ThemeData? originalTheme;
|
||||
final ButtonPosition buttonPosition;
|
||||
|
||||
const ActionButtonContext({
|
||||
required this.asset,
|
||||
@@ -56,13 +60,34 @@ class ActionButtonContext {
|
||||
this.isCasting = false,
|
||||
this.timelineOrigin = TimelineOrigin.main,
|
||||
this.originalTheme,
|
||||
this.buttonPosition = ButtonPosition.other,
|
||||
});
|
||||
|
||||
ActionButtonContext withButtonPosition(ButtonPosition position) {
|
||||
return ActionButtonContext(
|
||||
asset: asset,
|
||||
isOwner: isOwner,
|
||||
isArchived: isArchived,
|
||||
isTrashEnabled: isTrashEnabled,
|
||||
isStacked: isStacked,
|
||||
isInLockedView: isInLockedView,
|
||||
currentAlbum: currentAlbum,
|
||||
advancedTroubleshooting: advancedTroubleshooting,
|
||||
source: source,
|
||||
isCasting: isCasting,
|
||||
timelineOrigin: timelineOrigin,
|
||||
originalTheme: originalTheme,
|
||||
buttonPosition: position,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
enum ActionButtonType {
|
||||
openInfo,
|
||||
openActivity,
|
||||
likeActivity,
|
||||
share,
|
||||
editImage,
|
||||
shareLink,
|
||||
cast,
|
||||
similarPhotos,
|
||||
@@ -79,6 +104,7 @@ enum ActionButtonType {
|
||||
deleteLocal,
|
||||
deletePermanent,
|
||||
delete,
|
||||
addTo,
|
||||
advancedInfo;
|
||||
|
||||
bool shouldShow(ActionButtonContext context) {
|
||||
@@ -156,10 +182,22 @@ enum ActionButtonType {
|
||||
context.timelineOrigin != TimelineOrigin.localAlbum &&
|
||||
context.isOwner,
|
||||
ActionButtonType.cast => context.isCasting || context.asset.hasRemote,
|
||||
ActionButtonType.editImage =>
|
||||
!context.isInLockedView && //
|
||||
context.asset.type == AssetType.image &&
|
||||
!(context.buttonPosition == ButtonPosition.bottomBar && context.currentAlbum?.isShared == true),
|
||||
ActionButtonType.addTo =>
|
||||
!context.isInLockedView && //
|
||||
context.asset.hasRemote,
|
||||
ActionButtonType.openActivity =>
|
||||
!context.isInLockedView &&
|
||||
context.currentAlbum != null &&
|
||||
context.currentAlbum!.isActivityEnabled &&
|
||||
context.currentAlbum!.isShared,
|
||||
};
|
||||
}
|
||||
|
||||
ConsumerWidget buildButton(
|
||||
Widget buildButton(
|
||||
ActionButtonContext context, [
|
||||
BuildContext? buildContext,
|
||||
bool iconOnly = false,
|
||||
@@ -242,6 +280,9 @@ enum ActionButtonType {
|
||||
},
|
||||
),
|
||||
ActionButtonType.cast => CastActionButton(iconOnly: iconOnly, menuItem: menuItem),
|
||||
ActionButtonType.editImage => EditImageActionButton(iconOnly: iconOnly, menuItem: menuItem),
|
||||
ActionButtonType.addTo => AddActionButton(originalTheme: context.originalTheme),
|
||||
ActionButtonType.openActivity => OpenActivityActionButton(iconOnly: iconOnly, menuItem: menuItem),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -272,39 +313,77 @@ enum ActionButtonType {
|
||||
class ActionButtonBuilder {
|
||||
static const List<ActionButtonType> _actionTypes = ActionButtonType.values;
|
||||
static const List<ActionButtonType> defaultViewerKebabMenuOrder = _actionTypes;
|
||||
static const Set<ActionButtonType> defaultViewerBottomBarButtons = {
|
||||
static const List<ActionButtonType> _defaultViewerBottomBarOrder = [
|
||||
ActionButtonType.share,
|
||||
ActionButtonType.moveToLockFolder,
|
||||
ActionButtonType.upload,
|
||||
ActionButtonType.editImage,
|
||||
ActionButtonType.addTo,
|
||||
ActionButtonType.openActivity,
|
||||
ActionButtonType.likeActivity,
|
||||
ActionButtonType.deleteLocal,
|
||||
ActionButtonType.delete,
|
||||
ActionButtonType.archive,
|
||||
ActionButtonType.unarchive,
|
||||
};
|
||||
ActionButtonType.removeFromLockFolder,
|
||||
ActionButtonType.deletePermanent,
|
||||
];
|
||||
|
||||
static List<Widget> build(ActionButtonContext context) {
|
||||
return _actionTypes.where((type) => type.shouldShow(context)).map((type) => type.buildButton(context)).toList();
|
||||
}
|
||||
|
||||
static List<Widget> buildViewerKebabMenu(ActionButtonContext context, BuildContext buildContext, WidgetRef ref) {
|
||||
final visibleButtons = defaultViewerKebabMenuOrder
|
||||
.where((type) => !defaultViewerBottomBarButtons.contains(type) && type.shouldShow(context))
|
||||
.toList();
|
||||
static List<ActionButtonType> getViewerKebabMenuTypes(ActionButtonContext context) {
|
||||
final visibleBottomBarButtons = getViewerBottomBarTypes(context);
|
||||
final excludedTypes = <ActionButtonType>{...visibleBottomBarButtons, ActionButtonType.addTo};
|
||||
|
||||
if (visibleButtons.isEmpty) {
|
||||
if (visibleBottomBarButtons.contains(ActionButtonType.addTo)) {
|
||||
excludedTypes.addAll([ActionButtonType.moveToLockFolder, ActionButtonType.archive, ActionButtonType.unarchive]);
|
||||
}
|
||||
|
||||
return defaultViewerKebabMenuOrder
|
||||
.where((type) => !excludedTypes.contains(type) && type.shouldShow(context))
|
||||
.toList();
|
||||
}
|
||||
|
||||
static List<ActionButtonType> getViewerBottomBarTypes(ActionButtonContext context) {
|
||||
final bottomBarContext = context.withButtonPosition(ButtonPosition.bottomBar);
|
||||
return _defaultViewerBottomBarOrder.where((type) => type.shouldShow(bottomBarContext)).take(4).toList();
|
||||
}
|
||||
|
||||
static List<Widget> buildViewerKebabMenu(ActionButtonContext context, BuildContext buildContext, WidgetRef ref) {
|
||||
final visibleButtons = getViewerKebabMenuTypes(context);
|
||||
return visibleButtons.toKebabMenuWidgets(context, buildContext, ref);
|
||||
}
|
||||
|
||||
static List<Widget> buildViewerBottomBar(ActionButtonContext context, BuildContext buildContext, WidgetRef ref) {
|
||||
final visibleButtons = getViewerBottomBarTypes(context);
|
||||
return visibleButtons.toBottomBarWidgets(context, buildContext, ref);
|
||||
}
|
||||
}
|
||||
|
||||
extension ActionButtonTypeListExtension on List<ActionButtonType> {
|
||||
List<Widget> toKebabMenuWidgets(ActionButtonContext context, BuildContext buildContext, WidgetRef ref) {
|
||||
if (isEmpty) {
|
||||
return [];
|
||||
}
|
||||
|
||||
final List<Widget> result = [];
|
||||
int? lastGroup;
|
||||
|
||||
for (final type in visibleButtons) {
|
||||
for (final type in this) {
|
||||
if (lastGroup != null && type.kebabMenuGroup != lastGroup) {
|
||||
result.add(const Divider(height: 1));
|
||||
}
|
||||
result.add(type.buildButton(context, buildContext, false, true).build(buildContext, ref));
|
||||
final widget = type.buildButton(context, buildContext, false, true);
|
||||
result.add(widget is ConsumerWidget ? widget.build(buildContext, ref) : widget);
|
||||
lastGroup = type.kebabMenuGroup;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
List<Widget> toBottomBarWidgets(ActionButtonContext context, BuildContext buildContext, WidgetRef ref) {
|
||||
return map((type) {
|
||||
final widget = type.buildButton(context, buildContext, false, false);
|
||||
return widget is ConsumerWidget ? widget.build(buildContext, ref) : widget;
|
||||
}).toList();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:immich_mobile/constants/enums.dart';
|
||||
@@ -962,4 +963,128 @@ void main() {
|
||||
expect(nonArchivedWidgets, isNotEmpty);
|
||||
});
|
||||
});
|
||||
|
||||
group('ActionButtonBuilder.getViewerBottomBarTypes', () {
|
||||
test('should return correct button types for shared album with activity', () {
|
||||
final remoteAsset = createRemoteAsset();
|
||||
final album = createRemoteAlbum(isActivityEnabled: true, isShared: true);
|
||||
final context = ActionButtonContext(
|
||||
asset: remoteAsset,
|
||||
isOwner: true,
|
||||
isArchived: false,
|
||||
isTrashEnabled: true,
|
||||
isInLockedView: false,
|
||||
currentAlbum: album,
|
||||
advancedTroubleshooting: false,
|
||||
isStacked: false,
|
||||
source: ActionSource.viewer,
|
||||
buttonPosition: ButtonPosition.bottomBar,
|
||||
);
|
||||
|
||||
const expectedTypes = [
|
||||
ActionButtonType.share,
|
||||
ActionButtonType.addTo,
|
||||
ActionButtonType.openActivity,
|
||||
ActionButtonType.likeActivity,
|
||||
];
|
||||
|
||||
final bottomBarTypes = ActionButtonBuilder.getViewerBottomBarTypes(context);
|
||||
final kebabTypes = ActionButtonBuilder.getViewerKebabMenuTypes(context);
|
||||
|
||||
expect(const ListEquality().equals(bottomBarTypes, expectedTypes), isTrue);
|
||||
expect(bottomBarTypes.any(kebabTypes.contains), isFalse);
|
||||
});
|
||||
|
||||
test('should return correct button types for local only asset', () {
|
||||
final localAsset = createLocalAsset();
|
||||
final context = ActionButtonContext(
|
||||
asset: localAsset,
|
||||
isOwner: true,
|
||||
isArchived: false,
|
||||
isTrashEnabled: true,
|
||||
isInLockedView: false,
|
||||
currentAlbum: null,
|
||||
advancedTroubleshooting: false,
|
||||
isStacked: false,
|
||||
source: ActionSource.viewer,
|
||||
buttonPosition: ButtonPosition.bottomBar,
|
||||
);
|
||||
|
||||
const expectedTypes = [
|
||||
ActionButtonType.share,
|
||||
ActionButtonType.upload,
|
||||
ActionButtonType.editImage,
|
||||
ActionButtonType.deleteLocal,
|
||||
];
|
||||
|
||||
final bottomBarTypes = ActionButtonBuilder.getViewerBottomBarTypes(context);
|
||||
final kebabTypes = ActionButtonBuilder.getViewerKebabMenuTypes(
|
||||
context.withButtonPosition(ButtonPosition.kebabMenu),
|
||||
);
|
||||
|
||||
expect(const ListEquality().equals(bottomBarTypes, expectedTypes), isTrue);
|
||||
expect(bottomBarTypes.any(kebabTypes.contains), isFalse);
|
||||
});
|
||||
|
||||
test('should return correct button types for locked view', () {
|
||||
final remoteAsset = createRemoteAsset();
|
||||
final context = ActionButtonContext(
|
||||
asset: remoteAsset,
|
||||
isOwner: true,
|
||||
isArchived: false,
|
||||
isTrashEnabled: false,
|
||||
isInLockedView: true,
|
||||
currentAlbum: null,
|
||||
advancedTroubleshooting: false,
|
||||
isStacked: false,
|
||||
source: ActionSource.viewer,
|
||||
buttonPosition: ButtonPosition.bottomBar,
|
||||
);
|
||||
|
||||
const expectedTypes = [
|
||||
ActionButtonType.share,
|
||||
ActionButtonType.removeFromLockFolder,
|
||||
ActionButtonType.deletePermanent,
|
||||
];
|
||||
|
||||
final bottomBarTypes = ActionButtonBuilder.getViewerBottomBarTypes(context);
|
||||
final kebabTypes = ActionButtonBuilder.getViewerKebabMenuTypes(
|
||||
context.withButtonPosition(ButtonPosition.kebabMenu),
|
||||
);
|
||||
|
||||
expect(const ListEquality().equals(bottomBarTypes, expectedTypes), isTrue);
|
||||
expect(bottomBarTypes.any(kebabTypes.contains), isFalse);
|
||||
});
|
||||
|
||||
test('should return correct button types for remote only asset', () {
|
||||
final remoteAsset = createRemoteAsset();
|
||||
final context = ActionButtonContext(
|
||||
asset: remoteAsset,
|
||||
isOwner: true,
|
||||
isArchived: false,
|
||||
isTrashEnabled: true,
|
||||
isInLockedView: false,
|
||||
currentAlbum: null,
|
||||
advancedTroubleshooting: false,
|
||||
isStacked: false,
|
||||
source: ActionSource.viewer,
|
||||
buttonPosition: ButtonPosition.bottomBar,
|
||||
);
|
||||
|
||||
const expectedTypes = [
|
||||
ActionButtonType.share,
|
||||
ActionButtonType.editImage,
|
||||
ActionButtonType.addTo,
|
||||
ActionButtonType.delete,
|
||||
];
|
||||
|
||||
final bottomBarTypes = ActionButtonBuilder.getViewerBottomBarTypes(context);
|
||||
final kebabTypes = ActionButtonBuilder.getViewerKebabMenuTypes(
|
||||
context.withButtonPosition(ButtonPosition.kebabMenu),
|
||||
);
|
||||
|
||||
expect(const ListEquality().equals(bottomBarTypes, expectedTypes), isTrue);
|
||||
expect(bottomBarTypes.any(kebabTypes.contains), isFalse);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -240,7 +240,7 @@ export type Session = {
|
||||
isPendingSyncReset: boolean;
|
||||
};
|
||||
|
||||
export type Exif = Omit<Selectable<AssetExifTable>, 'updatedAt' | 'updateId'>;
|
||||
export type Exif = Omit<Selectable<AssetExifTable>, 'updatedAt' | 'updateId' | 'lockedProperties'>;
|
||||
|
||||
export type Person = {
|
||||
createdAt: Date;
|
||||
@@ -465,3 +465,13 @@ export const columns = {
|
||||
'plugin.updatedAt as updatedAt',
|
||||
],
|
||||
} 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
|
||||
"asset"."id" = "tag_asset"."assetId"
|
||||
) as agg
|
||||
) as "tags"
|
||||
) as "tags",
|
||||
to_json("asset_exif") as "exifInfo"
|
||||
from
|
||||
"asset"
|
||||
inner join "asset_exif" on "asset"."id" = "asset_exif"."assetId"
|
||||
where
|
||||
"asset"."id" = $2::uuid
|
||||
limit
|
||||
@@ -224,6 +226,14 @@ from
|
||||
where
|
||||
"asset"."id" = $2
|
||||
|
||||
-- AssetJobRepository.getLockedPropertiesForMetadataExtraction
|
||||
select
|
||||
"asset_exif"."lockedProperties"
|
||||
from
|
||||
"asset_exif"
|
||||
where
|
||||
"asset_exif"."assetId" = $1
|
||||
|
||||
-- AssetJobRepository.getAlbumThumbnailFiles
|
||||
select
|
||||
"asset_file"."id",
|
||||
|
||||
@@ -1,19 +1,49 @@
|
||||
-- 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
|
||||
update "asset_exif"
|
||||
set
|
||||
"model" = $1
|
||||
"model" = $1,
|
||||
"lockedProperties" = nullif(
|
||||
array(
|
||||
select distinct
|
||||
unnest("asset_exif"."lockedProperties" || $2)
|
||||
),
|
||||
'{}'
|
||||
)
|
||||
where
|
||||
"assetId" in ($2)
|
||||
"assetId" in ($3)
|
||||
|
||||
-- AssetRepository.updateDateTimeOriginal
|
||||
update "asset_exif"
|
||||
set
|
||||
"dateTimeOriginal" = "dateTimeOriginal" + $1::interval,
|
||||
"timeZone" = $2
|
||||
"timeZone" = $2,
|
||||
"lockedProperties" = nullif(
|
||||
array(
|
||||
select distinct
|
||||
unnest("asset_exif"."lockedProperties" || $3)
|
||||
),
|
||||
'{}'
|
||||
)
|
||||
where
|
||||
"assetId" in ($3)
|
||||
"assetId" in ($4)
|
||||
returning
|
||||
"assetId",
|
||||
"dateTimeOriginal",
|
||||
|
||||
@@ -50,6 +50,7 @@ export class AssetJobRepository {
|
||||
.whereRef('asset.id', '=', 'tag_asset.assetId'),
|
||||
).as('tags'),
|
||||
)
|
||||
.$call(withExifInner)
|
||||
.limit(1)
|
||||
.executeTakeFirst();
|
||||
}
|
||||
@@ -128,6 +129,16 @@ export class AssetJobRepository {
|
||||
.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] })
|
||||
getAlbumThumbnailFiles(id: string, fileType?: AssetFileType) {
|
||||
return this.db
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
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 { InjectKysely } from 'nestjs-kysely';
|
||||
import { Stack } from 'src/database';
|
||||
import { LockableProperty, Stack } from 'src/database';
|
||||
import { Chunked, ChunkedArray, DummyValue, GenerateSql } from 'src/decorators';
|
||||
import { AuthDto } from 'src/dtos/auth.dto';
|
||||
import { AssetFileType, AssetMetadataKey, AssetOrder, AssetStatus, AssetType, AssetVisibility } from 'src/enum';
|
||||
@@ -113,51 +113,77 @@ interface GetByIdsRelations {
|
||||
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()
|
||||
export class AssetRepository {
|
||||
constructor(@InjectKysely() private db: Kysely<DB>) {}
|
||||
|
||||
async upsertExif(exif: Insertable<AssetExifTable>): Promise<void> {
|
||||
const value = { ...exif, assetId: asUuid(exif.assetId) };
|
||||
@GenerateSql({
|
||||
params: [
|
||||
{ dateTimeOriginal: DummyValue.DATE, lockedProperties: ['dateTimeOriginal'] },
|
||||
{ lockedPropertiesBehavior: 'append' },
|
||||
],
|
||||
})
|
||||
async upsertExif(
|
||||
exif: Insertable<AssetExifTable>,
|
||||
{ lockedPropertiesBehavior }: { lockedPropertiesBehavior: 'override' | 'append' | 'skip' },
|
||||
): Promise<void> {
|
||||
await this.db
|
||||
.insertInto('asset_exif')
|
||||
.values(value)
|
||||
.values(exif)
|
||||
.onConflict((oc) =>
|
||||
oc.column('assetId').doUpdateSet((eb) =>
|
||||
removeUndefinedKeys(
|
||||
oc.column('assetId').doUpdateSet((eb) => {
|
||||
const updateLocked = <T extends keyof AssetExifTable>(col: T) => eb.ref(`excluded.${col}`);
|
||||
const skipLocked = <T extends keyof AssetExifTable>(col: T) =>
|
||||
eb
|
||||
.case()
|
||||
.when(sql`${col}`, '=', eb.fn.any('asset_exif.lockedProperties'))
|
||||
.then(eb.ref(`asset_exif.${col}`))
|
||||
.else(eb.ref(`excluded.${col}`))
|
||||
.end();
|
||||
const ref = lockedPropertiesBehavior === 'skip' ? skipLocked : updateLocked;
|
||||
return {
|
||||
...removeUndefinedKeys(
|
||||
{
|
||||
description: eb.ref('excluded.description'),
|
||||
exifImageWidth: eb.ref('excluded.exifImageWidth'),
|
||||
exifImageHeight: eb.ref('excluded.exifImageHeight'),
|
||||
fileSizeInByte: eb.ref('excluded.fileSizeInByte'),
|
||||
orientation: eb.ref('excluded.orientation'),
|
||||
dateTimeOriginal: eb.ref('excluded.dateTimeOriginal'),
|
||||
modifyDate: eb.ref('excluded.modifyDate'),
|
||||
timeZone: eb.ref('excluded.timeZone'),
|
||||
latitude: eb.ref('excluded.latitude'),
|
||||
longitude: eb.ref('excluded.longitude'),
|
||||
projectionType: eb.ref('excluded.projectionType'),
|
||||
city: eb.ref('excluded.city'),
|
||||
livePhotoCID: eb.ref('excluded.livePhotoCID'),
|
||||
autoStackId: eb.ref('excluded.autoStackId'),
|
||||
state: eb.ref('excluded.state'),
|
||||
country: eb.ref('excluded.country'),
|
||||
make: eb.ref('excluded.make'),
|
||||
model: eb.ref('excluded.model'),
|
||||
lensModel: eb.ref('excluded.lensModel'),
|
||||
fNumber: eb.ref('excluded.fNumber'),
|
||||
focalLength: eb.ref('excluded.focalLength'),
|
||||
iso: eb.ref('excluded.iso'),
|
||||
exposureTime: eb.ref('excluded.exposureTime'),
|
||||
profileDescription: eb.ref('excluded.profileDescription'),
|
||||
colorspace: eb.ref('excluded.colorspace'),
|
||||
bitsPerSample: eb.ref('excluded.bitsPerSample'),
|
||||
rating: eb.ref('excluded.rating'),
|
||||
fps: eb.ref('excluded.fps'),
|
||||
description: ref('description'),
|
||||
exifImageWidth: ref('exifImageWidth'),
|
||||
exifImageHeight: ref('exifImageHeight'),
|
||||
fileSizeInByte: ref('fileSizeInByte'),
|
||||
orientation: ref('orientation'),
|
||||
dateTimeOriginal: ref('dateTimeOriginal'),
|
||||
modifyDate: ref('modifyDate'),
|
||||
timeZone: ref('timeZone'),
|
||||
latitude: ref('latitude'),
|
||||
longitude: ref('longitude'),
|
||||
projectionType: ref('projectionType'),
|
||||
city: ref('city'),
|
||||
livePhotoCID: ref('livePhotoCID'),
|
||||
autoStackId: ref('autoStackId'),
|
||||
state: ref('state'),
|
||||
country: ref('country'),
|
||||
make: ref('make'),
|
||||
model: ref('model'),
|
||||
lensModel: ref('lensModel'),
|
||||
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'),
|
||||
},
|
||||
value,
|
||||
),
|
||||
exif,
|
||||
),
|
||||
};
|
||||
}),
|
||||
)
|
||||
.execute();
|
||||
}
|
||||
@@ -169,19 +195,26 @@ export class AssetRepository {
|
||||
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] })
|
||||
@Chunked()
|
||||
async updateDateTimeOriginal(
|
||||
ids: string[],
|
||||
delta?: number,
|
||||
timeZone?: string,
|
||||
): Promise<{ assetId: string; dateTimeOriginal: Date | null; timeZone: string | null }[]> {
|
||||
return await this.db
|
||||
updateDateTimeOriginal(ids: string[], delta?: number, timeZone?: string) {
|
||||
return this.db
|
||||
.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)
|
||||
.returning(['assetId', 'dateTimeOriginal', 'timeZone'])
|
||||
.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 { AssetTable } from 'src/schema/tables/asset.table';
|
||||
import { Column, ForeignKeyColumn, Generated, Int8, Table, Timestamp, UpdateDateColumn } from 'src/sql-tools';
|
||||
@@ -97,4 +98,7 @@ export class AssetExifTable {
|
||||
|
||||
@UpdateIdColumn({ index: true })
|
||||
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 }));
|
||||
|
||||
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({
|
||||
name: JobName.AssetExtractMetadata,
|
||||
data: { id: assetId, source: 'upload' },
|
||||
@@ -399,7 +402,10 @@ export class AssetMediaService extends BaseService {
|
||||
});
|
||||
|
||||
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' } });
|
||||
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(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 });
|
||||
|
||||
|
||||
@@ -225,7 +225,10 @@ describe(AssetService.name, () => {
|
||||
|
||||
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 () => {
|
||||
@@ -235,7 +238,14 @@ describe(AssetService.name, () => {
|
||||
|
||||
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 () => {
|
||||
@@ -427,9 +437,7 @@ describe(AssetService.name, () => {
|
||||
});
|
||||
expect(mocks.asset.updateAll).toHaveBeenCalled();
|
||||
expect(mocks.asset.updateAllExif).toHaveBeenCalledWith(['asset-1'], { latitude: 0, longitude: 0 });
|
||||
expect(mocks.job.queueAll).toHaveBeenCalledWith([
|
||||
{ name: JobName.SidecarWrite, data: { id: 'asset-1', latitude: 0, longitude: 0 } },
|
||||
]);
|
||||
expect(mocks.job.queueAll).toHaveBeenCalledWith([{ name: JobName.SidecarWrite, data: { id: 'asset-1' } }]);
|
||||
});
|
||||
|
||||
it('should update exif table if latitude field is provided', async () => {
|
||||
@@ -450,9 +458,7 @@ describe(AssetService.name, () => {
|
||||
latitude: 30,
|
||||
longitude: 50,
|
||||
});
|
||||
expect(mocks.job.queueAll).toHaveBeenCalledWith([
|
||||
{ name: JobName.SidecarWrite, data: { id: 'asset-1', dateTimeOriginal, latitude: 30, longitude: 50 } },
|
||||
]);
|
||||
expect(mocks.job.queueAll).toHaveBeenCalledWith([{ name: JobName.SidecarWrite, data: { id: 'asset-1' } }]);
|
||||
});
|
||||
|
||||
it('should update Assets table if duplicateId is provided as null', async () => {
|
||||
@@ -482,18 +488,7 @@ describe(AssetService.name, () => {
|
||||
timeZone,
|
||||
});
|
||||
expect(mocks.asset.updateDateTimeOriginal).toHaveBeenCalledWith(['asset-1'], dateTimeRelative, timeZone);
|
||||
expect(mocks.job.queueAll).toHaveBeenCalledWith([
|
||||
{
|
||||
name: JobName.SidecarWrite,
|
||||
data: {
|
||||
id: 'asset-1',
|
||||
dateTimeOriginal: '2020-02-25T06:41:00.000+02:00',
|
||||
description: undefined,
|
||||
latitude: undefined,
|
||||
longitude: undefined,
|
||||
},
|
||||
},
|
||||
]);
|
||||
expect(mocks.job.queueAll).toHaveBeenCalledWith([{ name: JobName.SidecarWrite, data: { id: 'asset-1' } }]);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -30,9 +30,10 @@ import {
|
||||
QueueName,
|
||||
} from 'src/enum';
|
||||
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 { getAssetFiles, getMyPartnerIds, onAfterUnlink, onBeforeLink, onBeforeUnlink } from 'src/utils/asset.util';
|
||||
import { updateLockedColumns } from 'src/utils/database';
|
||||
|
||||
@Injectable()
|
||||
export class AssetService extends BaseService {
|
||||
@@ -142,56 +143,26 @@ export class AssetService extends BaseService {
|
||||
} = dto;
|
||||
await this.requireAccess({ auth, permission: Permission.AssetUpdate, ids });
|
||||
|
||||
const assetDto = { isFavorite, visibility, duplicateId };
|
||||
const exifDto = { latitude, longitude, rating, description, dateTimeOriginal };
|
||||
const assetDto = _.omitBy({ isFavorite, visibility, duplicateId }, _.isUndefined);
|
||||
const exifDto = _.omitBy({ latitude, longitude, rating, description, dateTimeOriginal }, _.isUndefined);
|
||||
|
||||
const isExifChanged = Object.values(exifDto).some((v) => v !== undefined);
|
||||
if (isExifChanged) {
|
||||
if (Object.keys(exifDto).length > 0) {
|
||||
await this.assetRepository.updateAllExif(ids, exifDto);
|
||||
}
|
||||
|
||||
const assets =
|
||||
(dateTimeRelative !== undefined && dateTimeRelative !== 0) || timeZone !== undefined
|
||||
? 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);
|
||||
if ((dateTimeRelative !== undefined && dateTimeRelative !== 0) || timeZone !== undefined) {
|
||||
await this.assetRepository.updateDateTimeOriginal(ids, dateTimeRelative, 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 (isAssetChanged) {
|
||||
if (Object.keys(assetDto).length > 0) {
|
||||
await this.assetRepository.updateAll(ids, assetDto);
|
||||
}
|
||||
|
||||
if (visibility === AssetVisibility.Locked) {
|
||||
await this.albumRepository.removeAssetsFromAll(ids);
|
||||
}
|
||||
}
|
||||
|
||||
await this.jobRepository.queueAll(ids.map((id) => ({ name: JobName.SidecarWrite, data: { id } })));
|
||||
}
|
||||
|
||||
async copy(
|
||||
@@ -456,12 +427,25 @@ export class AssetService extends BaseService {
|
||||
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 writes = _.omitBy({ description, dateTimeOriginal, latitude, longitude, rating }, _.isUndefined);
|
||||
if (Object.keys(writes).length > 0) {
|
||||
await this.assetRepository.upsertExif({ assetId: id, ...writes });
|
||||
await this.jobRepository.queue({ name: JobName.SidecarWrite, data: { id, ...writes } });
|
||||
await this.assetRepository.upsertExif(
|
||||
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 });
|
||||
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.objectContaining({
|
||||
id: assetStub.image.id,
|
||||
@@ -214,6 +216,7 @@ describe(MetadataService.name, () => {
|
||||
expect(mocks.assetJob.getForMetadataExtraction).toHaveBeenCalledWith(assetStub.image.id);
|
||||
expect(mocks.asset.upsertExif).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ dateTimeOriginal: fileModifiedAt }),
|
||||
{ lockedPropertiesBehavior: 'skip' },
|
||||
);
|
||||
expect(mocks.asset.update).toHaveBeenCalledWith({
|
||||
id: assetStub.image.id,
|
||||
@@ -238,7 +241,10 @@ describe(MetadataService.name, () => {
|
||||
|
||||
await sut.handleMetadataExtraction({ id: 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({
|
||||
id: assetStub.image.id,
|
||||
duration: null,
|
||||
@@ -258,6 +264,7 @@ describe(MetadataService.name, () => {
|
||||
expect.objectContaining({
|
||||
dateTimeOriginal: new Date('2022-01-01T00:00:00.000Z'),
|
||||
}),
|
||||
{ lockedPropertiesBehavior: 'skip' },
|
||||
);
|
||||
|
||||
expect(mocks.asset.update).toHaveBeenCalledWith(
|
||||
@@ -281,7 +288,9 @@ describe(MetadataService.name, () => {
|
||||
|
||||
await sut.handleMetadataExtraction({ id: 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({
|
||||
id: assetStub.image.id,
|
||||
duration: null,
|
||||
@@ -310,6 +319,7 @@ describe(MetadataService.name, () => {
|
||||
expect(mocks.assetJob.getForMetadataExtraction).toHaveBeenCalledWith(assetStub.image.id);
|
||||
expect(mocks.asset.upsertExif).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ city: null, state: null, country: null }),
|
||||
{ lockedPropertiesBehavior: 'skip' },
|
||||
);
|
||||
expect(mocks.asset.update).toHaveBeenCalledWith({
|
||||
id: assetStub.withLocation.id,
|
||||
@@ -339,6 +349,7 @@ describe(MetadataService.name, () => {
|
||||
expect(mocks.assetJob.getForMetadataExtraction).toHaveBeenCalledWith(assetStub.image.id);
|
||||
expect(mocks.asset.upsertExif).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ city: 'City', state: 'State', country: 'Country' }),
|
||||
{ lockedPropertiesBehavior: 'skip' },
|
||||
);
|
||||
expect(mocks.asset.update).toHaveBeenCalledWith({
|
||||
id: assetStub.withLocation.id,
|
||||
@@ -358,7 +369,10 @@ describe(MetadataService.name, () => {
|
||||
|
||||
await sut.handleMetadataExtraction({ id: 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 () => {
|
||||
@@ -571,6 +585,7 @@ describe(MetadataService.name, () => {
|
||||
expect(mocks.assetJob.getForMetadataExtraction).toHaveBeenCalledWith(assetStub.video.id);
|
||||
expect(mocks.asset.upsertExif).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ orientation: ExifOrientation.Rotate270CW.toString() }),
|
||||
{ lockedPropertiesBehavior: 'skip' },
|
||||
);
|
||||
});
|
||||
|
||||
@@ -879,7 +894,8 @@ describe(MetadataService.name, () => {
|
||||
|
||||
await sut.handleMetadataExtraction({ id: 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),
|
||||
autoStackId: null,
|
||||
@@ -909,7 +925,9 @@ describe(MetadataService.name, () => {
|
||||
country: null,
|
||||
state: null,
|
||||
city: null,
|
||||
});
|
||||
},
|
||||
{ lockedPropertiesBehavior: 'skip' },
|
||||
);
|
||||
expect(mocks.asset.update).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
id: assetStub.image.id,
|
||||
@@ -943,6 +961,7 @@ describe(MetadataService.name, () => {
|
||||
expect.objectContaining({
|
||||
timeZone: 'UTC+0',
|
||||
}),
|
||||
{ lockedPropertiesBehavior: 'skip' },
|
||||
);
|
||||
});
|
||||
|
||||
@@ -1103,6 +1122,7 @@ describe(MetadataService.name, () => {
|
||||
expect.objectContaining({
|
||||
description: '',
|
||||
}),
|
||||
{ lockedPropertiesBehavior: 'skip' },
|
||||
);
|
||||
|
||||
mockReadTags({ ImageDescription: ' my\n description' });
|
||||
@@ -1111,6 +1131,7 @@ describe(MetadataService.name, () => {
|
||||
expect.objectContaining({
|
||||
description: 'my\n description',
|
||||
}),
|
||||
{ lockedPropertiesBehavior: 'skip' },
|
||||
);
|
||||
});
|
||||
|
||||
@@ -1123,6 +1144,7 @@ describe(MetadataService.name, () => {
|
||||
expect.objectContaining({
|
||||
description: '1000',
|
||||
}),
|
||||
{ lockedPropertiesBehavior: 'skip' },
|
||||
);
|
||||
});
|
||||
|
||||
@@ -1346,6 +1368,7 @@ describe(MetadataService.name, () => {
|
||||
expect.objectContaining({
|
||||
modifyDate: expect.any(Date),
|
||||
}),
|
||||
{ lockedPropertiesBehavior: 'skip' },
|
||||
);
|
||||
});
|
||||
|
||||
@@ -1358,6 +1381,7 @@ describe(MetadataService.name, () => {
|
||||
expect.objectContaining({
|
||||
rating: null,
|
||||
}),
|
||||
{ lockedPropertiesBehavior: 'skip' },
|
||||
);
|
||||
});
|
||||
|
||||
@@ -1370,6 +1394,7 @@ describe(MetadataService.name, () => {
|
||||
expect.objectContaining({
|
||||
rating: 5,
|
||||
}),
|
||||
{ lockedPropertiesBehavior: 'skip' },
|
||||
);
|
||||
});
|
||||
|
||||
@@ -1382,6 +1407,7 @@ describe(MetadataService.name, () => {
|
||||
expect.objectContaining({
|
||||
rating: -1,
|
||||
}),
|
||||
{ lockedPropertiesBehavior: 'skip' },
|
||||
);
|
||||
});
|
||||
|
||||
@@ -1503,7 +1529,9 @@ describe(MetadataService.name, () => {
|
||||
mockReadTags(exif);
|
||||
|
||||
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([
|
||||
@@ -1529,6 +1557,7 @@ describe(MetadataService.name, () => {
|
||||
expect.objectContaining({
|
||||
lensModel: expected,
|
||||
}),
|
||||
{ lockedPropertiesBehavior: 'skip' },
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -1637,12 +1666,14 @@ describe(MetadataService.name, () => {
|
||||
|
||||
describe('handleSidecarWrite', () => {
|
||||
it('should skip assets that no longer exist', async () => {
|
||||
mocks.assetJob.getLockedPropertiesForMetadataExtraction.mockResolvedValue([]);
|
||||
mocks.assetJob.getForSidecarWriteJob.mockResolvedValue(void 0);
|
||||
await expect(sut.handleSidecarWrite({ id: 'asset-123' })).resolves.toBe(JobStatus.Failed);
|
||||
expect(mocks.metadata.writeTags).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should skip jobs with no metadata', async () => {
|
||||
mocks.assetJob.getLockedPropertiesForMetadataExtraction.mockResolvedValue([]);
|
||||
const asset = factory.jobAssets.sidecarWrite();
|
||||
mocks.assetJob.getForSidecarWriteJob.mockResolvedValue(asset);
|
||||
await expect(sut.handleSidecarWrite({ id: asset.id })).resolves.toBe(JobStatus.Skipped);
|
||||
@@ -1655,20 +1686,22 @@ describe(MetadataService.name, () => {
|
||||
const gps = 12;
|
||||
const date = '2023-11-22T04:56:12.196Z';
|
||||
|
||||
mocks.assetJob.getLockedPropertiesForMetadataExtraction.mockResolvedValue([
|
||||
'description',
|
||||
'latitude',
|
||||
'longitude',
|
||||
'dateTimeOriginal',
|
||||
]);
|
||||
mocks.assetJob.getForSidecarWriteJob.mockResolvedValue(asset);
|
||||
await expect(
|
||||
sut.handleSidecarWrite({
|
||||
id: asset.id,
|
||||
description,
|
||||
latitude: gps,
|
||||
longitude: gps,
|
||||
dateTimeOriginal: date,
|
||||
}),
|
||||
).resolves.toBe(JobStatus.Success);
|
||||
expect(mocks.metadata.writeTags).toHaveBeenCalledWith(asset.files[0].path, {
|
||||
DateTimeOriginal: date,
|
||||
Description: description,
|
||||
ImageDescription: description,
|
||||
DateTimeOriginal: date,
|
||||
GPSLatitude: gps,
|
||||
GPSLongitude: gps,
|
||||
});
|
||||
|
||||
@@ -290,7 +290,7 @@ export class MetadataService extends BaseService {
|
||||
};
|
||||
|
||||
const promises: Promise<unknown>[] = [
|
||||
this.assetRepository.upsertExif(exifData),
|
||||
this.assetRepository.upsertExif(exifData, { lockedPropertiesBehavior: 'skip' }),
|
||||
this.assetRepository.update({
|
||||
id: asset.id,
|
||||
duration: this.getDuration(exifTags),
|
||||
@@ -393,22 +393,34 @@ export class MetadataService extends BaseService {
|
||||
|
||||
@OnJob({ name: JobName.SidecarWrite, queue: QueueName.Sidecar })
|
||||
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);
|
||||
if (!asset) {
|
||||
return JobStatus.Failed;
|
||||
}
|
||||
|
||||
const lockedProperties = await this.assetJobRepository.getLockedPropertiesForMetadataExtraction(id);
|
||||
const tagsList = (asset.tags || []).map((tag) => tag.value);
|
||||
|
||||
const { sidecarFile } = getAssetFiles(asset.files);
|
||||
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(
|
||||
<Tags>{
|
||||
Description: description,
|
||||
ImageDescription: description,
|
||||
DateTimeOriginal: dateTimeOriginal,
|
||||
DateTimeOriginal: dateTimeOriginal ? String(dateTimeOriginal) : undefined,
|
||||
GPSLatitude: latitude,
|
||||
GPSLongitude: longitude,
|
||||
Rating: rating,
|
||||
|
||||
@@ -222,11 +222,6 @@ export interface IDeleteFilesJob extends IBaseJob {
|
||||
}
|
||||
|
||||
export interface ISidecarWriteJob extends IEntityJob {
|
||||
description?: string;
|
||||
dateTimeOriginal?: string;
|
||||
latitude?: number;
|
||||
longitude?: number;
|
||||
rating?: number;
|
||||
tags?: true;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ import { PostgresJSDialect } from 'kysely-postgres-js';
|
||||
import { jsonArrayFrom, jsonObjectFrom } from 'kysely/helpers/postgres';
|
||||
import { parse } from 'pg-connection-string';
|
||||
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 { AssetSearchBuilderOptions } from 'src/repositories/search.repository';
|
||||
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>) {
|
||||
const result = await this.get(AssetRepository).upsertExif(dto);
|
||||
const result = await this.get(AssetRepository).upsertExif(dto, { lockedPropertiesBehavior: 'override' });
|
||||
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),
|
||||
timeZone: expected.timeZone,
|
||||
}),
|
||||
{ lockedPropertiesBehavior: 'skip' },
|
||||
);
|
||||
|
||||
expect(mocks.asset.update).toHaveBeenCalledWith(
|
||||
|
||||
@@ -2,6 +2,7 @@ import { Kysely } from 'kysely';
|
||||
import { AlbumUserRole, SyncEntityType, SyncRequestType } from 'src/enum';
|
||||
import { AssetRepository } from 'src/repositories/asset.repository';
|
||||
import { DB } from 'src/schema';
|
||||
import { updateLockedColumns } from 'src/utils/database';
|
||||
import { SyncTestContext } from 'test/medium.factory';
|
||||
import { factory } from 'test/small.factory';
|
||||
import { getKyselyDB, wait } from 'test/utils';
|
||||
@@ -288,10 +289,13 @@ describe(SyncRequestType.AlbumAssetExifsV1, () => {
|
||||
|
||||
// update the asset
|
||||
const assetRepository = ctx.get(AssetRepository);
|
||||
await assetRepository.upsertExif({
|
||||
await assetRepository.upsertExif(
|
||||
updateLockedColumns({
|
||||
assetId: asset.id,
|
||||
city: 'New City',
|
||||
});
|
||||
}),
|
||||
{ lockedPropertiesBehavior: 'append' },
|
||||
);
|
||||
|
||||
await expect(ctx.syncStream(auth, [SyncRequestType.AlbumAssetExifsV1])).resolves.toEqual([
|
||||
{
|
||||
@@ -346,10 +350,13 @@ describe(SyncRequestType.AlbumAssetExifsV1, () => {
|
||||
|
||||
// update the asset
|
||||
const assetRepository = ctx.get(AssetRepository);
|
||||
await assetRepository.upsertExif({
|
||||
await assetRepository.upsertExif(
|
||||
updateLockedColumns({
|
||||
assetId: assetDelayedExif.id,
|
||||
city: 'Delayed Exif',
|
||||
});
|
||||
}),
|
||||
{ lockedPropertiesBehavior: 'append' },
|
||||
);
|
||||
|
||||
await expect(ctx.syncStream(auth, [SyncRequestType.AlbumAssetExifsV1])).resolves.toEqual([
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@ import {
|
||||
AuthApiKey,
|
||||
AuthSharedLink,
|
||||
AuthUser,
|
||||
Exif,
|
||||
Library,
|
||||
Memory,
|
||||
Partner,
|
||||
@@ -319,8 +320,10 @@ const versionHistoryFactory = () => ({
|
||||
version: '1.123.45',
|
||||
});
|
||||
|
||||
const assetSidecarWriteFactory = () => ({
|
||||
id: newUuid(),
|
||||
const assetSidecarWriteFactory = () => {
|
||||
const id = newUuid();
|
||||
return {
|
||||
id,
|
||||
originalPath: '/path/to/original-path.jpg.xmp',
|
||||
tags: [],
|
||||
files: [
|
||||
@@ -330,7 +333,15 @@ const assetSidecarWriteFactory = () => ({
|
||||
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 = (
|
||||
ocr: {
|
||||
|
||||
Reference in New Issue
Block a user