@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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@subiz/widget-v4",
3
- "version": "4.0.67",
3
+ "version": "4.0.68",
4
4
  "main": "./compiled_src/lib.js",
5
5
  "scripts": {
6
6
  "dev": "npx webpack serve --config webpack.dev.js",
package/src/lib.js CHANGED
@@ -85,7 +85,15 @@ class Widget {
85
85
  }
86
86
 
87
87
  async sendMessage(convoid, message) {
88
- this.store.sendConvoEvent(convoid, 'message_sent', {message})
88
+ if (!convoid) {
89
+ const {convo, error} = await this.store.startConvo({
90
+ message: message.text,
91
+ initial_by: this.store.matchUser().id,
92
+ })
93
+ if (error) return {error}
94
+ convoid = convo.id
95
+ }
96
+ return this.store.sendConvoEvent(convoid, 'message_sent', {message})
89
97
  }
90
98
 
91
99
  startConvo(req) {
@@ -102,9 +110,10 @@ class Widget {
102
110
  this.pluginMgr.hideCurrentGreeting()
103
111
  }
104
112
 
105
- async showWidget(view, convo) {
113
+ // view could be: chat, list, offline_form
114
+ async showWidget(view, cid) {
106
115
  await this.domGate.entry()
107
- this.pluginMgr.showCurrentChatbox({view, cid: convo})
116
+ this.pluginMgr.showCurrentChatbox({view, cid: cid})
108
117
  }
109
118
 
110
119
  async hideWidget() {
@@ -112,7 +121,7 @@ class Widget {
112
121
  this.pluginMgr.hideCurrentChatbox()
113
122
  }
114
123
 
115
- version = () => '4.4'
124
+ version = () => '4.5'
116
125
 
117
126
  setSetting = (setting) => this.store.setSetting({account_setting: setting})
118
127
  getSetting = (_) => ({account_setting: sb.cloneDeep(this.store.matchAccountSetting())})
@@ -824,6 +824,7 @@ export default class Store {
824
824
  }
825
825
 
826
826
  this.kv.put('last_msg_sent', sb.Date.now())
827
+ return ret
827
828
  }
828
829
 
829
830
  onConvoEvent = (o, cb) => this.pubsub.on2(o, 'events', cb)