@@ -69,18 +69,17 @@ export const getApplications = async ({
69
69
state,
70
70
rootState
71
71
} : ActionContext < IChatState , IRootState > ) : Promise < IApplication [ ] > => {
72
+ console . debug ( 'start to get applications for chat' ) ;
72
73
return new Promise ( ( resolve , reject ) => {
73
- console . debug ( 'start to get applications for chat' ) ;
74
74
state . status . getApplications = Status . Request ;
75
75
applicationOperator
76
76
. getAll ( {
77
77
user_id : rootState ?. user ?. id ,
78
78
service_id : CHAT_SERVICE_ID
79
79
} )
80
80
. then ( ( response ) => {
81
- console . debug ( 'get application success' , response ?. data ) ;
81
+ console . debug ( 'get applications success' , response ?. data ) ;
82
82
state . status . getApplications = Status . Success ;
83
- commit ( 'setApplications' , response . data . items ) ;
84
83
// check if there is any application with 'Period' type
85
84
const application = response . data . items ?. find ( ( application ) => application ?. type === IApplicationType . PERIOD ) ;
86
85
const application2 = response . data . items ?. find ( ( application ) => application ?. type === IApplicationType . USAGE ) ;
@@ -100,9 +99,12 @@ export const getApplications = async ({
100
99
) ;
101
100
console . debug ( 'set credential with Usage' , application ) ;
102
101
commit ( 'setCredential' , credential ) ;
102
+ } else {
103
+ console . debug ( 'set application with null' , response . data . items ?. [ 0 ] ) ;
104
+ commit ( 'setApplication' , response . data . items ?. [ 0 ] ) ;
103
105
}
104
106
resolve ( response . data . items ) ;
105
- console . debug ( 'save applications success' , response . data . items ) ;
107
+ console . debug ( 'save application success' , response . data . items [ 0 ] ) ;
106
108
} )
107
109
. catch ( ( error ) => {
108
110
state . status . getApplications = Status . Error ;
0 commit comments