@@ -18,7 +18,7 @@ const defaultPreferencesContent = `
1818# DO NOT SHARE YOUR PREFERENCES FILE WITH ANYONE.
1919# IT CONTAINS YOUR PRIVATE KEYS.
2020#
21- [preferences ]
21+ [Preferences ]
2222theme = "light"
2323textSize = "prose-lg"
2424limit = "40"
@@ -33,6 +33,16 @@ blog = "all"
3333contact = "following"
3434about = "all"
3535gathering = "all"
36+
37+ [[QuickActions]]
38+ label = "Public"
39+ pkg = "hub"
40+ view = "public"
41+
42+ [[QuickActions]]
43+ label = "Mentions"
44+ pkg = "hub"
45+ view = "mentions"
3646`
3747
3848let savedData = { }
@@ -43,8 +53,8 @@ const preferencesFileExists = () => {
4353 if ( fileExists ) {
4454 const data = TOML . parse ( fs . readFileSync ( prefsFile ) )
4555 console . log ( data )
46- if ( data ?. preferences ?. defaultIdentity &&
47- data [ data ?. preferences ?. defaultIdentity ] ?. id ) {
56+ if ( data ?. Preferences ?. defaultIdentity &&
57+ data [ data ?. Preferences ?. defaultIdentity ] ?. id ) {
4858 return true
4959 }
5060 }
@@ -79,8 +89,8 @@ const loadSavedData = async () => {
7989 }
8090}
8191
82- const getPref = ( key , defaultValue , namespace = "preferences " ) => {
83- if ( ! savedData . hasOwnProperty ( "preferences " ) ) {
92+ const getPref = ( key , defaultValue , namespace = "Preferences " ) => {
93+ if ( ! savedData . hasOwnProperty ( "Preferences " ) ) {
8494 // maybe not loaded. Preferences should always be present. It is added
8595 // by the first-time setup.
8696 if ( preferencesFileExists ( ) ) {
@@ -96,6 +106,21 @@ const getPref = (key, defaultValue, namespace = "preferences") => {
96106 return defaultValue
97107}
98108
109+ const getNamespace = ( namespace , defaultValue ) => {
110+ if ( ! savedData . hasOwnProperty ( "Preferences" ) ) {
111+ // maybe not loaded. Preferences should always be present. It is added
112+ // by the first-time setup.
113+ if ( preferencesFileExists ( ) ) {
114+ savedData = TOML . parse ( fs . readFileSync ( prefsFile ) )
115+ }
116+ }
117+
118+ if ( savedData [ namespace ] ) {
119+ return savedData [ namespace ]
120+ }
121+ return defaultValue
122+ }
123+
99124function writePreferencesFile ( ) {
100125 let header = `
101126#
@@ -134,7 +159,7 @@ const removeIdentity = (key) => {
134159}
135160
136161
137- const setPref = ( key , value , namespace = "preferences " ) => {
162+ const setPref = ( key , value , namespace = "Preferences " ) => {
138163 savedData [ namespace ] = savedData [ namespace ] || { }
139164 savedData [ namespace ] [ key ] = value
140165
@@ -250,4 +275,5 @@ module.exports = {
250275 initialisePreferencesFileIfNeeded,
251276 setMessageTypeVisibility,
252277 getVisibilityForMessageType,
278+ getNamespace,
253279}
0 commit comments