Add checkbox for displaying emojis in sidebar (#520)
Browse files* Add settings for displaying emojis in sidebar
* updated wording
    	
        src/lib/components/SettingsModal.svelte
    CHANGED
    
    | @@ -75,6 +75,14 @@ | |
| 75 | 
             
            					</ul>
         | 
| 76 | 
             
            				</div>
         | 
| 77 | 
             
            			{/if}
         | 
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
| 78 | 
             
            			<form
         | 
| 79 | 
             
            				method="post"
         | 
| 80 | 
             
            				action="{base}/conversations?/delete"
         | 
|  | |
| 75 | 
             
            					</ul>
         | 
| 76 | 
             
            				</div>
         | 
| 77 | 
             
            			{/if}
         | 
| 78 | 
            +
            			<label class="flex cursor-pointer select-none items-center gap-2 text-sm text-gray-500">
         | 
| 79 | 
            +
            				<input
         | 
| 80 | 
            +
            					type="checkbox"
         | 
| 81 | 
            +
            					name="hideEmojiOnSidebar"
         | 
| 82 | 
            +
            					bind:checked={settings.hideEmojiOnSidebar}
         | 
| 83 | 
            +
            				/>
         | 
| 84 | 
            +
            				Show emoticons in conversation topics
         | 
| 85 | 
            +
            			</label>
         | 
| 86 | 
             
            			<form
         | 
| 87 | 
             
            				method="post"
         | 
| 88 | 
             
            				action="{base}/conversations?/delete"
         | 
    	
        src/lib/types/Settings.ts
    CHANGED
    
    | @@ -14,6 +14,7 @@ export interface Settings extends Timestamps { | |
| 14 | 
             
            	shareConversationsWithModelAuthors: boolean;
         | 
| 15 | 
             
            	ethicsModalAcceptedAt: Date | null;
         | 
| 16 | 
             
            	activeModel: string;
         | 
|  | |
| 17 |  | 
| 18 | 
             
            	// model name and system prompts
         | 
| 19 | 
             
            	customPrompts?: Record<string, string>;
         | 
|  | |
| 14 | 
             
            	shareConversationsWithModelAuthors: boolean;
         | 
| 15 | 
             
            	ethicsModalAcceptedAt: Date | null;
         | 
| 16 | 
             
            	activeModel: string;
         | 
| 17 | 
            +
            	hideEmojiOnSidebar?: boolean;
         | 
| 18 |  | 
| 19 | 
             
            	// model name and system prompts
         | 
| 20 | 
             
            	customPrompts?: Record<string, string>;
         | 
    	
        src/routes/+layout.server.ts
    CHANGED
    
    | @@ -71,7 +71,7 @@ export const load: LayoutServerLoad = async ({ locals, depends, url }) => { | |
| 71 | 
             
            			})
         | 
| 72 | 
             
            			.map((conv) => ({
         | 
| 73 | 
             
            				id: conv._id.toString(),
         | 
| 74 | 
            -
            				title: conv.title,
         | 
| 75 | 
             
            				model: conv.model ?? defaultModel,
         | 
| 76 | 
             
            			}))
         | 
| 77 | 
             
            			.toArray(),
         | 
| @@ -81,6 +81,7 @@ export const load: LayoutServerLoad = async ({ locals, depends, url }) => { | |
| 81 | 
             
            				DEFAULT_SETTINGS.shareConversationsWithModelAuthors,
         | 
| 82 | 
             
            			ethicsModalAcceptedAt: settings?.ethicsModalAcceptedAt ?? null,
         | 
| 83 | 
             
            			activeModel: settings?.activeModel ?? DEFAULT_SETTINGS.activeModel,
         | 
|  | |
| 84 | 
             
            			searchEnabled: !!(SERPAPI_KEY || SERPER_API_KEY),
         | 
| 85 | 
             
            			customPrompts: settings?.customPrompts ?? {},
         | 
| 86 | 
             
            		},
         | 
|  | |
| 71 | 
             
            			})
         | 
| 72 | 
             
            			.map((conv) => ({
         | 
| 73 | 
             
            				id: conv._id.toString(),
         | 
| 74 | 
            +
            				title: settings?.hideEmojiOnSidebar ? conv.title.replace(/\p{Emoji}/gu, "") : conv.title,
         | 
| 75 | 
             
            				model: conv.model ?? defaultModel,
         | 
| 76 | 
             
            			}))
         | 
| 77 | 
             
            			.toArray(),
         | 
|  | |
| 81 | 
             
            				DEFAULT_SETTINGS.shareConversationsWithModelAuthors,
         | 
