Skip to content
This repository was archived by the owner on Jun 19, 2025. It is now read-only.

Commit c1fa5d0

Browse files
authored
Merge pull request #1375 from tidalcycles/jade/share_fat
Share fat URL
2 parents 694a22a + 372542d commit c1fa5d0

File tree

2 files changed

+49
-31
lines changed

2 files changed

+49
-31
lines changed

website/src/repl/components/Header.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export function Header({ context, embedded = false }) {
102102
<span> shuffle</span>
103103
</button>
104104
) */}
105-
{/* !isEmbedded && (
105+
{!isEmbedded && (
106106
<button
107107
title="share"
108108
className={cx(
@@ -113,7 +113,7 @@ export function Header({ context, embedded = false }) {
113113
>
114114
<span>share</span>
115115
</button>
116-
) */}
116+
)}
117117
{!isEmbedded && (
118118
<a
119119
title="learn"

website/src/repl/util.mjs

Lines changed: 47 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -109,38 +109,56 @@ export function confirmDialog(msg) {
109109
}
110110

111111
let lastShared;
112-
export async function shareCode(codeToShare) {
113-
// const codeToShare = activeCode || code;
114-
if (lastShared === codeToShare) {
115-
logger(`Link already generated!`, 'error');
116-
return;
117-
}
118112

119-
confirmDialog(
120-
'Do you want your pattern to be public? If no, press cancel and you will get just a private link.',
121-
).then(async (isPublic) => {
122-
const hash = nanoid(12);
123-
const shareUrl = window.location.origin + window.location.pathname + '?' + hash;
124-
const { error } = await supabase.from('code_v1').insert([{ code: codeToShare, hash, ['public']: isPublic }]);
125-
if (!error) {
126-
lastShared = codeToShare;
127-
// copy shareUrl to clipboard
128-
if (isTauri()) {
129-
await writeText(shareUrl);
130-
} else {
131-
await navigator.clipboard.writeText(shareUrl);
132-
}
133-
const message = `Link copied to clipboard: ${shareUrl}`;
134-
alert(message);
135-
// alert(message);
136-
logger(message, 'highlight');
113+
//RIP due to SPAM
114+
// export async function shareCode(codeToShare) {
115+
// // const codeToShare = activeCode || code;
116+
// if (lastShared === codeToShare) {
117+
// logger(`Link already generated!`, 'error');
118+
// return;
119+
// }
120+
121+
// confirmDialog(
122+
// 'Do you want your pattern to be public? If no, press cancel and you will get just a private link.',
123+
// ).then(async (isPublic) => {
124+
// const hash = nanoid(12);
125+
// const shareUrl = window.location.origin + window.location.pathname + '?' + hash;
126+
// const { error } = await supabase.from('code_v1').insert([{ code: codeToShare, hash, ['public']: isPublic }]);
127+
// if (!error) {
128+
// lastShared = codeToShare;
129+
// // copy shareUrl to clipboard
130+
// if (isTauri()) {
131+
// await writeText(shareUrl);
132+
// } else {
133+
// await navigator.clipboard.writeText(shareUrl);
134+
// }
135+
// const message = `Link copied to clipboard: ${shareUrl}`;
136+
// alert(message);
137+
// // alert(message);
138+
// logger(message, 'highlight');
139+
// } else {
140+
// console.log('error', error);
141+
// const message = `Error: ${error.message}`;
142+
// // alert(message);
143+
// logger(message);
144+
// }
145+
// });
146+
// }
147+
148+
export async function shareCode() {
149+
try {
150+
const shareUrl = window.location.href;
151+
if (isTauri()) {
152+
await writeText(shareUrl);
137153
} else {
138-
console.log('error', error);
139-
const message = `Error: ${error.message}`;
140-
// alert(message);
141-
logger(message);
154+
await navigator.clipboard.writeText(shareUrl);
142155
}
143-
});
156+
const message = `Link copied to clipboard!`;
157+
alert(message);
158+
logger(message, 'highlight');
159+
} catch (e) {
160+
console.error(e);
161+
}
144162
}
145163

146164
export const isIframe = () => window.location !== window.parent.location;

0 commit comments

Comments
 (0)