@aochuang/client-sdk 1.0.379-wework-5 → 1.0.379-wework-7
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.
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
:initialSize="initialSize"
|
|
10
10
|
:minSize="270"
|
|
11
11
|
:maxSize="480"
|
|
12
|
+
:hidePanel="hideAddon"
|
|
12
13
|
@change="handleSizeChange"
|
|
13
14
|
>
|
|
14
15
|
<template slot="content">
|
|
@@ -41,6 +42,10 @@ export default {
|
|
|
41
42
|
},
|
|
42
43
|
hideSidebar: {
|
|
43
44
|
type: Boolean
|
|
45
|
+
},
|
|
46
|
+
// 隐藏addon区域(包括拖拽条)
|
|
47
|
+
hideAddon: {
|
|
48
|
+
type: Boolean
|
|
44
49
|
}
|
|
45
50
|
},
|
|
46
51
|
methods: {
|
package/package.json
CHANGED
|
@@ -95,6 +95,15 @@ export default class ClientChatAccount {
|
|
|
95
95
|
this.addAccount(item)
|
|
96
96
|
})
|
|
97
97
|
}
|
|
98
|
+
// 重新加载后账号对象都被替换了,当前账号需要指向新对象,账号已经不存在了就置为null(界面上选择全部企微号)
|
|
99
|
+
const currentAccount = this.data.currentAccount
|
|
100
|
+
if (currentAccount) {
|
|
101
|
+
if (this.accountMap[currentAccount.id]) {
|
|
102
|
+
this.data.currentAccount = this.accountMap[currentAccount.id]
|
|
103
|
+
} else {
|
|
104
|
+
this.setCurrentAccount(null)
|
|
105
|
+
}
|
|
106
|
+
}
|
|
98
107
|
}
|
|
99
108
|
|
|
100
109
|
getAccountData () {
|
|
@@ -341,20 +341,25 @@ class ClientChat {
|
|
|
341
341
|
}
|
|
342
342
|
const tasks = []
|
|
343
343
|
const removedTasks = []
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
344
|
+
const addedAccountIds = contacts
|
|
345
|
+
.filter(contact => contact && Number(contact.changeType) === 1)
|
|
346
|
+
.map(contact => contact.qwAccountId || data.qwAccountId)
|
|
347
|
+
return this.reloadAccountDataIfMissing(addedAccountIds).then(newAccountMap => {
|
|
348
|
+
contacts.forEach(contact => {
|
|
349
|
+
if (!contact) {
|
|
350
|
+
return
|
|
351
|
+
}
|
|
352
|
+
const changeType = Number(contact.changeType)
|
|
353
|
+
if (changeType === 1) {
|
|
354
|
+
tasks.push(this.handleQwContactAdded(contact, data, newAccountMap))
|
|
355
|
+
} else if (changeType === 2) {
|
|
356
|
+
tasks.push(this.handleQwContactUpdated(contact))
|
|
357
|
+
} else if (changeType === 3) {
|
|
358
|
+
removedTasks.push(this.handleQwContactRemoved(contact, data))
|
|
359
|
+
}
|
|
360
|
+
})
|
|
361
|
+
return Promise.all(tasks.concat(removedTasks))
|
|
362
|
+
}).then(results => {
|
|
358
363
|
const accountUnreadCountMap = {}
|
|
359
364
|
removedTasks.forEach((task, index) => {
|
|
360
365
|
const result = results[tasks.length + index]
|
|
@@ -383,20 +388,25 @@ class ClientChat {
|
|
|
383
388
|
}
|
|
384
389
|
const tasks = []
|
|
385
390
|
const removedTasks = []
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
391
|
+
const addedAccountIds = rooms
|
|
392
|
+
.filter(room => room && Number(room.changeType) === 1)
|
|
393
|
+
.map(room => room.qwAccountId || data.qwAccountId)
|
|
394
|
+
return this.reloadAccountDataIfMissing(addedAccountIds).then(newAccountMap => {
|
|
395
|
+
rooms.forEach(room => {
|
|
396
|
+
if (!room) {
|
|
397
|
+
return
|
|
398
|
+
}
|
|
399
|
+
const changeType = Number(room.changeType)
|
|
400
|
+
if (changeType === 1) {
|
|
401
|
+
tasks.push(this.handleQwRoomAdded(room, data, newAccountMap))
|
|
402
|
+
} else if (changeType === 2) {
|
|
403
|
+
tasks.push(this.handleQwRoomUpdated(room))
|
|
404
|
+
} else if (changeType === 3) {
|
|
405
|
+
removedTasks.push(this.handleQwRoomRemoved(room, data))
|
|
406
|
+
}
|
|
407
|
+
})
|
|
408
|
+
return Promise.all(tasks.concat(removedTasks))
|
|
409
|
+
}).then(results => {
|
|
400
410
|
return this.updateRemovedSessionUnreadCounts(
|
|
401
411
|
results.slice(tasks.length)
|
|
402
412
|
)
|
|
@@ -495,7 +505,32 @@ class ClientChat {
|
|
|
495
505
|
}))
|
|
496
506
|
}
|
|
497
507
|
|
|
498
|
-
|
|
508
|
+
/**
|
|
509
|
+
* 新增联系人/群聊所属的企微号不在当前企微号列表里时(例如客服原来一个企微号都没有,后台分配后),需要重新加载企微号列表
|
|
510
|
+
* 返回新加载出来的企微号id map,新企微号的未读数会在onAccountAdded里以服务端为准刷新,不需要再本地累加
|
|
511
|
+
*/
|
|
512
|
+
reloadAccountDataIfMissing (qwAccountIds) {
|
|
513
|
+
// 先等正在进行的加载完成,避免reloadData把初始化中的加载请求取消掉
|
|
514
|
+
return Promise.resolve(this.account._cacheLoadPromise).catch(() => {}).then(() => {
|
|
515
|
+
const missingAccountIds = (qwAccountIds || []).filter((id, index, data) => {
|
|
516
|
+
return id && data.indexOf(id) === index && !this.account.accountMap[id]
|
|
517
|
+
})
|
|
518
|
+
if (!missingAccountIds.length) {
|
|
519
|
+
return {}
|
|
520
|
+
}
|
|
521
|
+
return this.account.reloadData().then(() => {
|
|
522
|
+
return missingAccountIds.reduce((rs, id) => {
|
|
523
|
+
rs[id] = true
|
|
524
|
+
return rs
|
|
525
|
+
}, {})
|
|
526
|
+
})
|
|
527
|
+
}).catch(error => {
|
|
528
|
+
console.warn('[client-chat] reload account data failed', error)
|
|
529
|
+
return {}
|
|
530
|
+
})
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
handleQwContactAdded (contact, eventData, newAccountMap) {
|
|
499
534
|
const qwAccountId = contact.qwAccountId || (eventData && eventData.qwAccountId)
|
|
500
535
|
const corpId = this.getQwAccountCorpId(
|
|
501
536
|
qwAccountId,
|
|
@@ -509,12 +544,12 @@ class ClientChat {
|
|
|
509
544
|
}
|
|
510
545
|
const localSession = this.session.getSessionByLocal(sessionId)
|
|
511
546
|
const oldUnread = localSession ? (localSession.unreadMsgCount || 0) : 0
|
|
512
|
-
return this.session.
|
|
547
|
+
return this.session.getSession(sessionId).then(rs => {
|
|
513
548
|
const serverSession = rs && rs.data
|
|
514
549
|
const newUnread = serverSession ? (serverSession.unreadMsgCount || 0) : 0
|
|
515
550
|
const accountId = (serverSession && serverSession.qwAccountId) || qwAccountId
|
|
516
551
|
const unreadDiff = newUnread - oldUnread
|
|
517
|
-
if (accountId && unreadDiff) {
|
|
552
|
+
if (accountId && unreadDiff && !(newAccountMap && newAccountMap[accountId])) {
|
|
518
553
|
return this.account.updateAccountUnreadMessageNum(accountId, ({ unreadMesasgeNum }) => {
|
|
519
554
|
return Math.max(0, unreadMesasgeNum + unreadDiff)
|
|
520
555
|
})
|
|
@@ -567,7 +602,7 @@ class ClientChat {
|
|
|
567
602
|
})
|
|
568
603
|
}
|
|
569
604
|
|
|
570
|
-
handleQwRoomAdded (room, eventData) {
|
|
605
|
+
handleQwRoomAdded (room, eventData, newAccountMap) {
|
|
571
606
|
if (!room.roomId) {
|
|
572
607
|
return Promise.resolve()
|
|
573
608
|
}
|
|
@@ -580,11 +615,11 @@ class ClientChat {
|
|
|
580
615
|
console.warn('[client-chat] refresh added room failed', error)
|
|
581
616
|
})]
|
|
582
617
|
if (sessionId) {
|
|
583
|
-
tasks.push(this.session.
|
|
618
|
+
tasks.push(this.session.getSession(sessionId).then(rs => {
|
|
584
619
|
const serverSession = rs && rs.data
|
|
585
620
|
const unreadDiff = (serverSession ? (serverSession.unreadMsgCount || 0) : 0) - oldUnread
|
|
586
621
|
const changedAccountId = (serverSession && serverSession.qwAccountId) || qwAccountId
|
|
587
|
-
if (changedAccountId && unreadDiff) {
|
|
622
|
+
if (changedAccountId && unreadDiff && !(newAccountMap && newAccountMap[changedAccountId])) {
|
|
588
623
|
return this.account.updateAccountUnreadMessageNum(changedAccountId, ({ unreadMesasgeNum }) => {
|
|
589
624
|
return Math.max(0, unreadMesasgeNum + unreadDiff)
|
|
590
625
|
})
|