mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-07-24 15:49:42 +02:00
fix: show copy to clipboard failure (#2886)
Some checks are pending
Docker Nightly Production / Backend Server Tests (push) Waiting to run
Docker Nightly Production / Frontend and End-to-End Tests (push) Waiting to run
Docker Nightly Production / Build Tagged Release (push) Blocked by required conditions
Docker Nightly Production / Notify Discord (push) Blocked by required conditions
Some checks are pending
Docker Nightly Production / Backend Server Tests (push) Waiting to run
Docker Nightly Production / Frontend and End-to-End Tests (push) Waiting to run
Docker Nightly Production / Build Tagged Release (push) Blocked by required conditions
Docker Nightly Production / Notify Discord (push) Blocked by required conditions
* 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:
parent
f6f9a1c532
commit
6a71af98bd
4 changed files with 55 additions and 18 deletions
|
@ -7,23 +7,30 @@ export function useCopy() {
|
|||
const { i18n } = useContext();
|
||||
|
||||
function copyText(text: string) {
|
||||
if (!isSupported) {
|
||||
if (!isSupported.value) {
|
||||
alert.error(i18n.tc("general.clipboard-not-supported"));
|
||||
return;
|
||||
}
|
||||
copy(text);
|
||||
alert.success(i18n.tc("general.copied-to-clipboard"));
|
||||
copy(text).then(() => {
|
||||
// Verify copy success as no error is thrown on failure.
|
||||
if (copied.value) {
|
||||
alert.success(i18n.tc("general.copied-to-clipboard"));
|
||||
}
|
||||
else {
|
||||
alert.error(i18n.tc("general.clipboard-copy-failure"));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return { copyText, copied };
|
||||
}
|
||||
|
||||
export function useCopyList() {
|
||||
const { copy, isSupported } = useClipboard();
|
||||
const { copy, isSupported, copied } = useClipboard();
|
||||
const { i18n } = useContext();
|
||||
|
||||
function checkClipboard() {
|
||||
if (!isSupported) {
|
||||
if (!isSupported.value) {
|
||||
alert.error(i18n.tc("general.your-browser-does-not-support-clipboard"));
|
||||
return false;
|
||||
}
|
||||
|
@ -54,7 +61,13 @@ export function useCopyList() {
|
|||
|
||||
function copyText(text: string, len: number) {
|
||||
copy(text).then(() => {
|
||||
alert.success(i18n.tc("general.copied-items-to-clipboard", len));
|
||||
// Verify copy success as no error is thrown on failure.
|
||||
if (copied.value) {
|
||||
alert.success(i18n.tc("general.copied-items-to-clipboard", len));
|
||||
}
|
||||
else {
|
||||
alert.error(i18n.tc("general.clipboard-copy-failure"));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue