fix: show copy to clipboard failure (#2886)

* fix for AppButtonCopy

* add some logging

* fix if statement

* refactor, use .then

* check for copied

* Fix recipe share link

* refactor AppButtonCopy

* update tooltip text

* update use-copy

* logging

* fix is supported check

* more fixes for use-copy.ts

---------

Co-authored-by: Michael Genson <71845777+michael-genson@users.noreply.github.com>
This commit is contained in:
Kuchenpirat 2023-12-29 16:48:28 +01:00 committed by GitHub
commit 6a71af98bd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 55 additions and 18 deletions

View file

@ -143,7 +143,7 @@ export default defineComponent({
}
const { share, isSupported: shareIsSupported } = useShare();
const { copy } = useClipboard();
const { copy, copied, isSupported } = useClipboard();
function getRecipeText() {
return i18n.t("recipe.share-recipe-message", [props.name]);
@ -154,8 +154,18 @@ export default defineComponent({
}
async function copyTokenLink(token: string) {
await copy(getTokenLink(token));
alert.success(i18n.t("recipe-share.recipe-link-copied-message") as string);
if (isSupported.value) {
await copy(getTokenLink(token));
if (copied.value) {
alert.success(i18n.t("recipe-share.recipe-link-copied-message") as string);
}
else {
alert.error(i18n.t("general.clipboard-copy-failure") as string);
}
}
else {
alert.error(i18n.t("general.clipboard-not-supported") as string);
}
}
async function shareRecipe(token: string) {