commit
c1fa5d0855
2 changed files with 49 additions and 31 deletions
|
|
@ -102,7 +102,7 @@ export function Header({ context, embedded = false }) {
|
||||||
<span> shuffle</span>
|
<span> shuffle</span>
|
||||||
</button>
|
</button>
|
||||||
) */}
|
) */}
|
||||||
{/* !isEmbedded && (
|
{!isEmbedded && (
|
||||||
<button
|
<button
|
||||||
title="share"
|
title="share"
|
||||||
className={cx(
|
className={cx(
|
||||||
|
|
@ -113,7 +113,7 @@ export function Header({ context, embedded = false }) {
|
||||||
>
|
>
|
||||||
<span>share</span>
|
<span>share</span>
|
||||||
</button>
|
</button>
|
||||||
) */}
|
)}
|
||||||
{!isEmbedded && (
|
{!isEmbedded && (
|
||||||
<a
|
<a
|
||||||
title="learn"
|
title="learn"
|
||||||
|
|
|
||||||
|
|
@ -109,38 +109,56 @@ export function confirmDialog(msg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
let lastShared;
|
let lastShared;
|
||||||
export async function shareCode(codeToShare) {
|
|
||||||
// const codeToShare = activeCode || code;
|
|
||||||
if (lastShared === codeToShare) {
|
|
||||||
logger(`Link already generated!`, 'error');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
confirmDialog(
|
//RIP due to SPAM
|
||||||
'Do you want your pattern to be public? If no, press cancel and you will get just a private link.',
|
// export async function shareCode(codeToShare) {
|
||||||
).then(async (isPublic) => {
|
// // const codeToShare = activeCode || code;
|
||||||
const hash = nanoid(12);
|
// if (lastShared === codeToShare) {
|
||||||
const shareUrl = window.location.origin + window.location.pathname + '?' + hash;
|
// logger(`Link already generated!`, 'error');
|
||||||
const { error } = await supabase.from('code_v1').insert([{ code: codeToShare, hash, ['public']: isPublic }]);
|
// return;
|
||||||
if (!error) {
|
// }
|
||||||
lastShared = codeToShare;
|
|
||||||
// copy shareUrl to clipboard
|
// confirmDialog(
|
||||||
if (isTauri()) {
|
// 'Do you want your pattern to be public? If no, press cancel and you will get just a private link.',
|
||||||
await writeText(shareUrl);
|
// ).then(async (isPublic) => {
|
||||||
} else {
|
// const hash = nanoid(12);
|
||||||
await navigator.clipboard.writeText(shareUrl);
|
// const shareUrl = window.location.origin + window.location.pathname + '?' + hash;
|
||||||
}
|
// const { error } = await supabase.from('code_v1').insert([{ code: codeToShare, hash, ['public']: isPublic }]);
|
||||||
const message = `Link copied to clipboard: ${shareUrl}`;
|
// if (!error) {
|
||||||
alert(message);
|
// lastShared = codeToShare;
|
||||||
// alert(message);
|
// // copy shareUrl to clipboard
|
||||||
logger(message, 'highlight');
|
// if (isTauri()) {
|
||||||
|
// await writeText(shareUrl);
|
||||||
|
// } else {
|
||||||
|
// await navigator.clipboard.writeText(shareUrl);
|
||||||
|
// }
|
||||||
|
// const message = `Link copied to clipboard: ${shareUrl}`;
|
||||||
|
// alert(message);
|
||||||
|
// // alert(message);
|
||||||
|
// logger(message, 'highlight');
|
||||||
|
// } else {
|
||||||
|
// console.log('error', error);
|
||||||
|
// const message = `Error: ${error.message}`;
|
||||||
|
// // alert(message);
|
||||||
|
// logger(message);
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
|
||||||
|
export async function shareCode() {
|
||||||
|
try {
|
||||||
|
const shareUrl = window.location.href;
|
||||||
|
if (isTauri()) {
|
||||||
|
await writeText(shareUrl);
|
||||||
} else {
|
} else {
|
||||||
console.log('error', error);
|
await navigator.clipboard.writeText(shareUrl);
|
||||||
const message = `Error: ${error.message}`;
|
|
||||||
// alert(message);
|
|
||||||
logger(message);
|
|
||||||
}
|
}
|
||||||
});
|
const message = `Link copied to clipboard!`;
|
||||||
|
alert(message);
|
||||||
|
logger(message, 'highlight');
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const isIframe = () => window.location !== window.parent.location;
|
export const isIframe = () => window.location !== window.parent.location;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue