ask for public sharing (very cheap) + order browse list

This commit is contained in:
Felix Roos 2024-01-13 23:12:22 +01:00
parent 3c1844046a
commit 1ede99f71e
2 changed files with 17 additions and 4 deletions

View file

@ -90,10 +90,13 @@ export async function shareCode(codeToShare) {
logger(`Link already generated!`, 'error');
return;
}
const isPublic = confirm(
'Do you want your pattern to be public? If no, press cancel and you will get just a private link.',
);
// generate uuid in the browser
const hash = nanoid(12);
const shareUrl = window.location.origin + window.location.pathname + '?' + hash;
const { data, error } = await supabase.from('code').insert([{ code: codeToShare, hash }]);
const { error } = await supabase.from('code').insert([{ code: codeToShare, hash, ['public']: isPublic }]);
if (!error) {
lastShared = codeToShare;
// copy shareUrl to clipboard