@@ -797,6 +797,42 @@ const actions = {
797797 . catch ( ( error ) => { throw error } )
798798 } ) . catch ( ( error ) => context . commit ( 'API_FAILURE' , { userid, error } ) )
799799 } ,
800+ /**
801+ * Migrate local storage keys to database
802+ *
803+ * @param {object } context store context
804+ */
805+ migrateLocalStorage ( { commit } ) {
806+ const preferences = {
807+ showStoragePath : 'user_list_show_storage_path' ,
808+ showUserBackend : 'user_list_show_user_backend' ,
809+ showFirstLogin : 'user_list_show_first_login' ,
810+ showLastLogin : 'user_list_show_last_login' ,
811+ showNewUserForm : 'user_list_show_new_user_form' ,
812+ showLanguages : 'user_list_show_languages' ,
813+ }
814+
815+ for ( const [ key , dbKey ] of Object . entries ( preferences ) ) {
816+ const localKey = `account_settings__${ key } `
817+ const localValue = window . localStorage . getItem ( localKey )
818+ if ( localValue === null ) {
819+ continue
820+ }
821+
822+ const value = localValue === 'true'
823+ commit ( 'setShowConfig' , { key, value } )
824+
825+ axios . post ( generateUrl ( `/settings/users/preferences/${ dbKey } ` ) , {
826+ value : value ? 'true' : 'false' ,
827+ } ) . then ( ( ) => {
828+ window . localStorage . removeItem ( localKey )
829+ } ) . catch ( ( error ) => {
830+ logger . error ( `Failed to migrate preference ${ key } ` , { error } )
831+ } )
832+ }
833+ } ,
834+
835+
800836 /**
801837 * Set show config
802838 *
0 commit comments