mirror of
https://github.com/immich-app/immich.git
synced 2025-07-08 18:54:18 -04:00
fix(web): Update add to album notification to better announce errors (#18955)
* Update add to album notification to better announce errors * fix i18n --------- Co-authored-by: wuzihao051119 <wuzihao051119@outlook.com>
This commit is contained in:
parent
b557f3b7f2
commit
737fedd527
@ -463,6 +463,7 @@
|
||||
"assets_added_count": "Added {count, plural, one {# asset} other {# assets}}",
|
||||
"assets_added_to_album_count": "Added {count, plural, one {# asset} other {# assets}} to the album",
|
||||
"assets_added_to_name_count": "Added {count, plural, one {# asset} other {# assets}} to {hasName, select, true {<b>{name}</b>} other {new album}}",
|
||||
"assets_cannot_be_added_to_album_count": "{count, plural, one {Asset} other {Assets}} cannot be added to the album",
|
||||
"assets_count": "{count, plural, one {# asset} other {# assets}}",
|
||||
"assets_deleted_permanently": "{count} asset(s) deleted permanently",
|
||||
"assets_deleted_permanently_from_server": "{count} asset(s) deleted permanently from the Immich server",
|
||||
|
@ -52,16 +52,20 @@ export const addAssetsToAlbum = async (albumId: string, assetIds: string[], show
|
||||
key: authManager.key,
|
||||
});
|
||||
const count = result.filter(({ success }) => success).length;
|
||||
const duplicateErrorCount = result.filter(({ error }) => error === 'duplicate').length;
|
||||
const $t = get(t);
|
||||
|
||||
if (showNotification) {
|
||||
let message = $t('assets_cannot_be_added_to_album_count', { values: { count: assetIds.length } });
|
||||
if (count > 0) {
|
||||
message = $t('assets_added_to_album_count', { values: { count } });
|
||||
} else if (duplicateErrorCount > 0) {
|
||||
message = $t('assets_were_part_of_album_count', { values: { count: duplicateErrorCount } });
|
||||
}
|
||||
notificationController.show({
|
||||
type: NotificationType.Info,
|
||||
timeout: 5000,
|
||||
message:
|
||||
count > 0
|
||||
? $t('assets_added_to_album_count', { values: { count } })
|
||||
: $t('assets_were_part_of_album_count', { values: { count: assetIds.length } }),
|
||||
message,
|
||||
button: {
|
||||
text: $t('view_album'),
|
||||
onClick() {
|
||||
@ -125,23 +129,37 @@ export const addAssetsToNewAlbum = async (albumName: string, assetIds: string[])
|
||||
}
|
||||
const $t = get(t);
|
||||
// for reasons beyond me <ComponentProps<typeof FormatBoldMessage>> doesn't work, even though it's (afaik) exactly this object
|
||||
notificationController.show<{ key: Translations; values: InterpolationValues }>({
|
||||
type: NotificationType.Info,
|
||||
timeout: 5000,
|
||||
component: {
|
||||
type: FormatBoldMessage,
|
||||
props: {
|
||||
key: 'assets_added_to_name_count',
|
||||
values: { count: assetIds.length, name: albumName, hasName: !!albumName },
|
||||
if (album.assets.length === 0) {
|
||||
notificationController.show({
|
||||
type: NotificationType.Info,
|
||||
timeout: 5000,
|
||||
message: $t('assets_cannot_be_added_to_album_count', { values: { count: assetIds.length } }),
|
||||
button: {
|
||||
text: $t('view_album'),
|
||||
onClick() {
|
||||
return goto(`${AppRoute.ALBUMS}/${album.id}`);
|
||||
},
|
||||
},
|
||||
},
|
||||
button: {
|
||||
text: $t('view_album'),
|
||||
onClick() {
|
||||
return goto(`${AppRoute.ALBUMS}/${album.id}`);
|
||||
});
|
||||
} else {
|
||||
notificationController.show<{ key: Translations; values: InterpolationValues }>({
|
||||
type: NotificationType.Info,
|
||||
timeout: 5000,
|
||||
component: {
|
||||
type: FormatBoldMessage,
|
||||
props: {
|
||||
key: 'assets_added_to_name_count',
|
||||
values: { count: album.assets.length, name: albumName, hasName: !!albumName },
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
button: {
|
||||
text: $t('view_album'),
|
||||
onClick() {
|
||||
return goto(`${AppRoute.ALBUMS}/${album.id}`);
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
return album;
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user