1- import { atom , type WritableAtom } from 'jotai' ;
1+ import { atom } from 'jotai' ;
22import { mobileOrTablet } from '$utils/user-agent' ;
33
44const STORAGE_KEY = 'settings' ;
@@ -23,36 +23,6 @@ export enum CaptionPosition {
2323}
2424export type JumboEmojiSize = 'none' | 'extraSmall' | 'small' | 'normal' | 'large' | 'extraLarge' ;
2525
26- export type ThemeRemoteFavorite = {
27- fullUrl : string ;
28- displayName : string ;
29- basename : string ;
30- kind : 'light' | 'dark' ;
31- pinned ?: boolean ;
32- importedLocal ?: boolean ;
33- } ;
34-
35- export type ThemeRemoteTweakFavorite = {
36- fullUrl : string ;
37- displayName : string ;
38- basename : string ;
39- pinned ?: boolean ;
40- importedLocal ?: boolean ;
41- } ;
42-
43- /** Custom profile card hero colors: which brightness schemes to honor. */
44- export type RenderUserCardsMode = 'both' | 'light' | 'dark' | 'none' ;
45-
46- export function shouldApplyUserHeroCards (
47- mode : RenderUserCardsMode ,
48- brightness : string | undefined
49- ) : boolean {
50- if ( mode === 'none' ) return false ;
51- if ( mode === 'both' ) return true ;
52- if ( brightness !== 'light' && brightness !== 'dark' ) return false ;
53- return brightness === mode ;
54- }
55-
5626export interface Settings {
5727 themeId ?: string ;
5828 useSystemTheme : boolean ;
@@ -64,6 +34,8 @@ export interface Settings {
6434 arboriumDarkTheme ?: string ;
6535 saturationLevel ?: number ;
6636 uniformIcons : boolean ;
37+ isMarkdown : boolean ;
38+ editorToolbar : boolean ;
6739 twitterEmoji : boolean ;
6840 pageZoom : number ;
6941 hideActivity : boolean ;
@@ -113,7 +85,6 @@ export interface Settings {
11385 showPronouns : boolean ;
11486 parsePronouns : boolean ;
11587 renderGlobalNameColors : boolean ;
116- renderUserCards : RenderUserCardsMode ;
11788 filterPronounsBasedOnLanguage ?: boolean ;
11889 filterPronounsLanguages ?: string [ ] ;
11990 renderRoomColors : boolean ;
@@ -124,6 +95,7 @@ export interface Settings {
12495 // Sable features!
12596 sendPresence : boolean ;
12697 autoIdlePresence : boolean ;
98+ presenceIdleTimeoutMins : number ;
12799 showRoomMessagePreview : boolean ;
128100 mobileGestures : boolean ;
129101 rightSwipeAction : RightSwipeAction ;
@@ -153,26 +125,9 @@ export interface Settings {
153125
154126 // furry stuff
155127 renderAnimals : boolean ;
156-
157- // theme catalog
158- themeCatalogOnboardingDone : boolean ;
159- themeRemoteFavorites : ThemeRemoteFavorite [ ] ;
160- themeRemoteCatalogEnabled : boolean ;
161- themeChatSableWidgetsEnabled : boolean ;
162- themeChatAutoPreviewApprovedUrls : boolean ;
163- themeChatAutoPreviewAnyUrl : boolean ;
164- themeRemoteManualFullUrl ?: string ;
165- themeRemoteLightFullUrl ?: string ;
166- themeRemoteDarkFullUrl ?: string ;
167- themeRemoteManualKind ?: 'light' | 'dark' ;
168- themeRemoteLightKind ?: 'light' | 'dark' ;
169- themeRemoteDarkKind ?: 'light' | 'dark' ;
170- themeMigrationDismissed : boolean ;
171- themeRemoteTweakFavorites : ThemeRemoteTweakFavorite [ ] ;
172- themeRemoteEnabledTweakFullUrls : string [ ] ;
173128}
174129
175- export const defaultSettings : Settings = {
130+ const defaultSettings : Settings = {
176131 themeId : undefined ,
177132 useSystemTheme : true ,
178133 lightThemeId : undefined ,
@@ -183,6 +138,8 @@ export const defaultSettings: Settings = {
183138 arboriumDarkTheme : 'dracula' ,
184139 saturationLevel : 100 ,
185140 uniformIcons : false ,
141+ isMarkdown : true ,
142+ editorToolbar : false ,
186143 twitterEmoji : true ,
187144 pageZoom : 100 ,
188145 hideActivity : false ,
@@ -235,7 +192,6 @@ export const defaultSettings: Settings = {
235192 showPronouns : true ,
236193 parsePronouns : true ,
237194 renderGlobalNameColors : true ,
238- renderUserCards : 'both' ,
239195 renderRoomColors : true ,
240196 renderRoomFonts : true ,
241197 captionPosition : CaptionPosition . Below ,
@@ -244,6 +200,7 @@ export const defaultSettings: Settings = {
244200 // Sable features!
245201 sendPresence : true ,
246202 autoIdlePresence : true ,
203+ presenceIdleTimeoutMins : 5 ,
247204 showRoomMessagePreview : true ,
248205 mobileGestures : true ,
249206 rightSwipeAction : RightSwipeAction . Reply ,
@@ -273,23 +230,6 @@ export const defaultSettings: Settings = {
273230
274231 // furry stuff
275232 renderAnimals : true ,
276-
277- // theme catalog
278- themeCatalogOnboardingDone : false ,
279- themeRemoteFavorites : [ ] ,
280- themeRemoteCatalogEnabled : false ,
281- themeChatSableWidgetsEnabled : true ,
282- themeChatAutoPreviewApprovedUrls : true ,
283- themeChatAutoPreviewAnyUrl : false ,
284- themeRemoteManualFullUrl : undefined ,
285- themeRemoteLightFullUrl : undefined ,
286- themeRemoteDarkFullUrl : undefined ,
287- themeRemoteManualKind : undefined ,
288- themeRemoteLightKind : undefined ,
289- themeRemoteDarkKind : undefined ,
290- themeMigrationDismissed : false ,
291- themeRemoteTweakFavorites : [ ] ,
292- themeRemoteEnabledTweakFullUrls : [ ] ,
293233} ;
294234
295235export const getSettings = ( ) => {
@@ -307,34 +247,14 @@ export const getSettings = () => {
307247 }
308248 delete parsed . monochromeMode ;
309249
310- if ( typeof parsed . renderUserCards === 'boolean' ) {
311- parsed . renderUserCards = parsed . renderUserCards ? 'both' : 'none' ;
312- } else if (
313- parsed . renderUserCards !== 'both' &&
314- parsed . renderUserCards !== 'light' &&
315- parsed . renderUserCards !== 'dark' &&
316- parsed . renderUserCards !== 'none'
317- ) {
318- parsed . renderUserCards = 'both' ;
319- }
320-
321- const parsedRecord = parsed as Record < string , unknown > ;
322- if (
323- typeof parsedRecord . themeChatAutoPreviewAnyUrl !== 'boolean' &&
324- typeof parsedRecord . themeChatPreviewAnyUrl === 'boolean'
325- ) {
326- parsedRecord . themeChatAutoPreviewAnyUrl = parsedRecord . themeChatPreviewAnyUrl ;
327- }
328- delete parsedRecord . themeChatPreviewAnyUrl ;
329- delete parsedRecord . themeChatPreviewApprovedCatalogOnly ;
330-
331250 return {
332251 ...defaultSettings ,
333252 ...( parsed as Settings ) ,
334253 } ;
335254 } catch {
336255 return defaultSettings ;
337256 }
257+ } ;
338258
339259export const setSettings = ( settings : Settings ) => {
340260 try {
@@ -347,11 +267,8 @@ export const setSettings = (settings: Settings) => {
347267const baseSettings = atom ( getSettings ( ) ) ;
348268export const settingsAtom = atom < Settings , [ Settings ] , undefined > (
349269 ( get ) => get ( baseSettings ) ,
350- ( _get , set , update ) => {
351- ( set as ( atom : WritableAtom < Settings , [ Settings ] , void > , val : Settings ) => void ) (
352- baseSettings as WritableAtom < Settings , [ Settings ] , void > ,
353- update
354- ) ;
270+ ( get , set , update ) => {
271+ set ( baseSettings , update ) ;
355272 setSettings ( update ) ;
356273 }
357274) ;
0 commit comments