Improve mock fallback when Supabase returns empty objects

cgen-1919042aa9764046a6dcdbd9282911c5
This commit is contained in:
Builder.io 2025-09-27 22:09:07 +00:00
parent b36b529e70
commit f53d1a7735

View file

@ -77,8 +77,8 @@ export const aethexUserService = {
.eq("id", user.id)
.single();
if (error) {
console.warn("Error fetching user profile, falling back to mock:", error);
if (error || !data || Object.keys(data || {}).length === 0) {
if (error) console.warn("Error fetching user profile, falling back to mock:", error);
const mock = await mockAuth.getUserProfile(user.id as any);
if (mock) {
return {
@ -123,9 +123,9 @@ export const aethexUserService = {
.select()
.single();
if (error) {
console.warn("Error updating profile, attempting mock fallback:", error);
if (isTableMissing(error)) {
if (error || !data || Object.keys(data || {}).length === 0) {
console.warn("Updating profile fallback to mock (error or empty):", error?.message);
if (!error || isTableMissing(error)) {
const mock = await mockAuth.updateProfile(
userId as any,
updates as any,