perf: memo GridCard, fuse save fns, fix slash tab active color
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
import { auth } from '@/auth'
|
||||
import { prisma } from '@/lib/prisma'
|
||||
import { revalidatePath, updateTag } from 'next/cache'
|
||||
import { revalidatePath, revalidateTag } from 'next/cache'
|
||||
|
||||
export type UserAISettingsData = {
|
||||
titleSuggestions?: boolean
|
||||
@@ -25,6 +25,7 @@ export type UserAISettingsData = {
|
||||
fontFamily?: 'inter' | 'playfair' | 'jetbrains' | 'system'
|
||||
autoSave?: boolean
|
||||
aiProcessingConsent?: boolean
|
||||
svgComplexity?: 'simple' | 'illustrated' | 'rich'
|
||||
}
|
||||
|
||||
/** Only fields that exist on `UserAISettings` in Prisma (excludes e.g. `theme`, which lives on `User`). */
|
||||
@@ -49,6 +50,7 @@ const USER_AI_SETTINGS_PRISMA_KEYS = [
|
||||
'fontFamily',
|
||||
'autoSave',
|
||||
'aiProcessingConsent',
|
||||
'svgComplexity',
|
||||
] as const
|
||||
|
||||
type UserAISettingsPrismaKey = (typeof USER_AI_SETTINGS_PRISMA_KEYS)[number]
|
||||
@@ -99,7 +101,7 @@ export async function updateAISettings(settings: UserAISettingsData) {
|
||||
revalidatePath('/settings/ai', 'page')
|
||||
revalidatePath('/settings/appearance', 'page')
|
||||
revalidatePath('/', 'layout')
|
||||
updateTag('ai-settings')
|
||||
revalidateTag('ai-settings')
|
||||
|
||||
return { success: true }
|
||||
} catch (error) {
|
||||
@@ -153,6 +155,7 @@ const getCachedAISettings = unstable_cache(
|
||||
fontFamily: 'inter' as const,
|
||||
autoSave: true,
|
||||
aiProcessingConsent: false,
|
||||
svgComplexity: 'simple' as const,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -179,6 +182,7 @@ const getCachedAISettings = unstable_cache(
|
||||
fontFamily: (settings.fontFamily || 'inter') as 'inter' | 'playfair' | 'jetbrains' | 'system',
|
||||
autoSave: settings.autoSave ?? true,
|
||||
aiProcessingConsent: settings.aiProcessingConsent ?? false,
|
||||
svgComplexity: ((settings as any).svgComplexity ?? 'simple') as 'simple' | 'illustrated' | 'rich',
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error getting AI settings:', error)
|
||||
@@ -205,6 +209,7 @@ const getCachedAISettings = unstable_cache(
|
||||
fontFamily: 'inter' as const,
|
||||
autoSave: true,
|
||||
aiProcessingConsent: false,
|
||||
svgComplexity: 'simple' as const,
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -244,6 +249,7 @@ export async function getAISettings(userId?: string) {
|
||||
fontFamily: 'inter' as const,
|
||||
autoSave: true,
|
||||
aiProcessingConsent: false,
|
||||
svgComplexity: 'simple' as const,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user