Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
foreign
/
customer-service
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
8620aa88
authored
Dec 01, 2021
by
Sixong.Zhu
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
update unread method
parent
8082d7a8
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
56 additions
and
12 deletions
components/message.vue
store/index.ts
store/model.ts
xim/xim.ts
components/message.vue
View file @
8620aa88
...
...
@@ -27,8 +27,11 @@
:class=
"
{ all: isAllRead }"
>
<template
v-if=
"isAllRead"
>
全部已读
</
template
>
<
template
v-else-if=
"data.read_count > 0"
>
{{
data
.
read_count
}}
人已读
</
template
<
template
v-else-if=
"manualReaded || data.read_count"
>
{{
manualReaded
||
data
.
read_count
}}
人已读
</
template
>
<
template
v-else
>
未读
</
template
>
</span>
...
...
@@ -151,7 +154,6 @@
import
PurchasePlanMessage
from
"./message-item/purchase-plan-message.vue"
;
import
MyWelfareMessage
from
"./message-item/my-welfare-message.vue"
;
import
QuestionAnswerMessage
from
"./message-item/question-answer-message.vue"
;
import
xim
from
"./../xim"
;
import
{
ChatRole
}
from
"@/customer-service/model"
;
import
{
getUserMapping
}
from
"../utils/user-info"
;
import
Xim
from
"@/customer-service/xim"
;
...
...
@@ -210,6 +212,9 @@
@
chatStore
.
State
(
ChatStore
.
STATE_CHAT_CURRENT_IS_CHAT_MEMBER
)
private
readonly
isChatMember
!
:
ChatStore
.
STATE_CHAT_CURRENT_IS_CHAT_MEMBER
;
@
chatStore
.
Action
(
ChatStore
.
ACTION_UPDATE_MESSAGE_READ_STATUS
)
private
readonly
updateMessage
!
:
ChatStore
.
ACTION_UPDATE_MESSAGE_READ_STATUS
;
@
Prop
({
type
:
Object
,
default
:
()
=>
Object
.
create
(
null
)
})
private
readonly
data
!
:
dto
.
Message
;
...
...
@@ -231,6 +236,8 @@
private
readListVisibility
=
false
;
private
org
=
""
;
private
manualAllRead
=
false
;
private
manualReaded
=
0
;
private
readerListOffset
=
false
;
private
defaultMessageHandledStatus
=
dto
.
MessageHandled
.
Default
;
...
...
@@ -253,7 +260,10 @@
}
private
get
isAllRead
()
{
return
this
.
data
.
read_count
>=
this
.
data
.
total_read_count
;
return
(
this
.
manualAllRead
||
this
.
data
.
read_count
>=
this
.
data
.
total_read_count
);
}
private
get
messageBody
():
{
eid
?:
string
;
oid
?:
string
;
msg
:
any
}
{
...
...
@@ -326,7 +336,7 @@
}
private
get
defaultAvatar
()
{
return
x
im
.
getAvatar
();
return
X
im
.
getAvatar
();
}
private
get
chatRole
()
{
...
...
@@ -381,7 +391,7 @@
if
(
this
.
isTextMessage
&&
!
this
.
isMyMessage
)
{
const
m
=
this
.
messageBody
.
msg
as
{
text
:
string
};
if
(
m
&&
m
.
text
)
{
const
keywords
=
x
im
.
getMatchedTextKeywords
();
const
keywords
=
X
im
.
getMatchedTextKeywords
();
return
keywords
.
find
((
i
)
=>
m
.
text
.
includes
(
i
));
}
}
...
...
@@ -390,6 +400,27 @@
created
()
{
this
.
messageComponent
=
messageMapping
.
get
(
this
.
messageType
)
as
string
;
if
(
Xim
.
isBackend
())
{
this
.
data
&&
!
this
.
isAllRead
&&
ximInstance
.
queryNextPageMsg
(
"group"
,
this
.
chatId
,
this
.
data
.
id
-
1
,
1
)
.
then
((
m
)
=>
{
if
(
m
&&
m
.
length
)
{
const
t
=
m
[
0
];
t
.
read_count
&&
t
.
read_count
!==
this
.
data
.
read_count
&&
this
.
updateMessage
({
chat
:
this
.
chatId
,
start
:
this
.
data
.
id
,
all
:
(
this
.
manualAllRead
=
t
.
read_count
===
t
.
total_read_count
),
readed
:
(
this
.
manualReaded
=
t
.
read_count
),
});
}
});
}
}
private
isCustomer
()
{
...
...
store/index.ts
View file @
8620aa88
...
...
@@ -205,11 +205,14 @@ export default {
);
},
[
ChatStore
.
MUTATION_SAVE_MYSELF_ID
](
state
)
{
if
(
!
state
[
ChatStore
.
STATE_CHAT_MY_ID
])
{
Chat
.
getToken
().
then
((
token
)
=>
{
const
eid
=
decodeJwt
<
{
user_id
:
string
;
sub
:
string
}
>
(
token
);
const
eid
=
decodeJwt
<
{
user_id
:
string
;
sub
:
string
}
>
(
token
);
state
[
ChatStore
.
STATE_CHAT_MY_ID
]
=
String
(
eid
.
user_id
);
state
[
ChatStore
.
STATE_CHAT_MY_UID
]
=
eid
.
sub
;
});
}
},
[
ChatStore
.
MUTATION_CLEAR_MYSELF_ID
](
state
)
{
state
[
ChatStore
.
STATE_CHAT_MY_ID
]
=
null
;
...
...
@@ -390,6 +393,8 @@ export default {
},
actions
:
{
async
[
ChatStore
.
ACTION_GET_MY_CHAT_LIST
]({
commit
,
state
})
{
commit
(
ChatStore
.
MUTATION_SAVE_MYSELF_ID
);
let
cache
=
await
dbController
.
getChatList
();
cache
.
sort
((
x
,
y
)
=>
(
x
.
last_msg_ts
<
y
.
last_msg_ts
?
1
:
-
1
));
...
...
@@ -1072,6 +1077,7 @@ export default {
start
:
number
;
end
?:
number
;
all
?:
boolean
;
readed
?:
number
;
}
)
=>
{
const
items
=
state
[
ChatStore
.
STATE_CHAT_MSG_HISTORY
]
as
Message
[];
...
...
@@ -1082,6 +1088,8 @@ export default {
if
(
p
)
{
p
.
read_count
=
option
.
all
?
p
.
total_read_count
:
option
.
readed
?
option
.
readed
:
p
.
read_count
+
1
;
}
}
...
...
@@ -1090,16 +1098,20 @@ export default {
if
(
p
)
{
p
.
read_count
=
option
.
all
?
p
.
total_read_count
:
option
.
readed
?
option
.
readed
:
p
.
read_count
+
1
;
}
}
}
return
dbController
.
setMessageReaded
(
option
.
chat
,
{
return
dbController
.
setMessageReaded
(
option
.
chat
,
{
start
:
option
.
start
,
end
:
option
.
end
,
allRead
:
option
.
all
,
});
})
.
then
(()
=>
(
state
[
ChatStore
.
STATE_CHAT_MSG_HISTORY
]
=
items
));
},
},
getters
:
{
...
...
store/model.ts
View file @
8620aa88
...
...
@@ -364,6 +364,7 @@ export namespace ChatStore {
start
:
number
;
end
?:
number
;
all
?:
boolean
;
readed
?:
number
;
})
=>
Promise
<
void
>
;
export
interface
ChatUpdateParameter
{
...
...
xim/xim.ts
View file @
8620aa88
...
...
@@ -166,13 +166,13 @@ export class Xim {
rid
=
0
,
limit
=
DefaultMsgPageSize
,
desc
:
boolean
,
p
:
{
isMember
:
boolean
;
model
:
string
;
obj
:
string
}
p
?
:
{
isMember
:
boolean
;
model
:
string
;
obj
:
string
}
):
Promise
<
Message
[]
>
{
this
.
checkConnected
();
if
(
this
.
client
==
null
)
{
throw
new
Error
(
"client shouldn't undefined"
);
}
if
(
!
p
.
isMember
&&
p
.
model
&&
p
.
obj
)
{
if
(
p
&&
!
p
.
isMember
&&
p
.
model
&&
p
.
obj
)
{
return
this
.
queryMessageWhenIsNotMember
(
p
,
limit
,
lid
,
rid
,
desc
);
}
const
res
=
await
this
.
client
.
fetchChatMsgs
(
chatType
,
chatId
,
{
...
...
@@ -259,7 +259,7 @@ export class Xim {
chatId
:
number
,
msgId
:
number
,
limit
:
number
,
p
:
{
isMember
:
boolean
;
model
:
string
;
obj
:
string
}
p
?
:
{
isMember
:
boolean
;
model
:
string
;
obj
:
string
}
)
{
const
data
=
await
this
.
queryMsgs
(
chatType
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment