diff --git a/package-lock.json b/package-lock.json index 50c426d57..962cbe403 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,7 @@ "dependencies": { "@fontsource/fira-code": "^5.0.5", "@iconify/svelte": "^2.2.1", - "@primocms/builder": "^0.1.13", + "@primocms/builder": "^0.1.14", "@rollup/browser": "^3.28.0", "@supabase/auth-helpers-sveltekit": "^0.10.2", "@supabase/supabase-js": "^2.31.0", @@ -1223,9 +1223,9 @@ } }, "node_modules/@primocms/builder": { - "version": "0.1.13", - "resolved": "https://registry.npmjs.org/@primocms/builder/-/builder-0.1.13.tgz", - "integrity": "sha512-OHeo0zP0L+Bale4Mhve7Ek03wCe52mXys4/PnMcCWW5WQLd+FdqII12mxgkjCZLMsxBIQPHy+8Re3NVtcR0ZVA==", + "version": "0.1.14", + "resolved": "https://registry.npmjs.org/@primocms/builder/-/builder-0.1.14.tgz", + "integrity": "sha512-gw7BWt3LnIFyC6kT5GWIB9JQEKACK4Zt0GNb/I03vHI2mcWrR6ahffs3X1LfYUmkhmS58dGuh6rgc7GYzp23wg==", "peerDependencies": { "@codemirror/autocomplete": "^6.1.0", "@codemirror/commands": "^6.0.1", @@ -7374,9 +7374,9 @@ "peer": true }, "@primocms/builder": { - "version": "0.1.13", - "resolved": "https://registry.npmjs.org/@primocms/builder/-/builder-0.1.13.tgz", - "integrity": "sha512-OHeo0zP0L+Bale4Mhve7Ek03wCe52mXys4/PnMcCWW5WQLd+FdqII12mxgkjCZLMsxBIQPHy+8Re3NVtcR0ZVA==", + "version": "0.1.14", + "resolved": "https://registry.npmjs.org/@primocms/builder/-/builder-0.1.14.tgz", + "integrity": "sha512-gw7BWt3LnIFyC6kT5GWIB9JQEKACK4Zt0GNb/I03vHI2mcWrR6ahffs3X1LfYUmkhmS58dGuh6rgc7GYzp23wg==", "requires": {} }, "@remirror/core-constants": { diff --git a/package.json b/package.json index a88831427..94fcfcdae 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "dependencies": { "@fontsource/fira-code": "^5.0.5", "@iconify/svelte": "^2.2.1", - "@primocms/builder": "^0.1.13", + "@primocms/builder": "^0.1.14", "@rollup/browser": "^3.28.0", "@supabase/auth-helpers-sveltekit": "^0.10.2", "@supabase/supabase-js": "^2.31.0", diff --git a/src/routes/+layout.js b/src/routes/+layout.js index 9a7941bf7..f7ff46c31 100644 --- a/src/routes/+layout.js +++ b/src/routes/+layout.js @@ -1,4 +1,7 @@ -import { PUBLIC_SUPABASE_PUBLIC_KEY, PUBLIC_SUPABASE_URL } from '$env/static/public' +import { + PUBLIC_SUPABASE_PUBLIC_KEY, + PUBLIC_SUPABASE_URL, +} from '$env/static/public' import { createSupabaseLoadClient } from '@supabase/auth-helpers-sveltekit' import { redirect } from '@sveltejs/kit' @@ -13,49 +16,62 @@ export async function load(event) { event: { fetch }, serverSession: event?.data?.session, }) - const { data: { session } } = await supabase.auth.getSession() + const { + data: { session }, + } = await supabase.auth.getSession() if (!session && !event.url.pathname.startsWith('/auth')) { throw redirect(303, '/auth') } else if (session) { - // const site = event.params['site'] + // const site = event.params['site'] const { sites, user } = await Promise.all([ - supabase.from('sites').select('id, name, url, active_deployment, collaborators (*)').order('created_at', { ascending: true }), - supabase.from('users').select('*, server_members (admin, role), collaborators (role)').eq('id', session.user.id).single() + supabase + .from('sites') + .select('id, name, url, active_deployment, collaborators (*)') + .order('created_at', { ascending: true }), + supabase + .from('users') + .select('*, server_members (admin, role), collaborators (role)') + .eq('id', session.user.id) + .single(), ]).then(([{ data: sites }, { data: user }]) => { - const [server_member] = user.server_members const [collaborator] = user.collaborators - const user_final = server_member ? { - ...user, - server_member: true, - admin: server_member.admin, - role: server_member.role, - } : { - ...user, - server_member: false, - admin: false, - role: collaborator.role, - } + const user_final = server_member + ? { + ...user, + server_member: true, + admin: server_member.admin, + role: server_member.role, + } + : { + ...user, + server_member: false, + admin: false, + role: collaborator.role, + } return { sites: sites || [], - user: user_final + user: user_final, } }) // TODO: do this w/ sql - const user_sites = sites?.filter(site => - /*user is server member*/ user.server_member || - /*user is site collaborator*/ site.collaborators.some(collaborator => collaborator.user === user.id) + const user_sites = sites?.filter( + (site) => + /*user is server member*/ user.server_member || + /*user is site collaborator*/ site.collaborators.some( + (collaborator) => collaborator.user === user.id + ) ) return { supabase, session, user, - sites: user_sites + sites: user_sites, } } -} \ No newline at end of file +} diff --git a/src/routes/[site]/+layout.svelte b/src/routes/[site]/+layout.svelte index 18f72395b..8731a6e04 100644 --- a/src/routes/[site]/+layout.svelte +++ b/src/routes/[site]/+layout.svelte @@ -107,11 +107,11 @@ storage_subscribe(async ({ bucket, action, key, file, options }) => { if (action === 'upload') { - const { data } = await supabase.storage - .from(bucket) - .upload(key, file, options) - const { data: res } = supabase.storage.from('images').getPublicUrl(key) - return res.publicUrl + await supabase.storage.from(bucket).upload(key, file, options) + if (bucket === 'images') { + const { data: res } = supabase.storage.from(bucket).getPublicUrl(key) + return res.publicUrl + } } })