@subiz/widget-v4 4.0.67 → 4.0.68

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -24,7 +24,7 @@ _index.default.preloadWebfonts(['Roboto'], [400, 500]);
24
24
 
25
25
  class Widget {
26
26
  constructor(ApiURL, FileURL, RealtimeURL, inmem, fake, agenttoken) {
27
- _defineProperty(this, "version", () => '4.4');
27
+ _defineProperty(this, "version", () => '4.5');
28
28
 
29
29
  _defineProperty(this, "setSetting", setting => this.store.setSetting({
30
30
  account_setting: setting
@@ -108,7 +108,21 @@ class Widget {
108
108
  }
109
109
 
110
110
  async sendMessage(convoid, message) {
111
- this.store.sendConvoEvent(convoid, 'message_sent', {
111
+ if (!convoid) {
112
+ const {
113
+ convo,
114
+ error
115
+ } = await this.store.startConvo({
116
+ message: message.text,
117
+ initial_by: this.store.matchUser().id
118
+ });
119
+ if (error) return {
120
+ error
121
+ };
122
+ convoid = convo.id;
123
+ }
124
+
125
+ return this.store.sendConvoEvent(convoid, 'message_sent', {
112
126
  message
113
127
  });
114
128
  }
@@ -127,11 +141,11 @@ class Widget {
127
141
  this.pluginMgr.hideCurrentGreeting();
128
142
  }
129
143
 
130
- async showWidget(view, convo) {
144
+ async showWidget(view, cid) {
131
145
  await this.domGate.entry();
132
146
  this.pluginMgr.showCurrentChatbox({
133
147
  view,
134
- cid: convo
148
+ cid: cid
135
149
  });
136
150
  }
137
151
 
@@ -920,6 +920,7 @@ class Store {
920
920
  }
921
921
 
922
922
  this.kv.put('last_msg_sent', _index.default.Date.now());
923
+ return ret;
923
924
  }
924
925
 
925
926
  _setConvo(convo) {
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes