@@ -68,99 +68,100 @@ export default {
68
68
ChatMessager,
69
69
ChatSide,
70
70
ChatLogin,
71
- ChatLoading
71
+ ChatLoading,
72
72
},
73
73
props: {
74
74
tokenField: {
75
75
type: String ,
76
- default: " channel_owner_token"
76
+ default: " channel_owner_token" ,
77
77
},
78
78
displayFull: {
79
79
type: Boolean ,
80
- default: false
80
+ default: false ,
81
81
},
82
82
endpoint: {
83
83
type: String ,
84
- required: true
84
+ required: true ,
85
85
},
86
86
receiver: {
87
- type: String
87
+ type: String ,
88
88
},
89
89
showHeader: {
90
90
type: Boolean ,
91
- default: true
91
+ default: true ,
92
92
},
93
93
showChannelList: {
94
94
type: Boolean ,
95
- default: false
95
+ default: false ,
96
96
},
97
97
showSuggestButton: {
98
98
type: Boolean ,
99
- default: true
99
+ default: true ,
100
100
},
101
101
httpOptions: {
102
102
type: Object ,
103
103
default () {
104
104
return {};
105
- }
105
+ },
106
106
},
107
107
httpMethod: {
108
- type: Function
108
+ type: Function ,
109
109
},
110
110
isExpanded: {
111
111
type: Boolean ,
112
- default: false
112
+ default: false ,
113
113
},
114
114
externalChannelHandle: {
115
115
type: Boolean ,
116
- default: false
116
+ default: false ,
117
117
},
118
118
user: {
119
119
type: String ,
120
- default: " "
121
- }
120
+ default: " " ,
121
+ },
122
122
},
123
123
data () {
124
124
return {
125
125
client: null ,
126
126
channels: [],
127
127
activeChannel: null ,
128
- userContext: { identity: null }
128
+ userContext: { identity: null },
129
129
};
130
130
},
131
131
watch: {
132
132
receiver () {
133
133
this .unlistenEvents ();
134
- }
134
+ },
135
135
},
136
136
computed: {
137
137
isLoggedIn () {
138
138
return this .userContext .identity ;
139
- }
139
+ },
140
140
},
141
141
beforeDestroy () {
142
142
this .unlistenEvents ();
143
143
},
144
144
methods: {
145
- async createClient (data ) {
146
- const client = await Twilio .Client .create (data[this .tokenField ], {
147
- logLevel: " info"
148
- });
149
- this .userContext = {
150
- ... data,
151
- identity: client .user .identity ,
152
- user: client .user
153
- };
154
- this .client = client;
145
+ createClient (data ) {
146
+ Twilio .Client .create (data[this .tokenField ], {
147
+ logLevel: " info" ,
148
+ }). then (( client ) => {
149
+ this .userContext = {
150
+ ... data,
151
+ identity: client .user .identity ,
152
+ user: client .user ,
153
+ };
154
+ this .client = client;
155
155
156
- client .on (" tokenAboutToExpire" , this .onTokenAboutToExpire );
157
- this .loadChannelEvents (client);
158
- this .updateChannels ();
156
+ client .on (" tokenAboutToExpire" , this .onTokenAboutToExpire );
157
+ this .loadChannelEvents (client);
158
+ this .updateChannels ();
159
+ });
159
160
},
160
161
161
162
async loadChannel () {
162
163
if (! this .activeChannel && ! this .showChannelList ) {
163
- const channel = this .channels .find (channel => {
164
+ const channel = this .channels .find (( channel ) => {
164
165
return channel .sid == this .userContext .channel_sid ;
165
166
});
166
167
@@ -194,7 +195,7 @@ export default {
194
195
195
196
const subscribed = await this .client
196
197
.getSubscribedChannels ({ limit: 100 })
197
- .then (page => {
198
+ .then (( page ) => {
198
199
return this .appendChannels (page, []);
199
200
});
200
201
this .channels = subscribed;
@@ -216,7 +217,7 @@ export default {
216
217
},
217
218
218
219
loadChannelEvents (client ) {
219
- client .on (" channelJoined" , channel => {
220
+ client .on (" channelJoined" , ( channel ) => {
220
221
channel .on (" messageAdded" , () => {
221
222
this .updateChannels ();
222
223
});
@@ -232,7 +233,7 @@ export default {
232
233
233
234
unlistenEvents () {
234
235
if (this .client ) {
235
- this .client .removeListener (" channelJoined" , channel => {
236
+ this .client .removeListener (" channelJoined" , ( channel ) => {
236
237
channel .removeListener (" messageAdded" , () => {
237
238
this .updateChannels ();
238
239
});
@@ -269,8 +270,8 @@ export default {
269
270
270
271
sendMessage (message , attributes ) {
271
272
this .$refs .messenger .sendMessage (message, attributes);
272
- }
273
- }
273
+ },
274
+ },
274
275
};
275
276
</script >
276
277
0 commit comments