@@ -26,6 +26,7 @@ var app = new Vue({
26
26
example : "comments" ,
27
27
status : null ,
28
28
form : { } ,
29
+ threadId : null ,
29
30
conversations : [ ] ,
30
31
loading : {
31
32
general : false ,
@@ -88,12 +89,16 @@ var app = new Vue({
88
89
if ( this . loading . chat )
89
90
return ;
90
91
// retrieve from cookie
91
- let threadId = "effba2487ece11eb8e3a0242ac110002"
92
+ // will start from
93
+
94
+ // let threadId = "effba2487ece11eb8e3a0242ac110002"
95
+ let threadId = this . threadId ;
92
96
let config = { }
93
97
let request = {
94
- threadId : threadId ,
98
+ threadId : threadId || null ,
95
99
message : this . chat . message
96
100
}
101
+ console . log ( request ) ;
97
102
this . loading . chat = true ;
98
103
99
104
this . $http . post ( "/conversations/?action=submit" , request , config ) . then ( ( response ) => {
@@ -103,6 +108,8 @@ var app = new Vue({
103
108
if ( response . status == 201 ) {
104
109
this . chat . message = "" ;
105
110
console . log ( response . data ) ;
111
+ this . threadId = response . data . threadId ;
112
+ Cookies . set ( 'thread' , this . threadId , { expires : 7 , path : '' } )
106
113
this . conversations . push ( response . data ) ;
107
114
// this.$set()
108
115
// this.comments = response.data;
@@ -192,7 +199,8 @@ var app = new Vue({
192
199
} ,
193
200
getConversation ( ) {
194
201
// check from cookie for conversation id
195
- let threadId = "effba2487ece11eb8e3a0242ac110002"
202
+ let threadId = this . threadId ;
203
+ // "effba2487ece11eb8e3a0242ac110002"
196
204
this . loading . chat = true ;
197
205
this . errors = null ;
198
206
this . $http . post ( "/conversations/?action=get" , { "threadId" : threadId } ) . then ( ( response ) => {
@@ -236,6 +244,8 @@ var app = new Vue({
236
244
} ,
237
245
mounted ( ) {
238
246
this . getComments ( ) ;
239
- this . getConversation ( ) ;
247
+ this . threadId = Cookies . get ( 'thread' ) ;
248
+ if ( this . threadId )
249
+ this . getConversation ( ) ;
240
250
}
241
251
} )
0 commit comments