From 789b689451fb5fb4b910b92966c35fd0fb34f4ee Mon Sep 17 00:00:00 2001 From: Ahmet Kilinc Date: Fri, 2 May 2025 18:59:05 +0100 Subject: [PATCH 1/5] fixes settings/appearance issue --- apps/mail/app/(routes)/settings/appearance/page.tsx | 8 ++++---- apps/mail/app/api/auth/settings/route.ts | 3 +-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/apps/mail/app/(routes)/settings/appearance/page.tsx b/apps/mail/app/(routes)/settings/appearance/page.tsx index f7083bf09..a81387e55 100644 --- a/apps/mail/app/(routes)/settings/appearance/page.tsx +++ b/apps/mail/app/(routes)/settings/appearance/page.tsx @@ -42,7 +42,7 @@ export default function AppearancePage() { const form = useForm>({ resolver: zodResolver(formSchema), defaultValues: { - colorTheme: settings?.colorTheme || '', + colorTheme: settings?.colorTheme || theme, }, }); @@ -55,6 +55,7 @@ export default function AppearancePage() { function update() { setTheme(newTheme); + form.setValue('colorTheme', newTheme as z.infer['colorTheme']); } if (document.startViewTransition && nextResolvedTheme !== resolvedTheme) { @@ -109,7 +110,7 @@ export default function AppearancePage() {
- {settings.colorTheme ? ( + {settings.colorTheme || theme ? ( { handleThemeChange(value); - field.onChange(value); }} - defaultValue={settings.colorTheme} + defaultValue={form.getValues().colorTheme} > diff --git a/apps/mail/app/api/auth/settings/route.ts b/apps/mail/app/api/auth/settings/route.ts index 467e1be72..775a5b2b3 100644 --- a/apps/mail/app/api/auth/settings/route.ts +++ b/apps/mail/app/api/auth/settings/route.ts @@ -31,8 +31,7 @@ export const GET = async (req: NextRequest) => { .where(eq(userSettings.userId, userId)) .limit(1); - // Returning null here when there are no settings so we can use the default settings with timezone from the browser - if (!result) return NextResponse.json({ settings: defaultUserSettings }, { status: 200 }); + if (!result) return NextResponse.json({ ...defaultUserSettings }, { status: 200 }); const settings = userSettingsSchema.parse(result.settings); From f073bb47e0c2b39f2109468891693ae444a74018 Mon Sep 17 00:00:00 2001 From: Ahmet Kilinc Date: Fri, 2 May 2025 19:28:21 +0100 Subject: [PATCH 2/5] turn images on by default --- apps/mail/components/mail/mail-iframe.tsx | 2 +- packages/db/src/user_settings_default.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/mail/components/mail/mail-iframe.tsx b/apps/mail/components/mail/mail-iframe.tsx index 937f370f0..916db4442 100644 --- a/apps/mail/components/mail/mail-iframe.tsx +++ b/apps/mail/components/mail/mail-iframe.tsx @@ -17,7 +17,7 @@ export function MailIframe({ html, senderEmail }: { html: string; senderEmail: s [settings, senderEmail], ); const [cspViolation, setCspViolation] = useState(false); - const [imagesEnabled, setImagesEnabled] = useState(false); + const [imagesEnabled, setImagesEnabled] = useState(settings?.externalImages || true); const iframeRef = useRef(null); const [height, setHeight] = useState(0); const { resolvedTheme } = useTheme(); diff --git a/packages/db/src/user_settings_default.ts b/packages/db/src/user_settings_default.ts index 492a432ed..35935e474 100644 --- a/packages/db/src/user_settings_default.ts +++ b/packages/db/src/user_settings_default.ts @@ -4,7 +4,7 @@ export const defaultUserSettings = { language: 'en', timezone: 'UTC', dynamicContent: false, - externalImages: false, + externalImages: true, customPrompt: '', trustedSenders: [], isOnboarded: false, From 116a41f0a225888c637b12abe1380ddfa0fd6192 Mon Sep 17 00:00:00 2001 From: Ahmet Kilinc Date: Fri, 2 May 2025 19:34:18 +0100 Subject: [PATCH 3/5] remove console.log --- apps/mail/actions/settings.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/apps/mail/actions/settings.ts b/apps/mail/actions/settings.ts index d04a91171..40c251cb9 100644 --- a/apps/mail/actions/settings.ts +++ b/apps/mail/actions/settings.ts @@ -22,12 +22,9 @@ export async function saveUserSettings(settings: UserSettings) { try { const userId = await getAuthenticatedUserId(); if (!userId) throw new Error('No user ID found'); - console.error(settings, 'before'); settings = validateSettings(settings); - console.error(settings, 'after'); - const timestamp = new Date(); const [existingSettings] = await db From dc1b392cbf03320828157a2f09df3b866f6c5418 Mon Sep 17 00:00:00 2001 From: Ahmet Kilinc Date: Fri, 2 May 2025 22:28:10 +0100 Subject: [PATCH 4/5] fixes for sidebar --- apps/mail/components/ui/app-sidebar.tsx | 8 +++----- apps/mail/components/ui/nav-main.tsx | 10 ++++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/apps/mail/components/ui/app-sidebar.tsx b/apps/mail/components/ui/app-sidebar.tsx index ff2dcac59..286a1e994 100644 --- a/apps/mail/components/ui/app-sidebar.tsx +++ b/apps/mail/components/ui/app-sidebar.tsx @@ -120,11 +120,9 @@ export function AppSidebar({ ...props }: React.ComponentProps) { className={`mt-auto flex w-full flex-col ${state !== 'collapsed' ? 'px-0 md:px-2' : ''}`} > - - - - - +
+ +
diff --git a/apps/mail/components/ui/nav-main.tsx b/apps/mail/components/ui/nav-main.tsx index 8684e2c85..41252a43e 100644 --- a/apps/mail/components/ui/nav-main.tsx +++ b/apps/mail/components/ui/nav-main.tsx @@ -254,9 +254,11 @@ export function NavMain({ items }: NavMainProps) { > {state !== 'collapsed' ? ( -

- {section.title} -

+ section.title ? ( +

+ {section.title} +

+ ) : null ) : (
)} @@ -421,7 +423,7 @@ export function NavMain({ items }: NavMainProps) {
{labels.map((label) => ( From 8c30ea552e7ecb7ee09e945f0c9db48f43032e69 Mon Sep 17 00:00:00 2001 From: Ahmet Kilinc Date: Fri, 2 May 2025 22:28:41 +0100 Subject: [PATCH 5/5] padding fix --- apps/mail/components/ui/sidebar.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/mail/components/ui/sidebar.tsx b/apps/mail/components/ui/sidebar.tsx index 9e7ab1330..3e13fb00a 100644 --- a/apps/mail/components/ui/sidebar.tsx +++ b/apps/mail/components/ui/sidebar.tsx @@ -278,7 +278,7 @@ const SidebarGroup = React.forwardRef );