This repository was archived by the owner on Jan 26, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +31
-20
lines changed
components/blocks/MyAccount
modules/newsletter/features Expand file tree Collapse file tree 5 files changed +31
-20
lines changed Original file line number Diff line number Diff line change @@ -36,7 +36,9 @@ export default {
36
36
this . isEdited = false
37
37
} ,
38
38
getNewsletter ( ) {
39
- this . user . isSubscribed = this . isSubscribed
39
+ this . $store . dispatch ( 'user/loadNewsletterPreferences' ) . then ( ( res ) => {
40
+ this . user . isSubscribed = res . isSubscribed
41
+ } )
40
42
}
41
43
} ,
42
44
mixins : [ subscribe , unsubscribe , isSubscribed ]
Original file line number Diff line number Diff line change 9
9
export const isSubscribed = {
10
10
computed : {
11
11
isSubscribed ( ) {
12
- return this . $store . state . user . newsletter . isSubscribed ? this . $store . state . user . newsletter . isSubscribed : false
12
+ return this . $store . state . user . newsletter ? ( this . $store . state . user . newsletter . isSubscribed ? this . $store . state . user . newsletter . isSubscribed : false ) : false
13
13
}
14
14
}
15
15
}
Original file line number Diff line number Diff line change @@ -25,19 +25,19 @@ class LocalForageCacheDriver {
25
25
if ( typeof this . cacheErrorsCount [ collectionName ] === 'undefined' ) {
26
26
this . cacheErrorsCount [ collectionName ] = 0
27
27
}
28
- if ( typeof this . localCache === 'undefined' ) {
29
- this . localCache = { }
28
+ if ( typeof Vue . prototype . $ localCache === 'undefined' ) {
29
+ Vue . prototype . $ localCache = { }
30
30
}
31
- if ( typeof this . localCache [ dbName ] === 'undefined' ) {
32
- this . localCache [ dbName ] = { }
31
+ if ( typeof Vue . prototype . $ localCache[ dbName ] === 'undefined' ) {
32
+ Vue . prototype . $ localCache[ dbName ] = { }
33
33
}
34
- if ( typeof this . localCache [ dbName ] [ collectionName ] === 'undefined' ) {
35
- this . localCache [ dbName ] [ collectionName ] = { }
34
+ if ( typeof Vue . prototype . $ localCache[ dbName ] [ collectionName ] === 'undefined' ) {
35
+ Vue . prototype . $ localCache[ dbName ] [ collectionName ] = { }
36
36
}
37
37
this . _collectionName = collectionName
38
38
this . _dbName = dbName
39
39
this . _useLocalCacheByDefault = useLocalCacheByDefault
40
- this . _localCache = this . localCache [ dbName ] [ collectionName ]
40
+ this . _localCache = Vue . prototype . $ localCache[ dbName ] [ collectionName ]
41
41
this . _localForageCollection = collection
42
42
this . _lastError = null
43
43
this . _persistenceErrorNotified = false
Original file line number Diff line number Diff line change @@ -41,16 +41,25 @@ const actions: ActionTree<UserState, RootState> = {
41
41
Vue . prototype . $bus . $emit ( 'session-after-started' )
42
42
} )
43
43
44
+ context . dispatch ( 'loadNewsletterPreferences' )
45
+ } ,
46
+ loadNewsletterPreferences ( context ) {
44
47
const newsletterStorage = Vue . prototype . $db . newsletterPreferencesCollection
45
- newsletterStorage . getItem ( 'newsletter-preferences' , ( err , res ) => {
46
- if ( err ) {
47
- console . error ( err )
48
- return
49
- }
48
+ return new Promise ( ( resolve , reject ) => {
49
+ newsletterStorage . getItem ( 'newsletter-preferences' , ( err , res ) => {
50
+ if ( err ) {
51
+ console . error ( err )
52
+ reject ( err )
53
+ return
54
+ }
50
55
51
- if ( res ) {
52
- context . commit ( types . USER_UPDATE_PREFERENCES , res )
53
- }
56
+ if ( res ) {
57
+ context . commit ( types . USER_UPDATE_PREFERENCES , res )
58
+ resolve ( res )
59
+ } else {
60
+ resolve ( { isSubscribed : false } )
61
+ }
62
+ } )
54
63
} )
55
64
} ,
56
65
/**
Original file line number Diff line number Diff line change @@ -2,12 +2,12 @@ export default interface UserState {
2
2
token : string ,
3
3
refreshToken : string ,
4
4
groupToken : string ,
5
- groupId : null ,
5
+ groupId : any ,
6
6
current : {
7
7
email : string
8
8
} | null ,
9
9
current_storecode : string ,
10
10
session_started : Date ,
11
- newsletter : null ,
12
- orders_history : null
11
+ newsletter : any ,
12
+ orders_history : any
13
13
}
You can’t perform that action at this time.
0 commit comments