mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
fix(ui): fix copying image link
This commit is contained in:
parent
7bfb5640ad
commit
fcf9c63049
@ -553,6 +553,7 @@
|
||||
"downloadImageStarted": "Image Download Started",
|
||||
"imageCopied": "Image Copied",
|
||||
"imageLinkCopied": "Image Link Copied",
|
||||
"problemCopyingImageLink": "Unable to Copy Image Link",
|
||||
"imageNotLoaded": "No Image Loaded",
|
||||
"imageNotLoadedDesc": "Could not find image",
|
||||
"imageSavedToGallery": "Image Saved to Gallery",
|
||||
|
@ -184,13 +184,32 @@ const CurrentImageButtons = (props: CurrentImageButtonsProps) => {
|
||||
// }, [getUrl, t, image?.url, toast]);
|
||||
|
||||
const handleCopyImageLink = useCallback(() => {
|
||||
const url = image
|
||||
? shouldTransformUrls
|
||||
? getUrl(image.url)
|
||||
: window.location.toString() + image.url
|
||||
: '';
|
||||
const getImageUrl = () => {
|
||||
if (!image) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (shouldTransformUrls) {
|
||||
return getUrl(image.url);
|
||||
}
|
||||
|
||||
if (image.url.startsWith('http')) {
|
||||
return image.url;
|
||||
}
|
||||
|
||||
return window.location.toString() + image.url;
|
||||
};
|
||||
|
||||
const url = getImageUrl();
|
||||
|
||||
if (!url) {
|
||||
toast({
|
||||
title: t('toast.problemCopyingImageLink'),
|
||||
status: 'error',
|
||||
duration: 2500,
|
||||
isClosable: true,
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user