mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-26 21:18:49 +00:00
ask for public sharing (very cheap) + order browse list
This commit is contained in:
parent
3c1844046a
commit
1ede99f71e
@ -8,7 +8,7 @@ function PatternLink({ pattern }: { pattern: Tables<'code'> }) {
|
|||||||
// console.log('meta', meta);
|
// console.log('meta', meta);
|
||||||
return (
|
return (
|
||||||
<a href={`/?${pattern.hash}`} target="_blank">
|
<a href={`/?${pattern.hash}`} target="_blank">
|
||||||
{meta.title || pattern.hash} by {meta.by.join(',') || 'Anonymous'}
|
{pattern.id}. {meta.title || pattern.hash} by {meta.by.join(',') || 'Anonymous'}
|
||||||
</a>
|
</a>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -21,8 +21,18 @@ export function SharedPatterns() {
|
|||||||
'https://pidxdsxphlhzjnzmifth.supabase.co',
|
'https://pidxdsxphlhzjnzmifth.supabase.co',
|
||||||
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InBpZHhkc3hwaGxoempuem1pZnRoIiwicm9sZSI6ImFub24iLCJpYXQiOjE2NTYyMzA1NTYsImV4cCI6MTk3MTgwNjU1Nn0.bqlw7802fsWRnqU5BLYtmXk_k-D1VFmbkHMywWc15NM',
|
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InBpZHhkc3hwaGxoempuem1pZnRoIiwicm9sZSI6ImFub24iLCJpYXQiOjE2NTYyMzA1NTYsImV4cCI6MTk3MTgwNjU1Nn0.bqlw7802fsWRnqU5BLYtmXk_k-D1VFmbkHMywWc15NM',
|
||||||
);
|
);
|
||||||
const { data: _publicPatterns } = await supabase.from('code').select().eq('public', true).limit(20);
|
const { data: _publicPatterns } = await supabase
|
||||||
const { data: _featuredPatterns } = await supabase.from('code').select().eq('featured', true).limit(20);
|
.from('code')
|
||||||
|
.select()
|
||||||
|
.eq('public', true)
|
||||||
|
.limit(20)
|
||||||
|
.order('id', { ascending: false });
|
||||||
|
const { data: _featuredPatterns } = await supabase
|
||||||
|
.from('code')
|
||||||
|
.select()
|
||||||
|
.eq('featured', true)
|
||||||
|
.limit(20)
|
||||||
|
.order('id', { ascending: false });
|
||||||
setPublicPatterns(_publicPatterns);
|
setPublicPatterns(_publicPatterns);
|
||||||
setFeaturedPatterns(_featuredPatterns);
|
setFeaturedPatterns(_featuredPatterns);
|
||||||
/* console.log('public', publicPatterns);
|
/* console.log('public', publicPatterns);
|
||||||
|
|||||||
@ -90,10 +90,13 @@ export async function shareCode(codeToShare) {
|
|||||||
logger(`Link already generated!`, 'error');
|
logger(`Link already generated!`, 'error');
|
||||||
return;
|
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
|
// generate uuid in the browser
|
||||||
const hash = nanoid(12);
|
const hash = nanoid(12);
|
||||||
const shareUrl = window.location.origin + window.location.pathname + '?' + hash;
|
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) {
|
if (!error) {
|
||||||
lastShared = codeToShare;
|
lastShared = codeToShare;
|
||||||
// copy shareUrl to clipboard
|
// copy shareUrl to clipboard
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user