diff options
| -rw-r--r-- | apps/web/app/api/account/data/route.ts | 3 | ||||
| -rw-r--r-- | apps/web/app/api/export/route.ts | 2 | ||||
| -rw-r--r-- | apps/web/app/reader/settings/_components/account-settings.tsx | 13 | ||||
| -rw-r--r-- | apps/web/lib/queries/use-user-profile.ts | 4 | ||||
| -rw-r--r-- | supabase/schema.sql | 9 |
5 files changed, 12 insertions, 19 deletions
diff --git a/apps/web/app/api/account/data/route.ts b/apps/web/app/api/account/data/route.ts index 20a7b8c..e2566ba 100644 --- a/apps/web/app/api/account/data/route.ts +++ b/apps/web/app/api/account/data/route.ts @@ -30,7 +30,7 @@ export async function GET() { ] = await Promise.all([ supabaseClient .from("user_profiles") - .select("id, display_name, tier, created_at") + .select("id, tier, created_at") .eq("id", user.id) .single(), supabaseClient @@ -76,6 +76,7 @@ export async function GET() { exportedAt: new Date().toISOString(), account: { emailAddress: user.email, + displayName: user.user_metadata?.display_name ?? null, ...profileResult.data, }, subscriptions: subscriptionsResult.data ?? [], diff --git a/apps/web/app/api/export/route.ts b/apps/web/app/api/export/route.ts index dff7582..65a4327 100644 --- a/apps/web/app/api/export/route.ts +++ b/apps/web/app/api/export/route.ts @@ -19,7 +19,7 @@ export async function GET() { const { data: profile } = await supabaseClient .from("user_profiles") - .select("tier, display_name") + .select("tier") .eq("id", user.id) .single() diff --git a/apps/web/app/reader/settings/_components/account-settings.tsx b/apps/web/app/reader/settings/_components/account-settings.tsx index 9679e3b..298d80d 100644 --- a/apps/web/app/reader/settings/_components/account-settings.tsx +++ b/apps/web/app/reader/settings/_components/account-settings.tsx @@ -39,16 +39,9 @@ export function AccountSettings() { const updateDisplayName = useMutation({ mutationFn: async (displayName: string | null) => { - const { - data: { user }, - } = await supabaseClient.auth.getUser() - - if (!user) throw new Error("not authenticated") - - const { error } = await supabaseClient - .from("user_profiles") - .update({ display_name: displayName }) - .eq("id", user.id) + const { error } = await supabaseClient.auth.updateUser({ + data: { display_name: displayName }, + }) if (error) throw error }, diff --git a/apps/web/lib/queries/use-user-profile.ts b/apps/web/lib/queries/use-user-profile.ts index 49c1c4e..854d4a8 100644 --- a/apps/web/lib/queries/use-user-profile.ts +++ b/apps/web/lib/queries/use-user-profile.ts @@ -20,7 +20,7 @@ export function useUserProfile() { const { data, error } = await supabaseClient .from("user_profiles") .select( - "id, display_name, tier, feed_count, folder_count, muted_keyword_count, custom_feed_count, stripe_subscription_status, stripe_current_period_end" + "id, tier, feed_count, folder_count, muted_keyword_count, custom_feed_count, stripe_subscription_status, stripe_current_period_end" ) .eq("id", user.id) .single() @@ -30,7 +30,7 @@ export function useUserProfile() { const profile: UserProfile = { identifier: data.id, email: user.email ?? null, - displayName: data.display_name, + displayName: (user.user_metadata?.display_name as string) ?? null, tier: data.tier, feedCount: data.feed_count, folderCount: data.folder_count, diff --git a/supabase/schema.sql b/supabase/schema.sql index f75fe9e..828ffc6 100644 --- a/supabase/schema.sql +++ b/supabase/schema.sql @@ -2,7 +2,7 @@ -- PostgreSQL database dump -- --- \restrict 3Un8h9VlAyPuVfPugYV7LM7XGnkxI3KC1nPU1aarC0scGxlDzBQB81bgO7tvPsv +-- \restrict x5c7hoIeZadeb9vWOL0aN2XhOidKEkcJTCLPxElLQoDi4K0JeM3w2RYCHdK42ij -- Dumped from database version 17.6 -- Dumped by pg_dump version 17.6 @@ -816,8 +816,8 @@ CREATE OR REPLACE FUNCTION "public"."handle_new_user"() RETURNS "trigger" SET "search_path" TO '' AS $$ begin - insert into public.user_profiles (id, display_name) - values (new.id, coalesce(new.raw_user_meta_data ->> 'display_name', split_part(new.email, '@', 1))); + insert into public.user_profiles (id) + values (new.id); return new; end; @@ -1338,7 +1338,6 @@ ALTER TABLE "public"."user_highlights" OWNER TO "postgres"; CREATE TABLE IF NOT EXISTS "public"."user_profiles" ( "id" "uuid" NOT NULL, - "display_name" "text", "tier" "public"."subscription_tier" DEFAULT 'free'::"public"."subscription_tier" NOT NULL, "feed_count" integer DEFAULT 0 NOT NULL, "folder_count" integer DEFAULT 0 NOT NULL, @@ -3683,5 +3682,5 @@ ALTER DEFAULT PRIVILEGES FOR ROLE "postgres" IN SCHEMA "public" GRANT ALL ON TAB -- PostgreSQL database dump complete -- --- \unrestrict 3Un8h9VlAyPuVfPugYV7LM7XGnkxI3KC1nPU1aarC0scGxlDzBQB81bgO7tvPsv +-- \unrestrict x5c7hoIeZadeb9vWOL0aN2XhOidKEkcJTCLPxElLQoDi4K0JeM3w2RYCHdK42ij |