@@ -194,17 +194,15 @@ window.QPixel = {
194194 if ( QPixel . _preferences != null ) {
195195 return QPixel . _preferences ;
196196 }
197- // Early return the preferences from localStorage unless null or undefined
197+
198+ // Early return the preferences from storage unless null or undefined
198199 const key = QPixel . _preferencesLocalStorageKey ( ) ;
199- const localStoragePreferences = ( key in localStorage )
200- ? JSON . parse ( localStorage [ key ] )
201- : null ;
202- if ( localStoragePreferences != null ) {
203- QPixel . _preferences = localStoragePreferences ;
204- return QPixel . _preferences ;
200+ const storedPreferences = QPixel . Storage ?. get ( key , { parse : true } ) ;
201+ if ( storedPreferences ) {
202+ return ( QPixel . _preferences = /** @type {UserPreferences } */ ( storedPreferences ) ) ;
205203 }
206- // Preferences are still null (or undefined) after loading from localStorage, so we're probably on a site we
207- // haven't loaded them for yet. Load from Redis via AJAX.
204+
205+ // If preferences are absent in storage, load them via AJAX
208206 await QPixel . _cachedFetchPreferences ( ) ;
209207 return QPixel . _preferences ;
210208 } ,
@@ -322,7 +320,7 @@ window.QPixel = {
322320
323321 _preferencesLocalStorageKey : ( ) => {
324322 const id = document . body . dataset . userId ;
325- const key = `qpixel. user_${ id } _preferences` ;
323+ const key = `user_${ id } _preferences` ;
326324 QPixel . _preferencesLocalStorageKey = ( ) => key ;
327325 return key ;
328326 } ,
@@ -353,7 +351,7 @@ window.QPixel = {
353351 _updatePreferencesLocally : ( data ) => {
354352 QPixel . _preferences = data ;
355353 const key = QPixel . _preferencesLocalStorageKey ( ) ;
356- localStorage [ key ] = JSON . stringify ( QPixel . _preferences ) ;
354+ QPixel . Storage ?. set ( key , QPixel . _preferences ) ;
357355 } ,
358356
359357 currentCaretSequence : ( splat , posIdx ) => {
0 commit comments