@aochuang/client-sdk 1.0.303 → 1.0.304

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.
@@ -256,17 +256,25 @@ export default {
256
256
  return
257
257
  }
258
258
  keyword = this.normalizeSuggestionsKeyword(nearestInfo, keyword)
259
+ const requestId = (this._suggestionsRequestId || 0) + 1
260
+ this._suggestionsRequestId = requestId
259
261
  this.suggestioning = true
260
262
  this.suggestionsKeyword = keyword
263
+ this.popoverActive = true
261
264
  clearTimeout(this._loadSuggestionsTimer)
262
265
  return this.fetchSuggestionsMethod({
263
266
  keyword,
264
267
  nearestInfo,
265
268
  isAtContext: !!(nearestInfo && nearestInfo.isAtContext)
266
269
  }).then(rs => {
270
+ if (requestId !== this._suggestionsRequestId) {
271
+ return
272
+ }
267
273
  this.suggestionsData = rs || []
268
274
  }).finally(() => {
269
- this.suggestioning = false
275
+ if (requestId === this._suggestionsRequestId) {
276
+ this.suggestioning = false
277
+ }
270
278
  })
271
279
  },
272
280
  normalizeSuggestionsKeyword (nearestInfo, keyword) {
@@ -278,7 +286,17 @@ export default {
278
286
  : nearest.replace(/^\s+/, '')
279
287
  },
280
288
  closeSuggestions () {
289
+ clearTimeout(this._loadSuggestionsTimer)
290
+ this._suggestionsRequestId = (this._suggestionsRequestId || 0) + 1
281
291
  this.$refs.suggestions && this.$refs.suggestions.close()
292
+ this.suggestioning = false
293
+ this.popoverActive = false
294
+ },
295
+ hasCurrentSuggestionsContext () {
296
+ const inputValue = this.getInputText()
297
+ const range = this.cacheInputRange || this.getSelectionTextRange()
298
+ const nearestInfo = getNearestString(inputValue, range.start)
299
+ return !!this.normalizeSuggestionsKeyword(nearestInfo)
282
300
  },
283
301
  closeSuggestionsAfterConfirm () {
284
302
  this.closeSuggestions()
@@ -846,8 +864,13 @@ export default {
846
864
  if (this._skipNextSuggestionsLoad) {
847
865
  this._skipNextSuggestionsLoad = false
848
866
  } else {
849
- this.popoverActive = true
850
- this.delayLoadSuggestions(this.inputValue)
867
+ if (this.hasCurrentSuggestionsContext()) {
868
+ this.popoverActive = false
869
+ this.delayLoadSuggestions(this.inputValue)
870
+ } else {
871
+ this.suggestionsNearsetInfo = null
872
+ this.closeSuggestions()
873
+ }
851
874
  }
852
875
  this.$emit('change', {
853
876
  value: this.inputValue,
@@ -861,14 +884,14 @@ export default {
861
884
  if (this.disabled) {
862
885
  return
863
886
  }
864
- this.popoverActive = true
887
+ this.popoverActive = this.hasCurrentSuggestionsContext()
865
888
  this.focus()
866
889
  },
867
890
  handleInputFocus () {
868
891
  if (this.disabled) {
869
892
  return
870
893
  }
871
- this.popoverActive = true
894
+ this.popoverActive = this.hasCurrentSuggestionsContext()
872
895
  this.focus()
873
896
  },
874
897
  clearInput () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aochuang/client-sdk",
3
- "version": "1.0.303",
3
+ "version": "1.0.304",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -839,10 +839,18 @@ export default class ClientChatContacts {
839
839
  throw new Error('群少群id')
840
840
  }
841
841
  if (data && data.length) {
842
- Vue.set(this.data.roomBindMemberMap, roomId, data)
842
+ if (!this.data.roomBindMemberMap[roomId]) {
843
+ Vue.set(this.data.roomBindMemberMap, roomId, [])
844
+ } else {
845
+ this.data.roomBindMemberMap[roomId].length = 0
846
+ }
847
+ data.forEach(v => {
848
+ this.data.roomBindMemberMap[roomId].push(v)
849
+ })
843
850
  } else {
844
851
  Vue.delete(this.data.roomBindMemberMap, roomId)
845
852
  }
853
+ return this.data.roomBindMemberMap[roomId]
846
854
  }
847
855
 
848
856
  loadRoomMemberData (roomId, params, refresh) {
@@ -851,8 +859,7 @@ export default class ClientChatContacts {
851
859
  }
852
860
  if (!this.loadRoomMemberDataPromiseMap[roomId] || refresh) {
853
861
  this.loadRoomMemberDataPromiseMap[roomId] = this.loadContactsRoomMemberDataMethod(params).then((rs) => {
854
- this.setRoomMemberData(roomId, rs.data)
855
- return rs.data
862
+ return this.setRoomMemberData(roomId, rs.data)
856
863
  })
857
864
  }
858
865
  return this.loadRoomMemberDataPromiseMap[roomId]