| 82 | 
             
            			ethicsModalAcceptedAt: settings?.ethicsModalAcceptedAt ?? null,
         | 
| 83 | 
             
            			activeModel: settings?.activeModel ?? DEFAULT_SETTINGS.activeModel,
         | 
| 84 | 
            +
            			hideEmojiOnSidebar: settings?.hideEmojiOnSidebar ?? false,
         | 
| 85 | 
             
            			searchEnabled: !!(SERPAPI_KEY || SERPER_API_KEY),
         | 
| 86 | 
             
            			customPrompts: settings?.customPrompts ?? {},
         | 
| 87 | 
             
            		},
         | 
    	
        src/routes/settings/+page.server.ts
    CHANGED
    
    | @@ -6,22 +6,26 @@ import { models, validateModel } from "$lib/server/models"; | |
| 6 | 
             
            import { authCondition } from "$lib/server/auth";
         | 
| 7 | 
             
            import { DEFAULT_SETTINGS } from "$lib/types/Settings";
         | 
| 8 |  | 
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
| 9 | 
             
            export const actions = {
         | 
| 10 | 
             
            	default: async function ({ request, locals }) {
         | 
| 11 | 
             
            		const formData = await request.formData();
         | 
| 12 |  | 
| 13 | 
             
            		const { ethicsModalAccepted, ...settings } = z
         | 
| 14 | 
             
            			.object({
         | 
| 15 | 
            -
            				shareConversationsWithModelAuthors:  | 
| 16 | 
            -
             | 
| 17 | 
            -
            					.transform((value) => {
         | 
| 18 | 
            -
            						return value === "true" || value === "on";
         | 
| 19 | 
            -
            					}),
         | 
| 20 | 
             
            				ethicsModalAccepted: z.boolean({ coerce: true }).optional(),
         | 
| 21 | 
             
            				activeModel: validateModel(models),
         | 
| 22 | 
             
            				customPrompts: z.record(z.string()).default({}),
         | 
| 23 | 
             
            			})
         | 
| 24 | 
             
            			.parse({
         | 
|  | |
| 25 | 
             
            				shareConversationsWithModelAuthors: formData.get("shareConversationsWithModelAuthors"),
         | 
| 26 | 
             
            				ethicsModalAccepted: formData.get("ethicsModalAccepted"),
         | 
| 27 | 
             
            				activeModel: formData.get("activeModel") ?? DEFAULT_SETTINGS.activeModel,
         | 
|  | |
| 6 | 
             
            import { authCondition } from "$lib/server/auth";
         | 
| 7 | 
             
            import { DEFAULT_SETTINGS } from "$lib/types/Settings";
         | 
| 8 |  | 
| 9 | 
            +
            const booleanFormObject = z
         | 
| 10 | 
            +
            	.union([z.literal("true"), z.literal("on"), z.literal("false"), z.null()])
         | 
| 11 | 
            +
            	.transform((value) => {
         | 
| 12 | 
            +
            		return value === "true" || value === "on";
         | 
| 13 | 
            +
            	});
         | 
| 14 | 
            +
             | 
| 15 | 
             
            export const actions = {
         | 
| 16 | 
             
            	default: async function ({ request, locals }) {
         | 
| 17 | 
             
            		const formData = await request.formData();
         | 
| 18 |  | 
| 19 | 
             
            		const { ethicsModalAccepted, ...settings } = z
         | 
| 20 | 
             
            			.object({
         | 
| 21 | 
            +
            				shareConversationsWithModelAuthors: booleanFormObject,
         | 
| 22 | 
            +
            				hideEmojiOnSidebar: booleanFormObject,
         | 
|  | |
|  | |
|  | |
| 23 | 
             
            				ethicsModalAccepted: z.boolean({ coerce: true }).optional(),
         | 
| 24 | 
             
            				activeModel: validateModel(models),
         | 
| 25 | 
             
            				customPrompts: z.record(z.string()).default({}),
         | 
| 26 | 
             
            			})
         | 
| 27 | 
             
            			.parse({
         | 
| 28 | 
            +
            				hideEmojiOnSidebar: formData.get("hideEmojiOnSidebar"),
         | 
| 29 | 
             
            				shareConversationsWithModelAuthors: formData.get("shareConversationsWithModelAuthors"),
         | 
| 30 | 
             
            				ethicsModalAccepted: formData.get("ethicsModalAccepted"),
         | 
| 31 | 
             
            				activeModel: formData.get("activeModel") ?? DEFAULT_SETTINGS.activeModel,
         | 
 
			
