-
-
Notifications
You must be signed in to change notification settings - Fork 22
fix: Choose Avatar responsive on mobile (Fixes #35) #44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,36 +1,52 @@ | ||
| import { createClient } from '@supabase/supabase-js'; | ||
| import { createClient, SupabaseClient } from '@supabase/supabase-js'; | ||
|
|
||
| const supabaseUrl = import.meta.env.VITE_SUPABASE_URL!; | ||
| const supabaseAnonKey = import.meta.env.VITE_SUPABASE_ANON_KEY!; | ||
| const supabaseUrl = import.meta.env.VITE_SUPABASE_URL ?? ''; | ||
| const supabaseAnonKey = import.meta.env.VITE_SUPABASE_ANON_KEY ?? ''; | ||
|
|
||
| export const supabase = createClient(supabaseUrl, supabaseAnonKey); | ||
| export const supabase: SupabaseClient = | ||
| supabaseUrl && supabaseAnonKey | ||
| ? createClient(supabaseUrl, supabaseAnonKey) | ||
| : (null as unknown as SupabaseClient); | ||
|
|
||
| // Helper to get current session | ||
| export async function getSession() { | ||
| const { data: { session } } = await supabase.auth.getSession(); | ||
| return session; | ||
| if (!supabase) return null; | ||
| try { | ||
| const { data: { session } } = await supabase.auth.getSession(); | ||
| return session; | ||
| } catch { | ||
| return null; | ||
| } | ||
| } | ||
|
|
||
| // Helper to get current user | ||
| export async function getCurrentUser() { | ||
| if (!supabase) return null; | ||
| const { data: { user } } = await supabase.auth.getUser(); | ||
| return user; | ||
| } | ||
|
|
||
| // Helper to sign in anonymously | ||
| export async function signInAnonymously() { | ||
| if (!supabase) { | ||
| return { data: null, error: { message: 'Supabase not configured. Add VITE_SUPABASE_URL and VITE_SUPABASE_ANON_KEY to .env' } as any }; | ||
| } | ||
|
Comment on lines
+31
to
+33
|
||
| const { data, error } = await supabase.auth.signInAnonymously(); | ||
| return { data, error }; | ||
| } | ||
|
|
||
| // Helper to sign out | ||
| export async function signOut() { | ||
| if (!supabase) return { error: null }; | ||
| const { error } = await supabase.auth.signOut(); | ||
| return { error }; | ||
| } | ||
|
|
||
| // Helper to create user profile | ||
| export async function createProfile(userId: string, nickname: string, avatar: string) { | ||
| if (!supabase) { | ||
| return { data: null, error: { message: 'Supabase not configured' } as any }; | ||
| } | ||
| const { data, error } = await supabase | ||
| .from('profiles') | ||
| .insert({ | ||
|
|
@@ -46,6 +62,7 @@ export async function createProfile(userId: string, nickname: string, avatar: st | |
|
|
||
| // Helper to get user profile | ||
| export async function getProfile(userId: string) { | ||
| if (!supabase) return { data: null, error: { message: 'Supabase not configured' } as any }; | ||
| const { data, error } = await supabase | ||
| .from('profiles') | ||
| .select('*') | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -11,10 +11,14 @@ export default function Home() { | |||||||||||||||||||||||||||||||
| }, []); | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| async function checkSession() { | ||||||||||||||||||||||||||||||||
| const session = await getSession(); | ||||||||||||||||||||||||||||||||
| if (session) { | ||||||||||||||||||||||||||||||||
| navigate('/dashboard'); | ||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||
| const session = await getSession(); | ||||||||||||||||||||||||||||||||
| if (session) { | ||||||||||||||||||||||||||||||||
| navigate('/dashboard'); | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| } catch { | ||||||||||||||||||||||||||||||||
| // ignore | ||||||||||||||||||||||||||||||||
| } finally { | ||||||||||||||||||||||||||||||||
| setLoading(false); | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
Comment on lines
+14
to
23
|
||||||||||||||||||||||||||||||||
| try { | |
| const session = await getSession(); | |
| if (session) { | |
| navigate('/dashboard'); | |
| } | |
| } catch { | |
| // ignore | |
| } finally { | |
| setLoading(false); | |
| } | |
| const session = await getSession(); | |
| if (session) { | |
| navigate('/dashboard'); | |
| } | |
| setLoading(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
supabaseis exported asSupabaseClientbut can benullat runtime via(null as unknown as SupabaseClient). This defeats strict null-safety and can lead to runtime crashes in code that usessupabasedirectly (e.g.,frontend/src/lib/api.tscallssupabase.auth.getSession()without a guard). Prefer exportingsupabaseasSupabaseClient | null(orundefined) and updating call sites/helpers to handle the unconfigured case explicitly (or provide a safe stub implementation).