@@ -36,57 +36,54 @@ export class WebExtV160UpgradeProviderService extends V160UpgradeProviderService
3636 }
3737
3838 upgradeApp ( upgradingFromVersion ?: string ) : ng . IPromise < void > {
39- // Initialise IndexedDB data storage
40- return (
41- this . storeSvc
42- . init ( )
43- // Convert local storage items to IndexedDB
44- . then ( ( ) => browser . storage . local . get ( ) )
45- . then ( ( cachedData ) => {
46- if ( ! cachedData || Object . keys ( cachedData ) . length === 0 ) {
47- return ;
48- }
39+ // Migrate items in local storage to new IndexedDB store
40+ return this . storeSvc
41+ . init ( )
42+ . then ( ( ) => browser . storage . local . get ( ) )
43+ . then ( ( cachedData ) => {
44+ if ( ! cachedData || Object . keys ( cachedData ) . length === 0 ) {
45+ return ;
46+ }
4947
50- const syncInfo : Partial < ApiXbrowsersyncSyncInfo > = {
51- serviceType : ApiServiceType . xBrowserSync
52- } ;
53-
54- return this . $q
55- . all (
56- Object . keys ( cachedData ) . map ( ( key ) => {
57- if ( key === 'password' ) {
58- return ;
59- }
60-
61- // Upgrade sync settings
62- switch ( key ) {
63- case 'serviceUrl' :
64- syncInfo . serviceUrl = cachedData [ key ] ;
65- return ;
66- case 'syncId' :
67- syncInfo . id = cachedData [ key ] ;
68- return ;
69- case 'syncVersion' :
70- syncInfo . version = cachedData [ key ] ;
71- return ;
72- default :
73- }
74-
75- return this . storeSvc . set ( key , cachedData [ key ] ) ;
76- } )
77- )
78- . then ( ( ) => {
79- if ( ! syncInfo . id ) {
48+ const syncInfo : Partial < ApiXbrowsersyncSyncInfo > = {
49+ serviceType : ApiServiceType . xBrowserSync
50+ } ;
51+ return this . $q
52+ . all (
53+ Object . keys ( cachedData ) . map ( ( key ) => {
54+ // Ignore items that should not be migrated
55+ if ( key === 'password' || key === 'traceLog' ) {
8056 return ;
8157 }
82- if ( ! syncInfo . serviceUrl ) {
83- syncInfo . serviceUrl = Globals . URL . DefaultServiceUrl ;
58+
59+ // Upgrade sync settings
60+ switch ( key ) {
61+ case 'serviceUrl' :
62+ syncInfo . serviceUrl = cachedData [ key ] ;
63+ return ;
64+ case 'syncId' :
65+ syncInfo . id = cachedData [ key ] ;
66+ return ;
67+ case 'syncVersion' :
68+ syncInfo . version = cachedData [ key ] ;
69+ return ;
70+ default :
8471 }
85- return this . storeSvc . set ( StoreKey . SyncInfo , syncInfo ) ;
86- } ) ;
87- } )
88- . then ( ( ) => browser . storage . local . clear ( ) )
89- . then ( ( ) => super . upgradeApp ( ) )
90- ) ;
72+
73+ return this . storeSvc . set ( key , cachedData [ key ] ) ;
74+ } )
75+ )
76+ . then ( ( ) => {
77+ if ( ! syncInfo . id ) {
78+ return ;
79+ }
80+ if ( ! syncInfo . serviceUrl ) {
81+ syncInfo . serviceUrl = Globals . URL . DefaultServiceUrl ;
82+ }
83+ return this . storeSvc . set ( StoreKey . SyncInfo , syncInfo ) ;
84+ } ) ;
85+ } )
86+ . then ( ( ) => browser . storage . local . clear ( ) )
87+ . then ( ( ) => super . upgradeApp ( ) ) ;
9188 }
9289}
0 commit comments