atom/ics link copy to clipboard: using in "GroupView" + "EditIdentity" + "NotificationsView" + "AboutInstanceView" - refactoring to use same mecanizem (Issue #1496)
This commit is contained in:
@@ -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}`;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user