atom/ics link copy to clipboard: using in "GroupView" + "EditIdentity" + "NotificationsView" + "AboutInstanceView" - refactoring to use same mecanizem (Issue #1496)

This commit is contained in:
Laurent GAY
2025-07-30 17:29:19 +02:00
committed by setop
parent b339de8815
commit 35b73eb20c
5 changed files with 141 additions and 59 deletions

View File

@@ -1,3 +1,5 @@
import { reactive } from "vue";
export const twitterShareUrl = (
url: string | undefined,
text: string | undefined
@@ -75,6 +77,32 @@ export const mastodonShareUrl = (
)}`;
};
export const showCopiedTooltip = reactive({ ics: false, atom: false });
export const initCopiedTooltipShow = (): void => {
showCopiedTooltip.ics = false;
showCopiedTooltip.atom = false;
};
export const tokenToURL = (subURL: string): string => {
return `${window.location.origin}/${subURL}`;
};
export const copyURL = (
e: Event,
url: string,
format: "ics" | "atom"
): void => {
if (navigator.clipboard) {
e.preventDefault();
navigator.clipboard.writeText(url);
showCopiedTooltip[format] = true;
setTimeout(() => {
showCopiedTooltip[format] = false;
}, 2000);
}
};
const basicTextToEncode = (url: string, text: string): string => {
return `${text}\r\n${url}`;
};