File tree Expand file tree Collapse file tree
packages/app-core/src/lib Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -97,6 +97,10 @@ const VALID_FOLDER_ICON_IDS = new Set<FolderIconId>([
9797 'home'
9898] )
9999
100+ function isFolderIconId ( value : unknown ) : value is FolderIconId {
101+ return typeof value === 'string' && VALID_FOLDER_ICON_IDS . has ( value as FolderIconId )
102+ }
103+
100104const DEFAULT_VAULT_SETTINGS : VaultSettings = {
101105 primaryNotesLocation : 'inbox' ,
102106 dailyNotes : {
@@ -356,8 +360,7 @@ function normalizeVaultSettings(
356360 const folderIcons : Record < string , FolderIconId > = { }
357361 if ( candidate . folderIcons && typeof candidate . folderIcons === 'object' ) {
358362 for ( const [ key , iconId ] of Object . entries ( candidate . folderIcons ) ) {
359- if ( ! key || typeof iconId !== 'string' ) continue
360- if ( ! VALID_FOLDER_ICON_IDS . has ( iconId as FolderIconId ) ) continue
363+ if ( ! key || ! isFolderIconId ( iconId ) ) continue
361364 folderIcons [ key ] = iconId
362365 }
363366 }
Original file line number Diff line number Diff line change @@ -50,6 +50,10 @@ const VALID_FOLDER_ICON_IDS = new Set<FolderIconId>([
5050 'home'
5151] )
5252
53+ function isFolderIconId ( value : unknown ) : value is FolderIconId {
54+ return typeof value === 'string' && VALID_FOLDER_ICON_IDS . has ( value as FolderIconId )
55+ }
56+
5357function pad ( n : number ) : string {
5458 return n . toString ( ) . padStart ( 2 , '0' )
5559}
@@ -66,10 +70,8 @@ export function normalizeVaultSettings(
6670 const normalizedFolderIcons : Record < string , FolderIconId > = { }
6771 if ( folderIcons && typeof folderIcons === 'object' ) {
6872 for ( const [ key , value ] of Object . entries ( folderIcons ) ) {
69- if ( ! key || typeof value !== 'string' ) continue
70- if ( VALID_FOLDER_ICON_IDS . has ( value as FolderIconId ) ) {
71- normalizedFolderIcons [ key ] = value
72- }
73+ if ( ! key || ! isFolderIconId ( value ) ) continue
74+ normalizedFolderIcons [ key ] = value
7375 }
7476 }
7577 return {
You can’t perform that action at this time.
0 commit comments