mirror of
https://github.com/immich-app/immich.git
synced 2025-07-09 03:04:16 -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_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_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_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_count": "{count, plural, one {# asset} other {# assets}}",
|
||||||
"assets_deleted_permanently": "{count} asset(s) deleted permanently",
|
"assets_deleted_permanently": "{count} asset(s) deleted permanently",
|
||||||
"assets_deleted_permanently_from_server": "{count} asset(s) deleted permanently from the Immich server",
|
"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,
|
key: authManager.key,
|
||||||
});
|
});
|
||||||
const count = result.filter(({ success }) => success).length;
|
const count = result.filter(({ success }) => success).length;
|
||||||
|
const duplicateErrorCount = result.filter(({ error }) => error === 'duplicate').length;
|
||||||
const $t = get(t);
|
const $t = get(t);
|
||||||
|
|
||||||
if (showNotification) {
|
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({
|
notificationController.show({
|
||||||
type: NotificationType.Info,
|
type: NotificationType.Info,
|
||||||
timeout: 5000,
|
timeout: 5000,
|
||||||
message:
|
message,
|
||||||
count > 0
|
|
||||||
? $t('assets_added_to_album_count', { values: { count } })
|
|
||||||
: $t('assets_were_part_of_album_count', { values: { count: assetIds.length } }),
|
|
||||||
button: {
|
button: {
|
||||||
text: $t('view_album'),
|
text: $t('view_album'),
|
||||||
onClick() {
|
onClick() {
|
||||||
@ -125,23 +129,37 @@ export const addAssetsToNewAlbum = async (albumName: string, assetIds: string[])
|
|||||||
}
|
}
|
||||||
const $t = get(t);
|
const $t = get(t);
|
||||||
// for reasons beyond me <ComponentProps<typeof FormatBoldMessage>> doesn't work, even though it's (afaik) exactly this object
|
// for reasons beyond me <ComponentProps<typeof FormatBoldMessage>> doesn't work, even though it's (afaik) exactly this object
|
||||||
notificationController.show<{ key: Translations; values: InterpolationValues }>({
|
if (album.assets.length === 0) {
|
||||||
type: NotificationType.Info,
|
notificationController.show({
|
||||||
timeout: 5000,
|
type: NotificationType.Info,
|
||||||
component: {
|
timeout: 5000,
|
||||||
type: FormatBoldMessage,
|
message: $t('assets_cannot_be_added_to_album_count', { values: { count: assetIds.length } }),
|
||||||
props: {
|
button: {
|
||||||
key: 'assets_added_to_name_count',
|
text: $t('view_album'),
|
||||||
values: { count: assetIds.length, name: albumName, hasName: !!albumName },
|
onClick() {
|
||||||
|
return goto(`${AppRoute.ALBUMS}/${album.id}`);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
});
|
||||||
button: {
|
} else {
|
||||||
text: $t('view_album'),
|
notificationController.show<{ key: Translations; values: InterpolationValues }>({
|
||||||
onClick() {
|
type: NotificationType.Info,
|
||||||
return goto(`${AppRoute.ALBUMS}/${album.id}`);
|
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;
|
return album;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user