mirror of
https://github.com/immich-app/immich.git
synced 2025-12-17 17:23:20 +03:00
Compare commits
16 Commits
chore/log-
...
renovate/t
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a0a713fcc3 | ||
|
|
f0b069adb9 | ||
|
|
276d02e12b | ||
|
|
ded9535434 | ||
|
|
997aec2441 | ||
|
|
cb2bd47816 | ||
|
|
f1c8377ca0 | ||
|
|
8416397589 | ||
|
|
dc29635b67 | ||
|
|
00290e1e71 | ||
|
|
3ef4c4f315 | ||
|
|
b10a8baf53 | ||
|
|
77926383db | ||
|
|
35eda735c8 | ||
|
|
8f7a71d1cf | ||
|
|
33cdea88aa |
@@ -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",
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
[tools]
|
[tools]
|
||||||
terragrunt = "0.93.10"
|
terragrunt = "0.95.0"
|
||||||
opentofu = "1.10.7"
|
opentofu = "1.10.7"
|
||||||
|
|
||||||
[tasks."tg:fmt"]
|
[tasks."tg:fmt"]
|
||||||
|
|||||||
@@ -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",
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ experimental_monorepo_root = true
|
|||||||
node = "24.11.1"
|
node = "24.11.1"
|
||||||
flutter = "3.35.7"
|
flutter = "3.35.7"
|
||||||
pnpm = "10.24.0"
|
pnpm = "10.24.0"
|
||||||
terragrunt = "0.93.10"
|
terragrunt = "0.95.0"
|
||||||
opentofu = "1.10.7"
|
opentofu = "1.10.7"
|
||||||
java = "25.0.1"
|
java = "25.0.1"
|
||||||
|
|
||||||
|
|||||||
@@ -9,8 +9,10 @@ import 'package:immich_mobile/providers/infrastructure/action.provider.dart';
|
|||||||
|
|
||||||
class AdvancedInfoActionButton extends ConsumerWidget {
|
class AdvancedInfoActionButton extends ConsumerWidget {
|
||||||
final ActionSource source;
|
final ActionSource source;
|
||||||
|
final bool iconOnly;
|
||||||
|
final bool menuItem;
|
||||||
|
|
||||||
const AdvancedInfoActionButton({super.key, required this.source});
|
const AdvancedInfoActionButton({super.key, required this.source, this.iconOnly = false, this.menuItem = false});
|
||||||
|
|
||||||
void _onTap(BuildContext context, WidgetRef ref) async {
|
void _onTap(BuildContext context, WidgetRef ref) async {
|
||||||
if (!context.mounted) {
|
if (!context.mounted) {
|
||||||
@@ -26,6 +28,8 @@ class AdvancedInfoActionButton extends ConsumerWidget {
|
|||||||
maxWidth: 115.0,
|
maxWidth: 115.0,
|
||||||
iconData: Icons.help_outline_rounded,
|
iconData: Icons.help_outline_rounded,
|
||||||
label: "troubleshoot".t(context: context),
|
label: "troubleshoot".t(context: context),
|
||||||
|
iconOnly: iconOnly,
|
||||||
|
menuItem: menuItem,
|
||||||
onPressed: () => _onTap(context, ref),
|
onPressed: () => _onTap(context, ref),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,8 +35,10 @@ Future<void> performArchiveAction(BuildContext context, WidgetRef ref, {required
|
|||||||
|
|
||||||
class ArchiveActionButton extends ConsumerWidget {
|
class ArchiveActionButton extends ConsumerWidget {
|
||||||
final ActionSource source;
|
final ActionSource source;
|
||||||
|
final bool iconOnly;
|
||||||
|
final bool menuItem;
|
||||||
|
|
||||||
const ArchiveActionButton({super.key, required this.source});
|
const ArchiveActionButton({super.key, required this.source, this.iconOnly = false, this.menuItem = false});
|
||||||
|
|
||||||
Future<void> _onTap(BuildContext context, WidgetRef ref) async {
|
Future<void> _onTap(BuildContext context, WidgetRef ref) async {
|
||||||
await performArchiveAction(context, ref, source: source);
|
await performArchiveAction(context, ref, source: source);
|
||||||
@@ -47,6 +49,8 @@ class ArchiveActionButton extends ConsumerWidget {
|
|||||||
return BaseActionButton(
|
return BaseActionButton(
|
||||||
iconData: Icons.archive_outlined,
|
iconData: Icons.archive_outlined,
|
||||||
label: "to_archive".t(context: context),
|
label: "to_archive".t(context: context),
|
||||||
|
iconOnly: iconOnly,
|
||||||
|
menuItem: menuItem,
|
||||||
onPressed: () => _onTap(context, ref),
|
onPressed: () => _onTap(context, ref),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,15 @@ import 'package:immich_mobile/widgets/common/immich_toast.dart';
|
|||||||
class DeleteActionButton extends ConsumerWidget {
|
class DeleteActionButton extends ConsumerWidget {
|
||||||
final ActionSource source;
|
final ActionSource source;
|
||||||
final bool showConfirmation;
|
final bool showConfirmation;
|
||||||
const DeleteActionButton({super.key, required this.source, this.showConfirmation = false});
|
final bool iconOnly;
|
||||||
|
final bool menuItem;
|
||||||
|
const DeleteActionButton({
|
||||||
|
super.key,
|
||||||
|
required this.source,
|
||||||
|
this.showConfirmation = false,
|
||||||
|
this.iconOnly = false,
|
||||||
|
this.menuItem = false,
|
||||||
|
});
|
||||||
|
|
||||||
void _onTap(BuildContext context, WidgetRef ref) async {
|
void _onTap(BuildContext context, WidgetRef ref) async {
|
||||||
if (!context.mounted) {
|
if (!context.mounted) {
|
||||||
@@ -74,6 +82,8 @@ class DeleteActionButton extends ConsumerWidget {
|
|||||||
maxWidth: 110.0,
|
maxWidth: 110.0,
|
||||||
iconData: Icons.delete_sweep_outlined,
|
iconData: Icons.delete_sweep_outlined,
|
||||||
label: "delete".t(context: context),
|
label: "delete".t(context: context),
|
||||||
|
iconOnly: iconOnly,
|
||||||
|
menuItem: menuItem,
|
||||||
onPressed: () => _onTap(context, ref),
|
onPressed: () => _onTap(context, ref),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,8 +14,10 @@ import 'package:immich_mobile/widgets/common/immich_toast.dart';
|
|||||||
/// - Prompt to delete the asset locally
|
/// - Prompt to delete the asset locally
|
||||||
class DeleteLocalActionButton extends ConsumerWidget {
|
class DeleteLocalActionButton extends ConsumerWidget {
|
||||||
final ActionSource source;
|
final ActionSource source;
|
||||||
|
final bool iconOnly;
|
||||||
|
final bool menuItem;
|
||||||
|
|
||||||
const DeleteLocalActionButton({super.key, required this.source});
|
const DeleteLocalActionButton({super.key, required this.source, this.iconOnly = false, this.menuItem = false});
|
||||||
|
|
||||||
void _onTap(BuildContext context, WidgetRef ref) async {
|
void _onTap(BuildContext context, WidgetRef ref) async {
|
||||||
if (!context.mounted) {
|
if (!context.mounted) {
|
||||||
@@ -55,6 +57,8 @@ class DeleteLocalActionButton extends ConsumerWidget {
|
|||||||
maxWidth: 95.0,
|
maxWidth: 95.0,
|
||||||
iconData: Icons.no_cell_outlined,
|
iconData: Icons.no_cell_outlined,
|
||||||
label: "control_bottom_app_bar_delete_from_local".t(context: context),
|
label: "control_bottom_app_bar_delete_from_local".t(context: context),
|
||||||
|
iconOnly: iconOnly,
|
||||||
|
menuItem: menuItem,
|
||||||
onPressed: () => _onTap(context, ref),
|
onPressed: () => _onTap(context, ref),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,8 +15,10 @@ import 'package:immich_mobile/widgets/common/immich_toast.dart';
|
|||||||
/// - Prompt to delete the asset locally
|
/// - Prompt to delete the asset locally
|
||||||
class DeletePermanentActionButton extends ConsumerWidget {
|
class DeletePermanentActionButton extends ConsumerWidget {
|
||||||
final ActionSource source;
|
final ActionSource source;
|
||||||
|
final bool iconOnly;
|
||||||
|
final bool menuItem;
|
||||||
|
|
||||||
const DeletePermanentActionButton({super.key, required this.source});
|
const DeletePermanentActionButton({super.key, required this.source, this.iconOnly = false, this.menuItem = false});
|
||||||
|
|
||||||
void _onTap(BuildContext context, WidgetRef ref) async {
|
void _onTap(BuildContext context, WidgetRef ref) async {
|
||||||
if (!context.mounted) {
|
if (!context.mounted) {
|
||||||
@@ -51,6 +53,8 @@ class DeletePermanentActionButton extends ConsumerWidget {
|
|||||||
maxWidth: 110.0,
|
maxWidth: 110.0,
|
||||||
iconData: Icons.delete_forever,
|
iconData: Icons.delete_forever,
|
||||||
label: "delete_permanently".t(context: context),
|
label: "delete_permanently".t(context: context),
|
||||||
|
iconOnly: iconOnly,
|
||||||
|
menuItem: menuItem,
|
||||||
onPressed: () => _onTap(context, ref),
|
onPressed: () => _onTap(context, ref),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
@@ -38,8 +38,10 @@ Future<void> performMoveToLockFolderAction(BuildContext context, WidgetRef ref,
|
|||||||
|
|
||||||
class MoveToLockFolderActionButton extends ConsumerWidget {
|
class MoveToLockFolderActionButton extends ConsumerWidget {
|
||||||
final ActionSource source;
|
final ActionSource source;
|
||||||
|
final bool iconOnly;
|
||||||
|
final bool menuItem;
|
||||||
|
|
||||||
const MoveToLockFolderActionButton({super.key, required this.source});
|
const MoveToLockFolderActionButton({super.key, required this.source, this.iconOnly = false, this.menuItem = false});
|
||||||
|
|
||||||
Future<void> _onTap(BuildContext context, WidgetRef ref) async {
|
Future<void> _onTap(BuildContext context, WidgetRef ref) async {
|
||||||
await performMoveToLockFolderAction(context, ref, source: source);
|
await performMoveToLockFolderAction(context, ref, source: source);
|
||||||
@@ -51,6 +53,8 @@ class MoveToLockFolderActionButton extends ConsumerWidget {
|
|||||||
maxWidth: 115.0,
|
maxWidth: 115.0,
|
||||||
iconData: Icons.lock_outline_rounded,
|
iconData: Icons.lock_outline_rounded,
|
||||||
label: "move_to_locked_folder".t(context: context),
|
label: "move_to_locked_folder".t(context: context),
|
||||||
|
iconOnly: iconOnly,
|
||||||
|
menuItem: menuItem,
|
||||||
onPressed: () => _onTap(context, ref),
|
onPressed: () => _onTap(context, ref),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:fluttertoast/fluttertoast.dart';
|
import 'package:fluttertoast/fluttertoast.dart';
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
import 'package:immich_mobile/constants/enums.dart';
|
import 'package:immich_mobile/constants/enums.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/extensions/translate_extensions.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/action_buttons/base_action_button.widget.dart';
|
import 'package:immich_mobile/presentation/widgets/action_buttons/base_action_button.widget.dart';
|
||||||
import 'package:immich_mobile/providers/infrastructure/action.provider.dart';
|
import 'package:immich_mobile/providers/infrastructure/action.provider.dart';
|
||||||
@@ -11,8 +13,16 @@ import 'package:immich_mobile/widgets/common/immich_toast.dart';
|
|||||||
class RemoveFromAlbumActionButton extends ConsumerWidget {
|
class RemoveFromAlbumActionButton extends ConsumerWidget {
|
||||||
final String albumId;
|
final String albumId;
|
||||||
final ActionSource source;
|
final ActionSource source;
|
||||||
|
final bool iconOnly;
|
||||||
|
final bool menuItem;
|
||||||
|
|
||||||
const RemoveFromAlbumActionButton({super.key, required this.albumId, required this.source});
|
const RemoveFromAlbumActionButton({
|
||||||
|
super.key,
|
||||||
|
required this.albumId,
|
||||||
|
required this.source,
|
||||||
|
this.iconOnly = false,
|
||||||
|
this.menuItem = false,
|
||||||
|
});
|
||||||
|
|
||||||
void _onTap(BuildContext context, WidgetRef ref) async {
|
void _onTap(BuildContext context, WidgetRef ref) async {
|
||||||
if (!context.mounted) {
|
if (!context.mounted) {
|
||||||
@@ -22,6 +32,10 @@ class RemoveFromAlbumActionButton extends ConsumerWidget {
|
|||||||
final result = await ref.read(actionProvider.notifier).removeFromAlbum(source, albumId);
|
final result = await ref.read(actionProvider.notifier).removeFromAlbum(source, albumId);
|
||||||
ref.read(multiSelectProvider.notifier).reset();
|
ref.read(multiSelectProvider.notifier).reset();
|
||||||
|
|
||||||
|
if (source == ActionSource.viewer) {
|
||||||
|
EventStream.shared.emit(const ViewerReloadAssetEvent());
|
||||||
|
}
|
||||||
|
|
||||||
final successMessage = 'remove_from_album_action_prompt'.t(
|
final successMessage = 'remove_from_album_action_prompt'.t(
|
||||||
context: context,
|
context: context,
|
||||||
args: {'count': result.count.toString()},
|
args: {'count': result.count.toString()},
|
||||||
@@ -42,6 +56,8 @@ class RemoveFromAlbumActionButton extends ConsumerWidget {
|
|||||||
return BaseActionButton(
|
return BaseActionButton(
|
||||||
iconData: Icons.remove_circle_outline,
|
iconData: Icons.remove_circle_outline,
|
||||||
label: "remove_from_album".t(context: context),
|
label: "remove_from_album".t(context: context),
|
||||||
|
iconOnly: iconOnly,
|
||||||
|
menuItem: menuItem,
|
||||||
onPressed: () => _onTap(context, ref),
|
onPressed: () => _onTap(context, ref),
|
||||||
maxWidth: 100,
|
maxWidth: 100,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -10,8 +10,15 @@ import 'package:immich_mobile/widgets/common/immich_toast.dart';
|
|||||||
|
|
||||||
class RemoveFromLockFolderActionButton extends ConsumerWidget {
|
class RemoveFromLockFolderActionButton extends ConsumerWidget {
|
||||||
final ActionSource source;
|
final ActionSource source;
|
||||||
|
final bool iconOnly;
|
||||||
|
final bool menuItem;
|
||||||
|
|
||||||
const RemoveFromLockFolderActionButton({super.key, required this.source});
|
const RemoveFromLockFolderActionButton({
|
||||||
|
super.key,
|
||||||
|
required this.source,
|
||||||
|
this.iconOnly = false,
|
||||||
|
this.menuItem = false,
|
||||||
|
});
|
||||||
|
|
||||||
void _onTap(BuildContext context, WidgetRef ref) async {
|
void _onTap(BuildContext context, WidgetRef ref) async {
|
||||||
if (!context.mounted) {
|
if (!context.mounted) {
|
||||||
@@ -42,6 +49,8 @@ class RemoveFromLockFolderActionButton extends ConsumerWidget {
|
|||||||
maxWidth: 100.0,
|
maxWidth: 100.0,
|
||||||
iconData: Icons.lock_open_rounded,
|
iconData: Icons.lock_open_rounded,
|
||||||
label: "remove_from_locked_folder".t(context: context),
|
label: "remove_from_locked_folder".t(context: context),
|
||||||
|
iconOnly: iconOnly,
|
||||||
|
menuItem: menuItem,
|
||||||
onPressed: () => _onTap(context, ref),
|
onPressed: () => _onTap(context, ref),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,8 +31,10 @@ class _SharePreparingDialog extends StatelessWidget {
|
|||||||
|
|
||||||
class ShareActionButton extends ConsumerWidget {
|
class ShareActionButton extends ConsumerWidget {
|
||||||
final ActionSource source;
|
final ActionSource source;
|
||||||
|
final bool iconOnly;
|
||||||
|
final bool menuItem;
|
||||||
|
|
||||||
const ShareActionButton({super.key, required this.source});
|
const ShareActionButton({super.key, required this.source, this.iconOnly = false, this.menuItem = false});
|
||||||
|
|
||||||
void _onTap(BuildContext context, WidgetRef ref) async {
|
void _onTap(BuildContext context, WidgetRef ref) async {
|
||||||
if (!context.mounted) {
|
if (!context.mounted) {
|
||||||
@@ -74,6 +76,8 @@ class ShareActionButton extends ConsumerWidget {
|
|||||||
return BaseActionButton(
|
return BaseActionButton(
|
||||||
iconData: Platform.isAndroid ? Icons.share_rounded : Icons.ios_share_rounded,
|
iconData: Platform.isAndroid ? Icons.share_rounded : Icons.ios_share_rounded,
|
||||||
label: 'share'.t(context: context),
|
label: 'share'.t(context: context),
|
||||||
|
iconOnly: iconOnly,
|
||||||
|
menuItem: menuItem,
|
||||||
onPressed: () => _onTap(context, ref),
|
onPressed: () => _onTap(context, ref),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,8 +7,10 @@ import 'package:immich_mobile/providers/infrastructure/action.provider.dart';
|
|||||||
|
|
||||||
class ShareLinkActionButton extends ConsumerWidget {
|
class ShareLinkActionButton extends ConsumerWidget {
|
||||||
final ActionSource source;
|
final ActionSource source;
|
||||||
|
final bool iconOnly;
|
||||||
|
final bool menuItem;
|
||||||
|
|
||||||
const ShareLinkActionButton({super.key, required this.source});
|
const ShareLinkActionButton({super.key, required this.source, this.iconOnly = false, this.menuItem = false});
|
||||||
|
|
||||||
_onTap(BuildContext context, WidgetRef ref) async {
|
_onTap(BuildContext context, WidgetRef ref) async {
|
||||||
if (!context.mounted) {
|
if (!context.mounted) {
|
||||||
@@ -23,6 +25,8 @@ class ShareLinkActionButton extends ConsumerWidget {
|
|||||||
return BaseActionButton(
|
return BaseActionButton(
|
||||||
iconData: Icons.link_rounded,
|
iconData: Icons.link_rounded,
|
||||||
label: "share_link".t(context: context),
|
label: "share_link".t(context: context),
|
||||||
|
iconOnly: iconOnly,
|
||||||
|
menuItem: menuItem,
|
||||||
onPressed: () => _onTap(context, ref),
|
onPressed: () => _onTap(context, ref),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,8 +13,10 @@ import 'package:immich_mobile/routing/router.dart';
|
|||||||
|
|
||||||
class SimilarPhotosActionButton extends ConsumerWidget {
|
class SimilarPhotosActionButton extends ConsumerWidget {
|
||||||
final String assetId;
|
final String assetId;
|
||||||
|
final bool iconOnly;
|
||||||
|
final bool menuItem;
|
||||||
|
|
||||||
const SimilarPhotosActionButton({super.key, required this.assetId});
|
const SimilarPhotosActionButton({super.key, required this.assetId, this.iconOnly = false, this.menuItem = false});
|
||||||
|
|
||||||
void _onTap(BuildContext context, WidgetRef ref) async {
|
void _onTap(BuildContext context, WidgetRef ref) async {
|
||||||
if (!context.mounted) {
|
if (!context.mounted) {
|
||||||
@@ -44,6 +46,8 @@ class SimilarPhotosActionButton extends ConsumerWidget {
|
|||||||
return BaseActionButton(
|
return BaseActionButton(
|
||||||
iconData: Icons.compare,
|
iconData: Icons.compare,
|
||||||
label: "view_similar_photos".t(context: context),
|
label: "view_similar_photos".t(context: context),
|
||||||
|
iconOnly: iconOnly,
|
||||||
|
menuItem: menuItem,
|
||||||
onPressed: () => _onTap(context, ref),
|
onPressed: () => _onTap(context, ref),
|
||||||
maxWidth: 100,
|
maxWidth: 100,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -15,8 +15,10 @@ import 'package:immich_mobile/widgets/common/immich_toast.dart';
|
|||||||
/// which will be permanently deleted after the number of days configure by the admin
|
/// which will be permanently deleted after the number of days configure by the admin
|
||||||
class TrashActionButton extends ConsumerWidget {
|
class TrashActionButton extends ConsumerWidget {
|
||||||
final ActionSource source;
|
final ActionSource source;
|
||||||
|
final bool iconOnly;
|
||||||
|
final bool menuItem;
|
||||||
|
|
||||||
const TrashActionButton({super.key, required this.source});
|
const TrashActionButton({super.key, required this.source, this.iconOnly = false, this.menuItem = false});
|
||||||
|
|
||||||
void _onTap(BuildContext context, WidgetRef ref) async {
|
void _onTap(BuildContext context, WidgetRef ref) async {
|
||||||
if (!context.mounted) {
|
if (!context.mounted) {
|
||||||
@@ -48,6 +50,8 @@ class TrashActionButton extends ConsumerWidget {
|
|||||||
maxWidth: 85.0,
|
maxWidth: 85.0,
|
||||||
iconData: Icons.delete_outline_rounded,
|
iconData: Icons.delete_outline_rounded,
|
||||||
label: "control_bottom_app_bar_trash_from_immich".t(context: context),
|
label: "control_bottom_app_bar_trash_from_immich".t(context: context),
|
||||||
|
iconOnly: iconOnly,
|
||||||
|
menuItem: menuItem,
|
||||||
onPressed: () => _onTap(context, ref),
|
onPressed: () => _onTap(context, ref),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,8 +37,10 @@ Future<void> performUnArchiveAction(BuildContext context, WidgetRef ref, {requir
|
|||||||
|
|
||||||
class UnArchiveActionButton extends ConsumerWidget {
|
class UnArchiveActionButton extends ConsumerWidget {
|
||||||
final ActionSource source;
|
final ActionSource source;
|
||||||
|
final bool iconOnly;
|
||||||
|
final bool menuItem;
|
||||||
|
|
||||||
const UnArchiveActionButton({super.key, required this.source});
|
const UnArchiveActionButton({super.key, required this.source, this.iconOnly = false, this.menuItem = false});
|
||||||
|
|
||||||
Future<void> _onTap(BuildContext context, WidgetRef ref) async {
|
Future<void> _onTap(BuildContext context, WidgetRef ref) async {
|
||||||
await performUnArchiveAction(context, ref, source: source);
|
await performUnArchiveAction(context, ref, source: source);
|
||||||
@@ -49,6 +51,8 @@ class UnArchiveActionButton extends ConsumerWidget {
|
|||||||
return BaseActionButton(
|
return BaseActionButton(
|
||||||
iconData: Icons.unarchive_outlined,
|
iconData: Icons.unarchive_outlined,
|
||||||
label: "unarchive".t(context: context),
|
label: "unarchive".t(context: context),
|
||||||
|
iconOnly: iconOnly,
|
||||||
|
menuItem: menuItem,
|
||||||
onPressed: () => _onTap(context, ref),
|
onPressed: () => _onTap(context, ref),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,8 +10,10 @@ import 'package:immich_mobile/widgets/common/immich_toast.dart';
|
|||||||
|
|
||||||
class UnStackActionButton extends ConsumerWidget {
|
class UnStackActionButton extends ConsumerWidget {
|
||||||
final ActionSource source;
|
final ActionSource source;
|
||||||
|
final bool iconOnly;
|
||||||
|
final bool menuItem;
|
||||||
|
|
||||||
const UnStackActionButton({super.key, required this.source});
|
const UnStackActionButton({super.key, required this.source, this.iconOnly = false, this.menuItem = false});
|
||||||
|
|
||||||
void _onTap(BuildContext context, WidgetRef ref) async {
|
void _onTap(BuildContext context, WidgetRef ref) async {
|
||||||
if (!context.mounted) {
|
if (!context.mounted) {
|
||||||
@@ -38,6 +40,8 @@ class UnStackActionButton extends ConsumerWidget {
|
|||||||
return BaseActionButton(
|
return BaseActionButton(
|
||||||
iconData: Icons.layers_clear_outlined,
|
iconData: Icons.layers_clear_outlined,
|
||||||
label: "unstack".t(context: context),
|
label: "unstack".t(context: context),
|
||||||
|
iconOnly: iconOnly,
|
||||||
|
menuItem: menuItem,
|
||||||
onPressed: () => _onTap(context, ref),
|
onPressed: () => _onTap(context, ref),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,8 +10,10 @@ import 'package:immich_mobile/widgets/common/immich_toast.dart';
|
|||||||
|
|
||||||
class UploadActionButton extends ConsumerWidget {
|
class UploadActionButton extends ConsumerWidget {
|
||||||
final ActionSource source;
|
final ActionSource source;
|
||||||
|
final bool iconOnly;
|
||||||
|
final bool menuItem;
|
||||||
|
|
||||||
const UploadActionButton({super.key, required this.source});
|
const UploadActionButton({super.key, required this.source, this.iconOnly = false, this.menuItem = false});
|
||||||
|
|
||||||
void _onTap(BuildContext context, WidgetRef ref) async {
|
void _onTap(BuildContext context, WidgetRef ref) async {
|
||||||
if (!context.mounted) {
|
if (!context.mounted) {
|
||||||
@@ -39,6 +41,8 @@ class UploadActionButton extends ConsumerWidget {
|
|||||||
return BaseActionButton(
|
return BaseActionButton(
|
||||||
iconData: Icons.backup_outlined,
|
iconData: Icons.backup_outlined,
|
||||||
label: "upload".t(context: context),
|
label: "upload".t(context: context),
|
||||||
|
iconOnly: iconOnly,
|
||||||
|
menuItem: menuItem,
|
||||||
onPressed: () => _onTap(context, ref),
|
onPressed: () => _onTap(context, ref),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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()],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,14 +42,17 @@ class ViewerBottomBar extends ConsumerWidget {
|
|||||||
|
|
||||||
final actions = <Widget>[
|
final actions = <Widget>[
|
||||||
const ShareActionButton(source: ActionSource.viewer),
|
const ShareActionButton(source: ActionSource.viewer),
|
||||||
if (asset.isLocalOnly) const UploadActionButton(source: ActionSource.viewer),
|
|
||||||
if (asset.type == AssetType.image) const EditImageActionButton(),
|
|
||||||
if (asset.hasRemote) AddActionButton(originalTheme: originalTheme),
|
|
||||||
|
|
||||||
if (isOwner) ...[
|
if (!isInLockedView) ...[
|
||||||
asset.isLocalOnly
|
if (asset.isLocalOnly) const UploadActionButton(source: ActionSource.viewer),
|
||||||
? const DeleteLocalActionButton(source: ActionSource.viewer)
|
if (asset.type == AssetType.image) const EditImageActionButton(),
|
||||||
: const DeleteActionButton(source: ActionSource.viewer, showConfirmation: true),
|
if (asset.hasRemote) AddActionButton(originalTheme: originalTheme),
|
||||||
|
|
||||||
|
if (isOwner) ...[
|
||||||
|
asset.isLocalOnly
|
||||||
|
? const DeleteLocalActionButton(source: ActionSource.viewer)
|
||||||
|
: const DeleteActionButton(source: ActionSource.viewer, showConfirmation: true),
|
||||||
|
],
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -76,7 +79,7 @@ class ViewerBottomBar extends ConsumerWidget {
|
|||||||
mainAxisAlignment: MainAxisAlignment.end,
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
children: [
|
children: [
|
||||||
if (asset.isVideo) const VideoControls(),
|
if (asset.isVideo) const VideoControls(),
|
||||||
if (!isInLockedView && !isReadonlyModeEnabled)
|
if (!isReadonlyModeEnabled)
|
||||||
Row(mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: actions),
|
Row(mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: actions),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|||||||
import 'package:immich_mobile/constants/enums.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/asset/base_asset.model.dart';
|
||||||
import 'package:immich_mobile/domain/models/exif.model.dart';
|
import 'package:immich_mobile/domain/models/exif.model.dart';
|
||||||
import 'package:immich_mobile/domain/models/setting.model.dart';
|
|
||||||
import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
||||||
import 'package:immich_mobile/extensions/duration_extensions.dart';
|
import 'package:immich_mobile/extensions/duration_extensions.dart';
|
||||||
import 'package:immich_mobile/extensions/translate_extensions.dart';
|
import 'package:immich_mobile/extensions/translate_extensions.dart';
|
||||||
@@ -21,14 +20,9 @@ import 'package:immich_mobile/presentation/widgets/bottom_sheet/base_bottom_shee
|
|||||||
import 'package:immich_mobile/providers/infrastructure/action.provider.dart';
|
import 'package:immich_mobile/providers/infrastructure/action.provider.dart';
|
||||||
import 'package:immich_mobile/providers/infrastructure/album.provider.dart';
|
import 'package:immich_mobile/providers/infrastructure/album.provider.dart';
|
||||||
import 'package:immich_mobile/providers/infrastructure/asset_viewer/current_asset.provider.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/setting.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/providers/user.provider.dart';
|
||||||
import 'package:immich_mobile/repositories/asset_media.repository.dart';
|
import 'package:immich_mobile/repositories/asset_media.repository.dart';
|
||||||
import 'package:immich_mobile/routing/router.dart';
|
import 'package:immich_mobile/routing/router.dart';
|
||||||
import 'package:immich_mobile/utils/action_button.utils.dart';
|
|
||||||
import 'package:immich_mobile/utils/bytes_units.dart';
|
import 'package:immich_mobile/utils/bytes_units.dart';
|
||||||
import 'package:immich_mobile/utils/timezone.dart';
|
import 'package:immich_mobile/utils/timezone.dart';
|
||||||
import 'package:immich_mobile/widgets/common/immich_toast.dart';
|
import 'package:immich_mobile/widgets/common/immich_toast.dart';
|
||||||
@@ -48,29 +42,8 @@ class AssetDetailBottomSheet extends ConsumerWidget {
|
|||||||
return const SizedBox.shrink();
|
return const SizedBox.shrink();
|
||||||
}
|
}
|
||||||
|
|
||||||
final isTrashEnable = ref.watch(serverInfoProvider.select((state) => state.serverFeatures.trash));
|
|
||||||
final isOwner = asset is RemoteAsset && asset.ownerId == ref.watch(currentUserProvider)?.id;
|
|
||||||
final isInLockedView = ref.watch(inLockedViewProvider);
|
|
||||||
final currentAlbum = ref.watch(currentRemoteAlbumProvider);
|
|
||||||
final isArchived = asset is RemoteAsset && asset.visibility == AssetVisibility.archive;
|
|
||||||
final advancedTroubleshooting = ref.watch(settingsProvider.notifier).get(Setting.advancedTroubleshooting);
|
|
||||||
|
|
||||||
final buttonContext = ActionButtonContext(
|
|
||||||
asset: asset,
|
|
||||||
isOwner: isOwner,
|
|
||||||
isArchived: isArchived,
|
|
||||||
isTrashEnabled: isTrashEnable,
|
|
||||||
isInLockedView: isInLockedView,
|
|
||||||
isStacked: asset is RemoteAsset && asset.stackId != null,
|
|
||||||
currentAlbum: currentAlbum,
|
|
||||||
advancedTroubleshooting: advancedTroubleshooting,
|
|
||||||
source: ActionSource.viewer,
|
|
||||||
);
|
|
||||||
|
|
||||||
final actions = ActionButtonBuilder.build(buttonContext);
|
|
||||||
|
|
||||||
return BaseBottomSheet(
|
return BaseBottomSheet(
|
||||||
actions: actions,
|
actions: [],
|
||||||
slivers: const [_AssetDetailBottomSheet()],
|
slivers: const [_AssetDetailBottomSheet()],
|
||||||
controller: controller,
|
controller: controller,
|
||||||
initialChildSize: initialChildSize,
|
initialChildSize: initialChildSize,
|
||||||
@@ -79,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,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -326,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),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,16 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.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/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/extensions/build_context_extensions.dart';
|
||||||
import 'package:immich_mobile/providers/cast.provider.dart';
|
import 'package:immich_mobile/providers/cast.provider.dart';
|
||||||
import 'package:immich_mobile/providers/infrastructure/asset_viewer/current_asset.provider.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/setting.provider.dart';
|
||||||
import 'package:immich_mobile/providers/infrastructure/timeline.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/providers/user.provider.dart';
|
||||||
import 'package:immich_mobile/utils/action_button.utils.dart';
|
import 'package:immich_mobile/utils/action_button.utils.dart';
|
||||||
|
|
||||||
@@ -24,16 +30,28 @@ class ViewerKebabMenu extends ConsumerWidget {
|
|||||||
final isOwner = asset is RemoteAsset && asset.ownerId == user?.id;
|
final isOwner = asset is RemoteAsset && asset.ownerId == user?.id;
|
||||||
final isCasting = ref.watch(castProvider.select((c) => c.isCasting));
|
final isCasting = ref.watch(castProvider.select((c) => c.isCasting));
|
||||||
final timelineOrigin = ref.read(timelineServiceProvider).origin;
|
final timelineOrigin = ref.read(timelineServiceProvider).origin;
|
||||||
|
final isTrashEnable = ref.watch(serverInfoProvider.select((state) => state.serverFeatures.trash));
|
||||||
|
final isInLockedView = ref.watch(inLockedViewProvider);
|
||||||
|
final currentAlbum = ref.watch(currentRemoteAlbumProvider);
|
||||||
|
final isArchived = asset is RemoteAsset && asset.visibility == AssetVisibility.archive;
|
||||||
|
final advancedTroubleshooting = ref.watch(settingsProvider.notifier).get(Setting.advancedTroubleshooting);
|
||||||
|
|
||||||
final kebabContext = ViewerKebabMenuButtonContext(
|
final actionContext = ActionButtonContext(
|
||||||
asset: asset,
|
asset: asset,
|
||||||
isOwner: isOwner,
|
isOwner: isOwner,
|
||||||
|
isArchived: isArchived,
|
||||||
|
isTrashEnabled: isTrashEnable,
|
||||||
|
isStacked: asset is RemoteAsset && asset.stackId != null,
|
||||||
|
isInLockedView: isInLockedView,
|
||||||
|
currentAlbum: currentAlbum,
|
||||||
|
advancedTroubleshooting: advancedTroubleshooting,
|
||||||
|
source: ActionSource.viewer,
|
||||||
isCasting: isCasting,
|
isCasting: isCasting,
|
||||||
timelineOrigin: timelineOrigin,
|
timelineOrigin: timelineOrigin,
|
||||||
originalTheme: originalTheme,
|
originalTheme: originalTheme,
|
||||||
);
|
);
|
||||||
|
|
||||||
final menuChildren = ViewerKebabMenuButtonBuilder.build(kebabContext, context, ref);
|
final menuChildren = ActionButtonBuilder.buildViewerKebabMenu(actionContext, context, ref);
|
||||||
|
|
||||||
return MenuAnchor(
|
return MenuAnchor(
|
||||||
consumeOutsideTap: true,
|
consumeOutsideTap: true,
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -17,8 +17,10 @@ class PersonApiRepository extends ApiRepository {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<PersonDto> update(String id, {String? name, DateTime? birthday}) async {
|
Future<PersonDto> update(String id, {String? name, DateTime? birthday}) async {
|
||||||
final dto = await checkNull(_api.updatePerson(id, PersonUpdateDto(name: name, birthDate: birthday)));
|
final birthdayUtc = birthday == null ? null : DateTime.utc(birthday.year, birthday.month, birthday.day);
|
||||||
return _toPerson(dto);
|
final dto = PersonUpdateDto(name: name, birthDate: birthdayUtc);
|
||||||
|
final response = await checkNull(_api.updatePerson(id, dto));
|
||||||
|
return _toPerson(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
static PersonDto _toPerson(PersonResponseDto dto) => PersonDto(
|
static PersonDto _toPerson(PersonResponseDto dto) => PersonDto(
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ enum AppSettingsEnum<T> {
|
|||||||
thumbnailCacheSize<int>(StoreKey.thumbnailCacheSize, "thumbnailCacheSize", 10000),
|
thumbnailCacheSize<int>(StoreKey.thumbnailCacheSize, "thumbnailCacheSize", 10000),
|
||||||
imageCacheSize<int>(StoreKey.imageCacheSize, "imageCacheSize", 350),
|
imageCacheSize<int>(StoreKey.imageCacheSize, "imageCacheSize", 350),
|
||||||
albumThumbnailCacheSize<int>(StoreKey.albumThumbnailCacheSize, "albumThumbnailCacheSize", 200),
|
albumThumbnailCacheSize<int>(StoreKey.albumThumbnailCacheSize, "albumThumbnailCacheSize", 200),
|
||||||
selectedAlbumSortOrder<int>(StoreKey.selectedAlbumSortOrder, "selectedAlbumSortOrder", 0),
|
selectedAlbumSortOrder<int>(StoreKey.selectedAlbumSortOrder, "selectedAlbumSortOrder", 2),
|
||||||
advancedTroubleshooting<bool>(StoreKey.advancedTroubleshooting, null, false),
|
advancedTroubleshooting<bool>(StoreKey.advancedTroubleshooting, null, false),
|
||||||
manageLocalMediaAndroid<bool>(StoreKey.manageLocalMediaAndroid, null, false),
|
manageLocalMediaAndroid<bool>(StoreKey.manageLocalMediaAndroid, null, false),
|
||||||
logLevel<int>(StoreKey.logLevel, null, 5), // Level.INFO = 5
|
logLevel<int>(StoreKey.logLevel, null, 5), // Level.INFO = 5
|
||||||
@@ -42,7 +42,7 @@ enum AppSettingsEnum<T> {
|
|||||||
mapRelativeDate<int>(StoreKey.mapRelativeDate, null, 0),
|
mapRelativeDate<int>(StoreKey.mapRelativeDate, null, 0),
|
||||||
allowSelfSignedSSLCert<bool>(StoreKey.selfSignedCert, null, false),
|
allowSelfSignedSSLCert<bool>(StoreKey.selfSignedCert, null, false),
|
||||||
ignoreIcloudAssets<bool>(StoreKey.ignoreIcloudAssets, null, false),
|
ignoreIcloudAssets<bool>(StoreKey.ignoreIcloudAssets, null, false),
|
||||||
selectedAlbumSortReverse<bool>(StoreKey.selectedAlbumSortReverse, null, false),
|
selectedAlbumSortReverse<bool>(StoreKey.selectedAlbumSortReverse, null, true),
|
||||||
enableHapticFeedback<bool>(StoreKey.enableHapticFeedback, null, true),
|
enableHapticFeedback<bool>(StoreKey.enableHapticFeedback, null, true),
|
||||||
syncAlbums<bool>(StoreKey.syncAlbums, null, false),
|
syncAlbums<bool>(StoreKey.syncAlbums, null, false),
|
||||||
autoEndpointSwitching<bool>(StoreKey.autoEndpointSwitching, null, false),
|
autoEndpointSwitching<bool>(StoreKey.autoEndpointSwitching, null, false),
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ 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/models/events.model.dart';
|
||||||
import 'package:immich_mobile/domain/services/timeline.service.dart';
|
import 'package:immich_mobile/domain/services/timeline.service.dart';
|
||||||
import 'package:immich_mobile/domain/utils/event_stream.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/advanced_info_action_button.widget.dart';
|
import 'package:immich_mobile/presentation/widgets/action_buttons/advanced_info_action_button.widget.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/action_buttons/archive_action_button.widget.dart';
|
import 'package:immich_mobile/presentation/widgets/action_buttons/archive_action_button.widget.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/action_buttons/base_action_button.widget.dart';
|
import 'package:immich_mobile/presentation/widgets/action_buttons/base_action_button.widget.dart';
|
||||||
@@ -40,6 +39,9 @@ class ActionButtonContext {
|
|||||||
final RemoteAlbum? currentAlbum;
|
final RemoteAlbum? currentAlbum;
|
||||||
final bool advancedTroubleshooting;
|
final bool advancedTroubleshooting;
|
||||||
final ActionSource source;
|
final ActionSource source;
|
||||||
|
final bool isCasting;
|
||||||
|
final TimelineOrigin timelineOrigin;
|
||||||
|
final ThemeData? originalTheme;
|
||||||
|
|
||||||
const ActionButtonContext({
|
const ActionButtonContext({
|
||||||
required this.asset,
|
required this.asset,
|
||||||
@@ -51,27 +53,33 @@ class ActionButtonContext {
|
|||||||
required this.currentAlbum,
|
required this.currentAlbum,
|
||||||
required this.advancedTroubleshooting,
|
required this.advancedTroubleshooting,
|
||||||
required this.source,
|
required this.source,
|
||||||
|
this.isCasting = false,
|
||||||
|
this.timelineOrigin = TimelineOrigin.main,
|
||||||
|
this.originalTheme,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
enum ActionButtonType {
|
enum ActionButtonType {
|
||||||
advancedInfo,
|
openInfo,
|
||||||
|
likeActivity,
|
||||||
share,
|
share,
|
||||||
shareLink,
|
shareLink,
|
||||||
|
cast,
|
||||||
similarPhotos,
|
similarPhotos,
|
||||||
|
viewInTimeline,
|
||||||
|
download,
|
||||||
|
upload,
|
||||||
|
unstack,
|
||||||
archive,
|
archive,
|
||||||
unarchive,
|
unarchive,
|
||||||
download,
|
|
||||||
trash,
|
|
||||||
deletePermanent,
|
|
||||||
delete,
|
|
||||||
moveToLockFolder,
|
moveToLockFolder,
|
||||||
removeFromLockFolder,
|
removeFromLockFolder,
|
||||||
deleteLocal,
|
|
||||||
upload,
|
|
||||||
removeFromAlbum,
|
removeFromAlbum,
|
||||||
unstack,
|
trash,
|
||||||
likeActivity;
|
deleteLocal,
|
||||||
|
deletePermanent,
|
||||||
|
delete,
|
||||||
|
advancedInfo;
|
||||||
|
|
||||||
bool shouldShow(ActionButtonContext context) {
|
bool shouldShow(ActionButtonContext context) {
|
||||||
return switch (this) {
|
return switch (this) {
|
||||||
@@ -138,132 +146,163 @@ enum ActionButtonType {
|
|||||||
ActionButtonType.similarPhotos =>
|
ActionButtonType.similarPhotos =>
|
||||||
!context.isInLockedView && //
|
!context.isInLockedView && //
|
||||||
context.asset is RemoteAsset,
|
context.asset is RemoteAsset,
|
||||||
};
|
ActionButtonType.openInfo => true,
|
||||||
}
|
ActionButtonType.viewInTimeline =>
|
||||||
|
|
||||||
Widget buildButton(ActionButtonContext context) {
|
|
||||||
return switch (this) {
|
|
||||||
ActionButtonType.advancedInfo => AdvancedInfoActionButton(source: context.source),
|
|
||||||
ActionButtonType.share => ShareActionButton(source: context.source),
|
|
||||||
ActionButtonType.shareLink => ShareLinkActionButton(source: context.source),
|
|
||||||
ActionButtonType.archive => ArchiveActionButton(source: context.source),
|
|
||||||
ActionButtonType.unarchive => UnArchiveActionButton(source: context.source),
|
|
||||||
ActionButtonType.download => DownloadActionButton(source: context.source),
|
|
||||||
ActionButtonType.trash => TrashActionButton(source: context.source),
|
|
||||||
ActionButtonType.deletePermanent => DeletePermanentActionButton(source: context.source),
|
|
||||||
ActionButtonType.delete => DeleteActionButton(source: context.source),
|
|
||||||
ActionButtonType.moveToLockFolder => MoveToLockFolderActionButton(source: context.source),
|
|
||||||
ActionButtonType.removeFromLockFolder => RemoveFromLockFolderActionButton(source: context.source),
|
|
||||||
ActionButtonType.deleteLocal => DeleteLocalActionButton(source: context.source),
|
|
||||||
ActionButtonType.upload => UploadActionButton(source: context.source),
|
|
||||||
ActionButtonType.removeFromAlbum => RemoveFromAlbumActionButton(
|
|
||||||
albumId: context.currentAlbum!.id,
|
|
||||||
source: context.source,
|
|
||||||
),
|
|
||||||
ActionButtonType.likeActivity => const LikeActivityActionButton(),
|
|
||||||
ActionButtonType.unstack => UnStackActionButton(source: context.source),
|
|
||||||
ActionButtonType.similarPhotos => SimilarPhotosActionButton(assetId: (context.asset as RemoteAsset).id),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class ActionButtonBuilder {
|
|
||||||
static const List<ActionButtonType> _actionTypes = ActionButtonType.values;
|
|
||||||
|
|
||||||
static List<Widget> build(ActionButtonContext context) {
|
|
||||||
return _actionTypes.where((type) => type.shouldShow(context)).map((type) => type.buildButton(context)).toList();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class ViewerKebabMenuButtonContext {
|
|
||||||
final BaseAsset asset;
|
|
||||||
final bool isOwner;
|
|
||||||
final bool isCasting;
|
|
||||||
final TimelineOrigin timelineOrigin;
|
|
||||||
final ThemeData? originalTheme;
|
|
||||||
|
|
||||||
const ViewerKebabMenuButtonContext({
|
|
||||||
required this.asset,
|
|
||||||
required this.isOwner,
|
|
||||||
required this.isCasting,
|
|
||||||
required this.timelineOrigin,
|
|
||||||
this.originalTheme,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
enum ViewerKebabMenuButtonType {
|
|
||||||
openInfo,
|
|
||||||
viewInTimeline,
|
|
||||||
cast,
|
|
||||||
download;
|
|
||||||
|
|
||||||
/// Defines which group each button belongs to.
|
|
||||||
/// Buttons in the same group will be displayed together,
|
|
||||||
/// with dividers separating different groups.
|
|
||||||
int get group => switch (this) {
|
|
||||||
ViewerKebabMenuButtonType.openInfo => 0,
|
|
||||||
ViewerKebabMenuButtonType.viewInTimeline => 1,
|
|
||||||
ViewerKebabMenuButtonType.cast => 1,
|
|
||||||
ViewerKebabMenuButtonType.download => 1,
|
|
||||||
};
|
|
||||||
|
|
||||||
bool shouldShow(ViewerKebabMenuButtonContext context) {
|
|
||||||
return switch (this) {
|
|
||||||
ViewerKebabMenuButtonType.openInfo => true,
|
|
||||||
ViewerKebabMenuButtonType.viewInTimeline =>
|
|
||||||
context.timelineOrigin != TimelineOrigin.main &&
|
context.timelineOrigin != TimelineOrigin.main &&
|
||||||
context.timelineOrigin != TimelineOrigin.deepLink &&
|
context.timelineOrigin != TimelineOrigin.deepLink &&
|
||||||
context.timelineOrigin != TimelineOrigin.trash &&
|
context.timelineOrigin != TimelineOrigin.trash &&
|
||||||
|
context.timelineOrigin != TimelineOrigin.lockedFolder &&
|
||||||
context.timelineOrigin != TimelineOrigin.archive &&
|
context.timelineOrigin != TimelineOrigin.archive &&
|
||||||
context.timelineOrigin != TimelineOrigin.localAlbum &&
|
context.timelineOrigin != TimelineOrigin.localAlbum &&
|
||||||
context.isOwner,
|
context.isOwner,
|
||||||
ViewerKebabMenuButtonType.cast => context.isCasting || context.asset.hasRemote,
|
ActionButtonType.cast => context.isCasting || context.asset.hasRemote,
|
||||||
ViewerKebabMenuButtonType.download => context.asset.isRemoteOnly,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
ConsumerWidget buildButton(ViewerKebabMenuButtonContext context, BuildContext buildContext) {
|
ConsumerWidget buildButton(
|
||||||
|
ActionButtonContext context, [
|
||||||
|
BuildContext? buildContext,
|
||||||
|
bool iconOnly = false,
|
||||||
|
bool menuItem = false,
|
||||||
|
]) {
|
||||||
return switch (this) {
|
return switch (this) {
|
||||||
ViewerKebabMenuButtonType.openInfo => BaseActionButton(
|
ActionButtonType.advancedInfo => AdvancedInfoActionButton(
|
||||||
|
source: context.source,
|
||||||
|
iconOnly: iconOnly,
|
||||||
|
menuItem: menuItem,
|
||||||
|
),
|
||||||
|
ActionButtonType.share => ShareActionButton(source: context.source, iconOnly: iconOnly, menuItem: menuItem),
|
||||||
|
ActionButtonType.shareLink => ShareLinkActionButton(
|
||||||
|
source: context.source,
|
||||||
|
iconOnly: iconOnly,
|
||||||
|
menuItem: menuItem,
|
||||||
|
),
|
||||||
|
ActionButtonType.archive => ArchiveActionButton(source: context.source, iconOnly: iconOnly, menuItem: menuItem),
|
||||||
|
ActionButtonType.unarchive => UnArchiveActionButton(
|
||||||
|
source: context.source,
|
||||||
|
iconOnly: iconOnly,
|
||||||
|
menuItem: menuItem,
|
||||||
|
),
|
||||||
|
ActionButtonType.download => DownloadActionButton(source: context.source, iconOnly: iconOnly, menuItem: menuItem),
|
||||||
|
ActionButtonType.trash => TrashActionButton(source: context.source, iconOnly: iconOnly, menuItem: menuItem),
|
||||||
|
ActionButtonType.deletePermanent => DeletePermanentActionButton(
|
||||||
|
source: context.source,
|
||||||
|
iconOnly: iconOnly,
|
||||||
|
menuItem: menuItem,
|
||||||
|
),
|
||||||
|
ActionButtonType.delete => DeleteActionButton(source: context.source, iconOnly: iconOnly, menuItem: menuItem),
|
||||||
|
ActionButtonType.moveToLockFolder => MoveToLockFolderActionButton(
|
||||||
|
source: context.source,
|
||||||
|
iconOnly: iconOnly,
|
||||||
|
menuItem: menuItem,
|
||||||
|
),
|
||||||
|
ActionButtonType.removeFromLockFolder => RemoveFromLockFolderActionButton(
|
||||||
|
source: context.source,
|
||||||
|
iconOnly: iconOnly,
|
||||||
|
menuItem: menuItem,
|
||||||
|
),
|
||||||
|
ActionButtonType.deleteLocal => DeleteLocalActionButton(
|
||||||
|
source: context.source,
|
||||||
|
iconOnly: iconOnly,
|
||||||
|
menuItem: menuItem,
|
||||||
|
),
|
||||||
|
ActionButtonType.upload => UploadActionButton(source: context.source, iconOnly: iconOnly, menuItem: menuItem),
|
||||||
|
ActionButtonType.removeFromAlbum => RemoveFromAlbumActionButton(
|
||||||
|
albumId: context.currentAlbum!.id,
|
||||||
|
source: context.source,
|
||||||
|
iconOnly: iconOnly,
|
||||||
|
menuItem: menuItem,
|
||||||
|
),
|
||||||
|
ActionButtonType.likeActivity => LikeActivityActionButton(iconOnly: iconOnly, menuItem: menuItem),
|
||||||
|
ActionButtonType.unstack => UnStackActionButton(source: context.source, iconOnly: iconOnly, menuItem: menuItem),
|
||||||
|
ActionButtonType.similarPhotos => SimilarPhotosActionButton(
|
||||||
|
assetId: (context.asset as RemoteAsset).id,
|
||||||
|
iconOnly: iconOnly,
|
||||||
|
menuItem: menuItem,
|
||||||
|
),
|
||||||
|
ActionButtonType.openInfo => BaseActionButton(
|
||||||
label: 'info'.tr(),
|
label: 'info'.tr(),
|
||||||
iconData: Icons.info_outline,
|
iconData: Icons.info_outline,
|
||||||
iconColor: context.originalTheme?.iconTheme.color,
|
iconColor: context.originalTheme?.iconTheme.color,
|
||||||
menuItem: true,
|
menuItem: true,
|
||||||
onPressed: () => EventStream.shared.emit(const ViewerOpenBottomSheetEvent()),
|
onPressed: () => EventStream.shared.emit(const ViewerOpenBottomSheetEvent()),
|
||||||
),
|
),
|
||||||
|
ActionButtonType.viewInTimeline => BaseActionButton(
|
||||||
ViewerKebabMenuButtonType.viewInTimeline => BaseActionButton(
|
label: 'view_in_timeline'.tr(),
|
||||||
label: 'view_in_timeline'.t(context: buildContext),
|
|
||||||
iconData: Icons.image_search,
|
iconData: Icons.image_search,
|
||||||
iconColor: context.originalTheme?.iconTheme.color,
|
iconColor: context.originalTheme?.iconTheme.color,
|
||||||
menuItem: true,
|
iconOnly: iconOnly,
|
||||||
onPressed: () async {
|
menuItem: menuItem,
|
||||||
await buildContext.maybePop();
|
onPressed: buildContext == null
|
||||||
await buildContext.navigateTo(const TabShellRoute(children: [MainTimelineRoute()]));
|
? null
|
||||||
EventStream.shared.emit(ScrollToDateEvent(context.asset.createdAt));
|
: () async {
|
||||||
},
|
await buildContext.maybePop();
|
||||||
|
await buildContext.navigateTo(const TabShellRoute(children: [MainTimelineRoute()]));
|
||||||
|
EventStream.shared.emit(ScrollToDateEvent(context.asset.createdAt));
|
||||||
|
},
|
||||||
),
|
),
|
||||||
ViewerKebabMenuButtonType.cast => const CastActionButton(menuItem: true),
|
ActionButtonType.cast => CastActionButton(iconOnly: iconOnly, menuItem: menuItem),
|
||||||
ViewerKebabMenuButtonType.download => const DownloadActionButton(source: ActionSource.viewer, menuItem: true),
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Defines which group each button belongs to for kebab menu.
|
||||||
|
/// Buttons in the same group will be displayed together,
|
||||||
|
/// with dividers separating different groups.
|
||||||
|
int get kebabMenuGroup => switch (this) {
|
||||||
|
// 0: info
|
||||||
|
ActionButtonType.openInfo => 0,
|
||||||
|
// 10: move,remove, and delete
|
||||||
|
ActionButtonType.trash => 10,
|
||||||
|
ActionButtonType.deletePermanent => 10,
|
||||||
|
ActionButtonType.removeFromLockFolder => 10,
|
||||||
|
ActionButtonType.removeFromAlbum => 10,
|
||||||
|
ActionButtonType.unstack => 10,
|
||||||
|
ActionButtonType.archive => 10,
|
||||||
|
ActionButtonType.unarchive => 10,
|
||||||
|
ActionButtonType.moveToLockFolder => 10,
|
||||||
|
ActionButtonType.deleteLocal => 10,
|
||||||
|
ActionButtonType.delete => 10,
|
||||||
|
// 90: advancedInfo
|
||||||
|
ActionButtonType.advancedInfo => 90,
|
||||||
|
// 1: others
|
||||||
|
_ => 1,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
class ViewerKebabMenuButtonBuilder {
|
class ActionButtonBuilder {
|
||||||
static List<Widget> build(ViewerKebabMenuButtonContext context, BuildContext buildContext, WidgetRef ref) {
|
static const List<ActionButtonType> _actionTypes = ActionButtonType.values;
|
||||||
final visibleButtons = ViewerKebabMenuButtonType.values.where((type) => type.shouldShow(context)).toList();
|
static const List<ActionButtonType> defaultViewerKebabMenuOrder = _actionTypes;
|
||||||
|
static const Set<ActionButtonType> defaultViewerBottomBarButtons = {
|
||||||
|
ActionButtonType.share,
|
||||||
|
ActionButtonType.moveToLockFolder,
|
||||||
|
ActionButtonType.upload,
|
||||||
|
ActionButtonType.delete,
|
||||||
|
ActionButtonType.archive,
|
||||||
|
ActionButtonType.unarchive,
|
||||||
|
};
|
||||||
|
|
||||||
if (visibleButtons.isEmpty) return [];
|
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();
|
||||||
|
|
||||||
|
if (visibleButtons.isEmpty) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
final List<Widget> result = [];
|
final List<Widget> result = [];
|
||||||
int? lastGroup;
|
int? lastGroup;
|
||||||
|
|
||||||
for (final type in visibleButtons) {
|
for (final type in visibleButtons) {
|
||||||
if (lastGroup != null && type.group != lastGroup) {
|
if (lastGroup != null && type.kebabMenuGroup != lastGroup) {
|
||||||
result.add(const Divider(height: 1));
|
result.add(const Divider(height: 1));
|
||||||
}
|
}
|
||||||
result.add(type.buildButton(context, buildContext).build(buildContext, ref));
|
result.add(type.buildButton(context, buildContext, false, true).build(buildContext, ref));
|
||||||
lastGroup = type.group;
|
lastGroup = type.kebabMenuGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -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": {
|
||||||
|
|||||||
3733
pnpm-lock.yaml
generated
3733
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -69,7 +69,7 @@
|
|||||||
"compression": "^1.8.0",
|
"compression": "^1.8.0",
|
||||||
"cookie": "^1.0.2",
|
"cookie": "^1.0.2",
|
||||||
"cookie-parser": "^1.4.7",
|
"cookie-parser": "^1.4.7",
|
||||||
"cron": "4.3.3",
|
"cron": "4.3.5",
|
||||||
"exiftool-vendored": "^34.0.0",
|
"exiftool-vendored": "^34.0.0",
|
||||||
"express": "^5.1.0",
|
"express": "^5.1.0",
|
||||||
"fast-glob": "^3.3.2",
|
"fast-glob": "^3.3.2",
|
||||||
@@ -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",
|
||||||
|
|||||||
@@ -1034,7 +1034,10 @@ describe(MetadataService.name, () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should use Duration from exif', async () => {
|
it('should use Duration from exif', async () => {
|
||||||
mocks.assetJob.getForMetadataExtraction.mockResolvedValue(assetStub.image);
|
mocks.assetJob.getForMetadataExtraction.mockResolvedValue({
|
||||||
|
...assetStub.image,
|
||||||
|
originalPath: '/original/path.webp',
|
||||||
|
});
|
||||||
mockReadTags({ Duration: 123 }, {});
|
mockReadTags({ Duration: 123 }, {});
|
||||||
|
|
||||||
await sut.handleMetadataExtraction({ id: assetStub.image.id });
|
await sut.handleMetadataExtraction({ id: assetStub.image.id });
|
||||||
@@ -1046,6 +1049,7 @@ describe(MetadataService.name, () => {
|
|||||||
it('should prefer Duration from exif over sidecar', async () => {
|
it('should prefer Duration from exif over sidecar', async () => {
|
||||||
mocks.assetJob.getForMetadataExtraction.mockResolvedValue({
|
mocks.assetJob.getForMetadataExtraction.mockResolvedValue({
|
||||||
...assetStub.image,
|
...assetStub.image,
|
||||||
|
originalPath: '/original/path.webp',
|
||||||
files: [
|
files: [
|
||||||
{
|
{
|
||||||
id: 'some-id',
|
id: 'some-id',
|
||||||
@@ -1063,6 +1067,16 @@ describe(MetadataService.name, () => {
|
|||||||
expect(mocks.asset.update).toHaveBeenCalledWith(expect.objectContaining({ duration: '00:02:03.000' }));
|
expect(mocks.asset.update).toHaveBeenCalledWith(expect.objectContaining({ duration: '00:02:03.000' }));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should ignore all Duration tags for definitely static images', async () => {
|
||||||
|
mocks.assetJob.getForMetadataExtraction.mockResolvedValue(assetStub.imageDng);
|
||||||
|
mockReadTags({ Duration: 123 }, { Duration: 456 });
|
||||||
|
|
||||||
|
await sut.handleMetadataExtraction({ id: assetStub.imageDng.id });
|
||||||
|
|
||||||
|
expect(mocks.metadata.readTags).toHaveBeenCalledTimes(1);
|
||||||
|
expect(mocks.asset.update).toHaveBeenCalledWith(expect.objectContaining({ duration: null }));
|
||||||
|
});
|
||||||
|
|
||||||
it('should ignore Duration from exif for videos', async () => {
|
it('should ignore Duration from exif for videos', async () => {
|
||||||
mocks.assetJob.getForMetadataExtraction.mockResolvedValue(assetStub.video);
|
mocks.assetJob.getForMetadataExtraction.mockResolvedValue(assetStub.video);
|
||||||
mockReadTags({ Duration: 123 }, {});
|
mockReadTags({ Duration: 123 }, {});
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ import { BaseService } from 'src/services/base.service';
|
|||||||
import { JobItem, JobOf } from 'src/types';
|
import { JobItem, JobOf } from 'src/types';
|
||||||
import { getAssetFiles } from 'src/utils/asset.util';
|
import { getAssetFiles } from 'src/utils/asset.util';
|
||||||
import { isAssetChecksumConstraint } from 'src/utils/database';
|
import { isAssetChecksumConstraint } from 'src/utils/database';
|
||||||
|
import { mimeTypes } from 'src/utils/mime-types';
|
||||||
import { isFaceImportEnabled } from 'src/utils/misc';
|
import { isFaceImportEnabled } from 'src/utils/misc';
|
||||||
import { upsertTags } from 'src/utils/tag';
|
import { upsertTags } from 'src/utils/tag';
|
||||||
|
|
||||||
@@ -486,7 +487,8 @@ export class MetadataService extends BaseService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// prefer duration from video tags
|
// prefer duration from video tags
|
||||||
if (videoTags) {
|
// don't save duration if asset is definitely not an animated image (see e.g. CR3 with Duration: 1s)
|
||||||
|
if (videoTags || !mimeTypes.isPossiblyAnimatedImage(asset.originalPath)) {
|
||||||
delete mediaTags.Duration;
|
delete mediaTags.Duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -152,6 +152,26 @@ describe('mimeTypes', () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('animated image', () => {
|
||||||
|
for (const img of ['a.avif', 'a.gif', 'a.webp']) {
|
||||||
|
it('should identify animated image mime types as such', () => {
|
||||||
|
expect(mimeTypes.isPossiblyAnimatedImage(img)).toBeTruthy();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const img of ['a.cr3', 'a.jpg', 'a.tiff']) {
|
||||||
|
it('should identify static image mime types as such', () => {
|
||||||
|
expect(mimeTypes.isPossiblyAnimatedImage(img)).toBeFalsy();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const extension of Object.keys(mimeTypes.video)) {
|
||||||
|
it('should not identify video mime types as animated', () => {
|
||||||
|
expect(mimeTypes.isPossiblyAnimatedImage(extension)).toBeFalsy();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
describe('video', () => {
|
describe('video', () => {
|
||||||
it('should contain only lowercase mime types', () => {
|
it('should contain only lowercase mime types', () => {
|
||||||
const keys = Object.keys(mimeTypes.video);
|
const keys = Object.keys(mimeTypes.video);
|
||||||
|
|||||||
@@ -64,6 +64,11 @@ const image: Record<string, string[]> = {
|
|||||||
'.tiff': ['image/tiff'],
|
'.tiff': ['image/tiff'],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const possiblyAnimatedImageExtensions = new Set(['.avif', '.gif', '.heic', '.heif', '.jxl', '.png', '.webp']);
|
||||||
|
const possiblyAnimatedImage: Record<string, string[]> = Object.fromEntries(
|
||||||
|
Object.entries(image).filter(([key]) => possiblyAnimatedImageExtensions.has(key)),
|
||||||
|
);
|
||||||
|
|
||||||
const extensionOverrides: Record<string, string> = {
|
const extensionOverrides: Record<string, string> = {
|
||||||
'image/jpeg': '.jpg',
|
'image/jpeg': '.jpg',
|
||||||
};
|
};
|
||||||
@@ -119,6 +124,7 @@ export const mimeTypes = {
|
|||||||
isAsset: (filename: string) => isType(filename, image) || isType(filename, video),
|
isAsset: (filename: string) => isType(filename, image) || isType(filename, video),
|
||||||
isImage: (filename: string) => isType(filename, image),
|
isImage: (filename: string) => isType(filename, image),
|
||||||
isWebSupportedImage: (filename: string) => isType(filename, webSupportedImage),
|
isWebSupportedImage: (filename: string) => isType(filename, webSupportedImage),
|
||||||
|
isPossiblyAnimatedImage: (filename: string) => isType(filename, possiblyAnimatedImage),
|
||||||
isProfile: (filename: string) => isType(filename, profile),
|
isProfile: (filename: string) => isType(filename, profile),
|
||||||
isSidecar: (filename: string) => isType(filename, sidecar),
|
isSidecar: (filename: string) => isType(filename, sidecar),
|
||||||
isVideo: (filename: string) => isType(filename, video),
|
isVideo: (filename: string) => isType(filename, video),
|
||||||
|
|||||||
@@ -98,7 +98,7 @@
|
|||||||
"prettier-plugin-sort-json": "^4.1.1",
|
"prettier-plugin-sort-json": "^4.1.1",
|
||||||
"prettier-plugin-svelte": "^3.3.3",
|
"prettier-plugin-svelte": "^3.3.3",
|
||||||
"rollup-plugin-visualizer": "^6.0.0",
|
"rollup-plugin-visualizer": "^6.0.0",
|
||||||
"svelte": "5.45.5",
|
"svelte": "5.43.3",
|
||||||
"svelte-check": "^4.1.5",
|
"svelte-check": "^4.1.5",
|
||||||
"svelte-eslint-parser": "^1.3.3",
|
"svelte-eslint-parser": "^1.3.3",
|
||||||
"tailwindcss": "^4.1.7",
|
"tailwindcss": "^4.1.7",
|
||||||
|
|||||||
@@ -12,12 +12,14 @@
|
|||||||
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';
|
||||||
import type { AlbumResponseDto, SharedLinkResponseDto, UserResponseDto } from '@immich/sdk';
|
import type { AlbumResponseDto, SharedLinkResponseDto, UserResponseDto } from '@immich/sdk';
|
||||||
import { IconButton, Logo } from '@immich/ui';
|
import { IconButton, Logo } from '@immich/ui';
|
||||||
import { mdiDownload, mdiFileImagePlusOutline } from '@mdi/js';
|
import { mdiDownload, mdiFileImagePlusOutline, mdiPresentationPlay } from '@mdi/js';
|
||||||
import { t } from 'svelte-i18n';
|
import { t } from 'svelte-i18n';
|
||||||
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';
|
||||||
@@ -32,7 +34,8 @@
|
|||||||
|
|
||||||
const album = sharedLink.album as AlbumResponseDto;
|
const album = sharedLink.album as AlbumResponseDto;
|
||||||
|
|
||||||
let { isViewing: showAssetViewer } = assetViewingStore;
|
let { isViewing: showAssetViewer, setAssetId } = assetViewingStore;
|
||||||
|
let { slideshowState, slideshowNavigation } = slideshowStore;
|
||||||
|
|
||||||
const options = $derived({ albumId: album.id, order: album.order });
|
const options = $derived({ albumId: album.id, order: album.order });
|
||||||
let timelineManager = $state<TimelineManager>() as TimelineManager;
|
let timelineManager = $state<TimelineManager>() as TimelineManager;
|
||||||
@@ -45,6 +48,16 @@
|
|||||||
dragAndDropFilesStore.set({ isDragging: false, files: [] });
|
dragAndDropFilesStore.set({ isDragging: false, files: [] });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const handleStartSlideshow = async () => {
|
||||||
|
const asset =
|
||||||
|
$slideshowNavigation === SlideshowNavigation.Shuffle
|
||||||
|
? await timelineManager.getRandomAsset()
|
||||||
|
: timelineManager.months[0]?.dayGroups[0]?.viewerAssets[0]?.asset;
|
||||||
|
if (asset) {
|
||||||
|
handlePromiseError(setAssetId(asset.id).then(() => ($slideshowState = SlideshowState.PlaySlideshow)));
|
||||||
|
}
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:document
|
<svelte:document
|
||||||
@@ -98,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}
|
||||||
|
|
||||||
@@ -117,6 +130,14 @@
|
|||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{#if album.assetCount > 0 && sharedLink.allowDownload}
|
{#if album.assetCount > 0 && sharedLink.allowDownload}
|
||||||
|
<IconButton
|
||||||
|
shape="round"
|
||||||
|
variant="ghost"
|
||||||
|
color="secondary"
|
||||||
|
aria-label={$t('slideshow')}
|
||||||
|
onclick={handleStartSlideshow}
|
||||||
|
icon={mdiPresentationPlay}
|
||||||
|
/>
|
||||||
<IconButton
|
<IconButton
|
||||||
shape="round"
|
shape="round"
|
||||||
color="secondary"
|
color="secondary"
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
{#if downloadManager.isDownloading}
|
{#if downloadManager.isDownloading}
|
||||||
<div
|
<div
|
||||||
transition:fly={{ x: -100, duration: 350 }}
|
transition:fly={{ x: -100, duration: 350 }}
|
||||||
class="fixed bottom-10 start-2 max-h-67.5 w-79 rounded-2xl border dark:border-white/10 p-4 shadow-lg bg-subtle"
|
class="fixed bottom-10 start-2 max-h-67.5 w-79 z-60 rounded-2xl border dark:border-white/10 p-4 shadow-lg bg-subtle"
|
||||||
>
|
>
|
||||||
<Heading size="tiny">{$t('downloading')}</Heading>
|
<Heading size="tiny">{$t('downloading')}</Heading>
|
||||||
<div class="my-2 mb-2 flex max-h-50 flex-col overflow-y-auto text-sm">
|
<div class="my-2 mb-2 flex max-h-50 flex-col overflow-y-auto text-sm">
|
||||||
|
|||||||
@@ -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}
|
||||||
|
|
||||||
|
|||||||
@@ -79,10 +79,30 @@
|
|||||||
searchStore.isSearchEnabled = false;
|
searchStore.isSearchEnabled = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const buildSearchPayload = (term: string): SmartSearchDto | MetadataSearchDto => {
|
||||||
|
const searchType = getSearchType();
|
||||||
|
switch (searchType) {
|
||||||
|
case 'smart': {
|
||||||
|
return { query: term };
|
||||||
|
}
|
||||||
|
case 'metadata': {
|
||||||
|
return { originalFileName: term };
|
||||||
|
}
|
||||||
|
case 'description': {
|
||||||
|
return { description: term };
|
||||||
|
}
|
||||||
|
case 'ocr': {
|
||||||
|
return { ocr: term };
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
return { query: term };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const onHistoryTermClick = async (searchTerm: string) => {
|
const onHistoryTermClick = async (searchTerm: string) => {
|
||||||
value = searchTerm;
|
value = searchTerm;
|
||||||
const searchPayload = { query: searchTerm };
|
await handleSearch(buildSearchPayload(searchTerm));
|
||||||
await handleSearch(searchPayload);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const onFilterClick = async () => {
|
const onFilterClick = async () => {
|
||||||
@@ -112,29 +132,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
const onSubmit = () => {
|
const onSubmit = () => {
|
||||||
const searchType = getSearchType();
|
handlePromiseError(handleSearch(buildSearchPayload(value)));
|
||||||
let payload = {} as SmartSearchDto | MetadataSearchDto;
|
|
||||||
|
|
||||||
switch (searchType) {
|
|
||||||
case 'smart': {
|
|
||||||
payload = { query: value } as SmartSearchDto;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 'metadata': {
|
|
||||||
payload = { originalFileName: value } as MetadataSearchDto;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 'description': {
|
|
||||||
payload = { description: value } as MetadataSearchDto;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 'ocr': {
|
|
||||||
payload = { ocr: value } as MetadataSearchDto;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
handlePromiseError(handleSearch(payload));
|
|
||||||
saveSearchTerm(value);
|
saveSearchTerm(value);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -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">
|
||||||
225
web/src/lib/stores/ocr.svelte.spec.ts
Normal file
225
web/src/lib/stores/ocr.svelte.spec.ts
Normal file
@@ -0,0 +1,225 @@
|
|||||||
|
import { ocrManager, type OcrBoundingBox } from '$lib/stores/ocr.svelte';
|
||||||
|
import { getAssetOcr } from '@immich/sdk';
|
||||||
|
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
||||||
|
|
||||||
|
// Mock the SDK
|
||||||
|
vi.mock('@immich/sdk', () => ({
|
||||||
|
getAssetOcr: vi.fn(),
|
||||||
|
}));
|
||||||
|
|
||||||
|
const createMockOcrData = (overrides?: Partial<OcrBoundingBox>): OcrBoundingBox[] => [
|
||||||
|
{
|
||||||
|
id: '1',
|
||||||
|
assetId: 'asset-123',
|
||||||
|
x1: 0,
|
||||||
|
y1: 0,
|
||||||
|
x2: 100,
|
||||||
|
y2: 0,
|
||||||
|
x3: 100,
|
||||||
|
y3: 50,
|
||||||
|
x4: 0,
|
||||||
|
y4: 50,
|
||||||
|
boxScore: 0.95,
|
||||||
|
textScore: 0.98,
|
||||||
|
text: 'Hello World',
|
||||||
|
...overrides,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
describe('OcrManager', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
// Reset the singleton state before each test
|
||||||
|
ocrManager.clear();
|
||||||
|
vi.clearAllMocks();
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('initial state', () => {
|
||||||
|
it('should initialize with empty data', () => {
|
||||||
|
expect(ocrManager.data).toEqual([]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should initialize with showOverlay as false', () => {
|
||||||
|
expect(ocrManager.showOverlay).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should initialize with hasOcrData as false', () => {
|
||||||
|
expect(ocrManager.hasOcrData).toBe(false);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('getAssetOcr', () => {
|
||||||
|
it('should load OCR data for an asset', async () => {
|
||||||
|
const mockData = createMockOcrData();
|
||||||
|
vi.mocked(getAssetOcr).mockResolvedValue(mockData);
|
||||||
|
|
||||||
|
await ocrManager.getAssetOcr('asset-123');
|
||||||
|
|
||||||
|
expect(getAssetOcr).toHaveBeenCalledWith({ id: 'asset-123' });
|
||||||
|
expect(ocrManager.data).toEqual(mockData);
|
||||||
|
expect(ocrManager.hasOcrData).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should handle empty OCR data', async () => {
|
||||||
|
vi.mocked(getAssetOcr).mockResolvedValue([]);
|
||||||
|
|
||||||
|
await ocrManager.getAssetOcr('asset-456');
|
||||||
|
|
||||||
|
expect(ocrManager.data).toEqual([]);
|
||||||
|
expect(ocrManager.hasOcrData).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should reset the loader when previously cleared', async () => {
|
||||||
|
const mockData = createMockOcrData();
|
||||||
|
vi.mocked(getAssetOcr).mockResolvedValue(mockData);
|
||||||
|
|
||||||
|
// First clear
|
||||||
|
ocrManager.clear();
|
||||||
|
expect(ocrManager.data).toEqual([]);
|
||||||
|
|
||||||
|
// Then load new data
|
||||||
|
await ocrManager.getAssetOcr('asset-789');
|
||||||
|
|
||||||
|
expect(ocrManager.data).toEqual(mockData);
|
||||||
|
expect(ocrManager.hasOcrData).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should handle concurrent requests safely', async () => {
|
||||||
|
const firstData = createMockOcrData({ id: '1', text: 'First' });
|
||||||
|
const secondData = createMockOcrData({ id: '2', text: 'Second' });
|
||||||
|
|
||||||
|
vi.mocked(getAssetOcr)
|
||||||
|
.mockImplementationOnce(
|
||||||
|
() =>
|
||||||
|
new Promise((resolve) => {
|
||||||
|
setTimeout(() => resolve(firstData), 100);
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
.mockResolvedValueOnce(secondData);
|
||||||
|
|
||||||
|
// Start first request
|
||||||
|
const promise1 = ocrManager.getAssetOcr('asset-1');
|
||||||
|
// Start second request immediately (should wait for first to complete)
|
||||||
|
const promise2 = ocrManager.getAssetOcr('asset-2');
|
||||||
|
|
||||||
|
await Promise.all([promise1, promise2]);
|
||||||
|
|
||||||
|
// CancellableTask waits for first request, so second request is ignored
|
||||||
|
// The data should be from the first request that completed
|
||||||
|
expect(ocrManager.data).toEqual(firstData);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should handle errors gracefully', async () => {
|
||||||
|
const error = new Error('Network error');
|
||||||
|
vi.mocked(getAssetOcr).mockRejectedValue(error);
|
||||||
|
|
||||||
|
// The error should be handled by CancellableTask
|
||||||
|
await expect(ocrManager.getAssetOcr('asset-error')).resolves.not.toThrow();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('clear', () => {
|
||||||
|
it('should clear OCR data', async () => {
|
||||||
|
const mockData = createMockOcrData({ text: 'Test' });
|
||||||
|
vi.mocked(getAssetOcr).mockResolvedValue(mockData);
|
||||||
|
await ocrManager.getAssetOcr('asset-123');
|
||||||
|
|
||||||
|
ocrManager.clear();
|
||||||
|
|
||||||
|
expect(ocrManager.data).toEqual([]);
|
||||||
|
expect(ocrManager.hasOcrData).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should reset showOverlay to false', () => {
|
||||||
|
ocrManager.showOverlay = true;
|
||||||
|
|
||||||
|
ocrManager.clear();
|
||||||
|
|
||||||
|
expect(ocrManager.showOverlay).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should mark as cleared for next load', async () => {
|
||||||
|
const mockData = createMockOcrData({ text: 'Test' });
|
||||||
|
vi.mocked(getAssetOcr).mockResolvedValue(mockData);
|
||||||
|
|
||||||
|
ocrManager.clear();
|
||||||
|
await ocrManager.getAssetOcr('asset-123');
|
||||||
|
|
||||||
|
// Should successfully load after clear
|
||||||
|
expect(ocrManager.data).toEqual(mockData);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('toggleOcrBoundingBox', () => {
|
||||||
|
it('should toggle showOverlay from false to true', () => {
|
||||||
|
expect(ocrManager.showOverlay).toBe(false);
|
||||||
|
|
||||||
|
ocrManager.toggleOcrBoundingBox();
|
||||||
|
|
||||||
|
expect(ocrManager.showOverlay).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should toggle showOverlay from true to false', () => {
|
||||||
|
ocrManager.showOverlay = true;
|
||||||
|
|
||||||
|
ocrManager.toggleOcrBoundingBox();
|
||||||
|
|
||||||
|
expect(ocrManager.showOverlay).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should toggle multiple times', () => {
|
||||||
|
ocrManager.toggleOcrBoundingBox();
|
||||||
|
expect(ocrManager.showOverlay).toBe(true);
|
||||||
|
|
||||||
|
ocrManager.toggleOcrBoundingBox();
|
||||||
|
expect(ocrManager.showOverlay).toBe(false);
|
||||||
|
|
||||||
|
ocrManager.toggleOcrBoundingBox();
|
||||||
|
expect(ocrManager.showOverlay).toBe(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('hasOcrData derived state', () => {
|
||||||
|
it('should be false when data is empty', () => {
|
||||||
|
expect(ocrManager.hasOcrData).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be true when data is present', async () => {
|
||||||
|
const mockData = createMockOcrData({ text: 'Test' });
|
||||||
|
vi.mocked(getAssetOcr).mockResolvedValue(mockData);
|
||||||
|
await ocrManager.getAssetOcr('asset-123');
|
||||||
|
|
||||||
|
expect(ocrManager.hasOcrData).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should update when data is cleared', async () => {
|
||||||
|
const mockData = createMockOcrData({ text: 'Test' });
|
||||||
|
vi.mocked(getAssetOcr).mockResolvedValue(mockData);
|
||||||
|
await ocrManager.getAssetOcr('asset-123');
|
||||||
|
expect(ocrManager.hasOcrData).toBe(true);
|
||||||
|
|
||||||
|
ocrManager.clear();
|
||||||
|
expect(ocrManager.hasOcrData).toBe(false);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('data immutability', () => {
|
||||||
|
it('should return the same reference when data does not change', () => {
|
||||||
|
const firstReference = ocrManager.data;
|
||||||
|
const secondReference = ocrManager.data;
|
||||||
|
|
||||||
|
expect(firstReference).toBe(secondReference);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return a new reference when data changes', async () => {
|
||||||
|
const firstReference = ocrManager.data;
|
||||||
|
const mockData = createMockOcrData({ text: 'Test' });
|
||||||
|
|
||||||
|
vi.mocked(getAssetOcr).mockResolvedValue(mockData);
|
||||||
|
await ocrManager.getAssetOcr('asset-123');
|
||||||
|
|
||||||
|
const secondReference = ocrManager.data;
|
||||||
|
|
||||||
|
expect(firstReference).not.toBe(secondReference);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { CancellableTask } from '$lib/utils/cancellable-task';
|
||||||
import { getAssetOcr } from '@immich/sdk';
|
import { getAssetOcr } from '@immich/sdk';
|
||||||
|
|
||||||
export type OcrBoundingBox = {
|
export type OcrBoundingBox = {
|
||||||
@@ -20,6 +21,8 @@ class OcrManager {
|
|||||||
#data = $state<OcrBoundingBox[]>([]);
|
#data = $state<OcrBoundingBox[]>([]);
|
||||||
showOverlay = $state(false);
|
showOverlay = $state(false);
|
||||||
#hasOcrData = $derived(this.#data.length > 0);
|
#hasOcrData = $derived(this.#data.length > 0);
|
||||||
|
#ocrLoader = new CancellableTask();
|
||||||
|
#cleared = false;
|
||||||
|
|
||||||
get data() {
|
get data() {
|
||||||
return this.#data;
|
return this.#data;
|
||||||
@@ -30,10 +33,17 @@ class OcrManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getAssetOcr(id: string) {
|
async getAssetOcr(id: string) {
|
||||||
this.#data = await getAssetOcr({ id });
|
if (this.#cleared) {
|
||||||
|
await this.#ocrLoader.reset();
|
||||||
|
this.#cleared = false;
|
||||||
|
}
|
||||||
|
await this.#ocrLoader.execute(async () => {
|
||||||
|
this.#data = await getAssetOcr({ id });
|
||||||
|
}, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
clear() {
|
clear() {
|
||||||
|
this.#cleared = true;
|
||||||
this.#data = [];
|
this.#data = [];
|
||||||
this.showOverlay = false;
|
this.showOverlay = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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';
|
||||||
|
|||||||
Reference in New Issue
Block a user