From 6a71af98bde8c69bdcc91b1c77cb1b7127560185 Mon Sep 17 00:00:00 2001 From: Kuchenpirat <24235032+Kuchenpirat@users.noreply.github.com> Date: Fri, 29 Dec 2023 16:48:28 +0100 Subject: [PATCH] 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> --- .../Domain/Recipe/RecipeDialogShare.vue | 16 ++++++++-- frontend/components/global/AppButtonCopy.vue | 29 ++++++++++++++----- frontend/composables/use-copy.ts | 25 ++++++++++++---- frontend/lang/messages/en-US.json | 3 +- 4 files changed, 55 insertions(+), 18 deletions(-) diff --git a/frontend/components/Domain/Recipe/RecipeDialogShare.vue b/frontend/components/Domain/Recipe/RecipeDialogShare.vue index d62ccfc9843c..f64aa341588b 100644 --- a/frontend/components/Domain/Recipe/RecipeDialogShare.vue +++ b/frontend/components/Domain/Recipe/RecipeDialogShare.vue @@ -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) { diff --git a/frontend/components/global/AppButtonCopy.vue b/frontend/components/global/AppButtonCopy.vue index 2f8fcf94bf11..09bbadcff47c 100644 --- a/frontend/components/global/AppButtonCopy.vue +++ b/frontend/components/global/AppButtonCopy.vue @@ -2,7 +2,7 @@ {{ $globals.icons.clipboardCheck }} - {{ $t("general.copied_message") }} + {{ $t("general.your-browser-does-not-support-clipboard") }} + {{ copied ? $t("general.copied_message") : $t("general.clipboard-copy-failure") }}