Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-im
提交
beae4161
U
uni-im
项目概览
DCloud
/
uni-im
通知
3
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-im
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
beae4161
编写于
5月 11, 2024
作者:
DCloud_JSON
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修复 当群公告被刷屏,导致后打开会话的用户看不到的问题
上级
f5fc925f
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
47 addition
and
16 deletion
+47
-16
components/uni-im-msg-list/uni-im-msg-list.vue
components/uni-im-msg-list/uni-im-msg-list.vue
+34
-12
sdk/ext/MsgManager.class.js
sdk/ext/MsgManager.class.js
+2
-2
uniCloud/database/uni-im-conversation.schema.ext.js
uniCloud/database/uni-im-conversation.schema.ext.js
+1
-2
uniCloud/database/uni-im-conversation.schema.json
uniCloud/database/uni-im-conversation.schema.json
+5
-0
uniCloud/database/uni-im-group.schema.ext.js
uniCloud/database/uni-im-group.schema.ext.js
+5
-0
未找到文件。
components/uni-im-msg-list/uni-im-msg-list.vue
浏览文件 @
beae4161
...
@@ -53,7 +53,7 @@
...
@@ -53,7 +53,7 @@
<view
v-if=
"call_list.length"
class=
"showCallMe"
@
click=
"showCallMe"
>
@回复我({{call_list.length}})
</view>
<view
v-if=
"call_list.length"
class=
"showCallMe"
@
click=
"showCallMe"
>
@回复我({{call_list.length}})
</view>
<uni-popup
@
change=
"
closeGroupNotification
"
ref=
"group-notification-popup"
type=
"center"
class=
"group-notification-popup"
>
<uni-popup
@
change=
"
$event.show?'':closeGroupNotification()
"
ref=
"group-notification-popup"
type=
"center"
class=
"group-notification-popup"
>
<uni-im-group-notification
ref=
"group-notification"
></uni-im-group-notification>
<uni-im-group-notification
ref=
"group-notification"
></uni-im-group-notification>
</uni-popup>
</uni-popup>
...
@@ -161,7 +161,12 @@
...
@@ -161,7 +161,12 @@
data
()
{
data
()
{
return
{
return
{
val
:
0
,
val
:
0
,
conversation
:
{},
conversation
:
{
has_unread_group_notification
:
false
,
group_info
:
{
notification
:
false
}
},
scrollIntoView
:
""
,
scrollIntoView
:
""
,
scrollTop
:
0
,
scrollTop
:
0
,
scrollTracker
:
new
ScrollTracker
(),
scrollTracker
:
new
ScrollTracker
(),
...
@@ -177,20 +182,23 @@
...
@@ -177,20 +182,23 @@
'
conversation.call_list
'
(
call_list
)
{
'
conversation.call_list
'
(
call_list
)
{
this
.
call_list
=
call_list
this
.
call_list
=
call_list
},
},
'
conversation.unreadGroupNotification
'
:
{
'
conversation.has_unread_group_notification
'
:
{
handler
(
unreadGroupNotification
)
{
async
handler
(
hasUnreadGroupNotification
)
{
const
group_notification
=
this
.
conversation
?.
group_info
?.
notification
// 弹出群公告
// 弹出群公告
if
(
unreadGroupNotification
&&
unreadGroupNotification
.
content
)
{
if
(
hasUnreadGroupNotification
&&
group_notification
&&
group_notification
.
content
)
{
await
uniIm
.
utils
.
sleep
(
1000
)
// 判断列表中是否已经渲染了此群公告,是则 call 当前用户。否则弹框提示
// 判断列表中是否已经渲染了此群公告,是则 call 当前用户。否则弹框提示
let
groupNotificationMsg
=
[...
this
.
visibleMsgList
].
reverse
().
find
(
msg
=>
msg
.
action
===
let
groupNotificationMsg
=
[...
this
.
visibleMsgList
].
reverse
().
find
(
msg
=>
msg
.
action
===
'
update-group-info-notification
'
)
'
update-group-info-notification
'
)
console
.
log
(
'
groupNotificationMsg
'
,
groupNotificationMsg
);
// console.log('groupNotificationMsg', groupNotificationMsg,this.visibleMsgList
);
if
(
groupNotificationMsg
)
{
if
(
groupNotificationMsg
)
{
this
.
conversation
.
call_list
.
push
(
groupNotificationMsg
.
_id
)
this
.
conversation
.
call_list
.
push
(
groupNotificationMsg
.
_id
)
this
.
closeGroupNotification
()
}
else
{
}
else
{
this
.
$refs
[
"
group-notification-popup
"
].
open
()
this
.
$refs
[
"
group-notification-popup
"
].
open
()
this
.
$nextTick
(()
=>
{
this
.
$nextTick
(()
=>
{
this
.
$refs
[
"
group-notification
"
].
notification
=
unreadGroupN
otification
this
.
$refs
[
"
group-notification
"
].
notification
=
group_n
otification
})
})
}
}
}
}
...
@@ -562,14 +570,28 @@
...
@@ -562,14 +570,28 @@
// 如果是显示群公告,则设置未读的群公告内容为 false
// 如果是显示群公告,则设置未读的群公告内容为 false
if
(
this
.
visibleMsgList
[
index
].
action
===
"
update-group-info-notification
"
)
{
if
(
this
.
visibleMsgList
[
index
].
action
===
"
update-group-info-notification
"
)
{
this
.
c
onversation
.
unreadGroupNotification
=
false
this
.
c
loseGroupNotification
()
}
}
},
},
closeGroupNotification
(
e
)
{
closeGroupNotification
()
{
if
(
e
.
show
===
false
)
{
// console.log('######关闭群公告',this.conversationId)
this
.
conversation
.
unreadGroupNotification
=
false
}
const
db
=
uniCloud
.
database
();
db
.
collection
(
'
uni-im-conversation
'
)
.
where
({
id
:
this
.
conversationId
,
user_id
:
uniCloud
.
getCurrentUserInfo
().
uid
})
.
update
({
has_unread_group_notification
:
false
}).
then
(
res
=>
{
this
.
conversation
.
has_unread_group_notification
=
false
// console.log('关闭群公告成功', res)
}).
catch
(
err
=>
{
console
.
error
(
'
关闭群公告失败
'
,
err
)
})
},
},
isChecked
(
msg
)
{
isChecked
(
msg
)
{
return
this
.
checkedMsgList
.
some
(
i
=>
i
.
_id
===
msg
.
_id
)
return
this
.
checkedMsgList
.
some
(
i
=>
i
.
_id
===
msg
.
_id
)
...
...
sdk/ext/MsgManager.class.js
浏览文件 @
beae4161
...
@@ -360,7 +360,7 @@ export default class Message {
...
@@ -360,7 +360,7 @@ export default class Message {
//重新拉取 群成员
//重新拉取 群成员
await
uniIm
.
group
.
loadMember
(
_currentConversation
.
group_id
)
await
uniIm
.
group
.
loadMember
(
_currentConversation
.
group_id
)
// 获取群公告
// 获取群公告
_currentConversation
.
unreadGroupNotification
=
_currentConversation
.
group_info
.
notification
_currentConversation
.
has_unread_group_notification
=
!!
_currentConversation
.
group_info
.
notification
}
else
{
}
else
{
// 将新成员加入到群成员列表
// 将新成员加入到群成员列表
for
(
let
i
=
0
;
i
<
new_member_list
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
new_member_list
.
length
;
i
++
)
{
...
@@ -390,7 +390,7 @@ export default class Message {
...
@@ -390,7 +390,7 @@ export default class Message {
const
{
notification
}
=
data
.
body
.
updateData
const
{
notification
}
=
data
.
body
.
updateData
if
(
data
.
action
===
"
update-group-info-notification
"
){
if
(
data
.
action
===
"
update-group-info-notification
"
){
console
.
log
(
'
收到群公告
'
);
console
.
log
(
'
收到群公告
'
);
_currentConversation
.
unreadGroupNotification
=
notification
_currentConversation
.
has_unread_group_notification
=
true
}
}
}
else
if
(
data
.
action
===
"
set-group-admin
"
){
}
else
if
(
data
.
action
===
"
set-group-admin
"
){
const
{
user_id
,
addRole
,
delRole
}
=
data
.
body
const
{
user_id
,
addRole
,
delRole
}
=
data
.
body
...
...
uniCloud/database/uni-im-conversation.schema.ext.js
浏览文件 @
beae4161
...
@@ -57,7 +57,7 @@ module.exports = {
...
@@ -57,7 +57,7 @@ module.exports = {
},
},
async
beforeUpdate
({
where
,
updateData
,
userInfo
}){
async
beforeUpdate
({
where
,
updateData
,
userInfo
}){
//只开放部分字段
//只开放部分字段
let
canUpdateField
=
[
"
unread_count
"
,
"
pinned
"
,
"
hidden
"
,
"
mute
"
]
let
canUpdateField
=
[
"
unread_count
"
,
"
pinned
"
,
"
hidden
"
,
"
mute
"
,
"
has_unread_group_notification
"
]
Object
.
keys
(
updateData
).
forEach
(
field
=>
{
Object
.
keys
(
updateData
).
forEach
(
field
=>
{
if
(
!
canUpdateField
.
includes
(
field
)){
if
(
!
canUpdateField
.
includes
(
field
)){
throw
new
Error
(
'
uni-im-conversation.schema.ext.js beforeUpdate:限制只能更新的字段:
'
+
canUpdateField
.
join
(
'
,
'
))
throw
new
Error
(
'
uni-im-conversation.schema.ext.js beforeUpdate:限制只能更新的字段:
'
+
canUpdateField
.
join
(
'
,
'
))
...
@@ -76,7 +76,6 @@ module.exports = {
...
@@ -76,7 +76,6 @@ module.exports = {
}).
update
({
}).
update
({
is_read
:
true
is_read
:
true
})
})
// console.log('uni-im-conversation beforeUpdate res:',res);
// console.log('uni-im-conversation beforeUpdate res:',res);
}
}
},
},
...
...
uniCloud/database/uni-im-conversation.schema.json
浏览文件 @
beae4161
...
@@ -86,6 +86,11 @@
...
@@ -86,6 +86,11 @@
"bsonType"
:
"bool"
,
"bsonType"
:
"bool"
,
"description"
:
"是否免打扰(右键设置会话消息免打扰)"
,
"description"
:
"是否免打扰(右键设置会话消息免打扰)"
,
"defaultValue"
:
false
"defaultValue"
:
false
},
"has_unread_group_notification"
:{
"bsonType"
:
"bool"
,
"description"
:
"是否有未读的群通知"
,
"defaultValue"
:
false
}
}
}
}
}
}
\ No newline at end of file
uniCloud/database/uni-im-group.schema.ext.js
浏览文件 @
beae4161
...
@@ -26,6 +26,11 @@ module.exports = {
...
@@ -26,6 +26,11 @@ module.exports = {
if
(
field
==
'
notification
'
){
if
(
field
==
'
notification
'
){
// 如果是群公告,增加一个公告的创建时间
// 如果是群公告,增加一个公告的创建时间
updateData
[
field
].
create_time
=
Date
.
now
()
updateData
[
field
].
create_time
=
Date
.
now
()
await
db
.
collection
(
'
uni-im-conversation
'
).
where
({
group_id
,
}).
update
({
has_unread_group_notification
:
true
})
}
}
},
},
async
afterUpdate
({
where
,
updateData
,
clientInfo
,
userInfo
}){
async
afterUpdate
({
where
,
updateData
,
clientInfo
,
userInfo
}){
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录