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
2aff577f
authored
Oct 21, 2021
by
Sixong.Zhu
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
update
parent
28d34715
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
12 deletions
components/message-list.vue
store/index.ts
xim/index.ts
components/message-list.vue
View file @
2aff577f
...
...
@@ -47,6 +47,7 @@
import
VideoPreview
from
"./video-preview.vue"
;
import
{
ChatStore
,
chatStore
}
from
"@/customer-service/store/model"
;
import
{
dbController
}
from
"../database"
;
import
{
getLastMessageId
}
from
"../store"
;
@
Component
({
components
:
{
message
,
ImagePreview
,
VideoPreview
}
})
export
default
class
MessageList
extends
Vue
{
...
...
@@ -323,7 +324,7 @@
if
(
msg
==
null
)
return
;
if
(
msg
.
length
===
0
)
return
;
this
.
startLoadingNew
();
const
msgId
=
msg
[
msg
.
length
-
1
].
id
;
const
msgId
=
getLastMessageId
(
msg
)
;
const
data
=
await
this
.
getNextPageMsg
(
msgId
);
if
(
data
.
length
===
0
)
{
// eslint-disable-next-line no-console
...
...
store/index.ts
View file @
2aff577f
...
...
@@ -31,7 +31,7 @@ function uniqueMessages(
messages
:
NonNullable
<
ChatStore
.
STATE_CHAT_MSG_HISTORY
>
)
{
const
arr
=
[...
messages
];
return
unique
(
arr
,
function
(
item
,
all
)
{
return
unique
(
arr
,
function
(
item
,
all
)
{
return
all
.
findIndex
((
k
)
=>
k
.
id
===
item
.
id
);
});
}
...
...
@@ -52,7 +52,9 @@ async function preCacheImgs(msgs?: any[]) {
return
Promise
.
resolve
();
}
await
Promise
.
all
(
msgs
.
filter
(
i
=>
i
.
id
>
0
).
map
((
k
)
=>
{
msgs
.
filter
((
i
)
=>
i
.
id
>
0
)
.
map
((
k
)
=>
{
return
new
Promise
((
resolve
:
(
p
:
void
)
=>
void
)
=>
{
if
(
k
.
type
===
"image"
)
{
const
msg
=
JSON
.
parse
(
k
.
msg
);
...
...
@@ -102,6 +104,15 @@ const filterActiveChats = (items: RawChatItem[]) => {
);
};
export
function
getLastMessageId
(
msgs
:
Message
[]
|
any
)
{
const
last
=
msgs
[
msgs
.
length
-
1
];
let
id
=
last
.
id
;
if
(
id
<
0
)
{
id
=
Math
.
max
(...
msgs
.
map
((
i
)
=>
i
.
id
));
}
return
id
;
}
export
default
{
namespaced
:
true
,
state
:
()
=>
({
...
...
@@ -315,7 +326,7 @@ export default {
state
[
ChatStore
.
STATE_CHAT_SENDING_MESSAGES
]
=
[...
current
];
}
},
[
ChatStore
.
MUTATION_SAVE_CURRENT_CHAT_INPUTING
]:
(
function
()
{
[
ChatStore
.
MUTATION_SAVE_CURRENT_CHAT_INPUTING
]:
(
function
()
{
const
setTimeoutId
:
{
[
key
:
string
]:
number
}
=
{};
return
(
state
:
ChatStoreState
,
...
...
@@ -513,11 +524,7 @@ export default {
if
(
msgs
==
null
||
msgs
.
length
===
0
)
{
newMsgsArr
=
await
dispatch
(
ChatStore
.
ACTION_GET_CHAT_MESSAGES
);
}
else
{
const
last
=
msgs
[
msgs
.
length
-
1
]
let
id
=
last
.
id
if
(
id
<
0
)
{
id
=
Math
.
max
(...
msgs
.
map
(
i
=>
i
.
id
))
}
const
id
=
getLastMessageId
(
msgs
);
newMsgsArr
=
await
dispatch
(
ChatStore
.
ACTION_GET_CHAT_MESSAGES_AFTER_SPECIFIC_ID
,
id
...
...
@@ -722,7 +729,7 @@ export default {
}
commit
(
ChatStore
.
MUTATION_SAVE_CURRENT_CHAT_MEMBERS
,
unique
(
newChatMembers
,
function
(
item
,
all
)
{
unique
(
newChatMembers
,
function
(
item
,
all
)
{
return
all
.
findIndex
((
k
)
=>
k
.
eid
===
item
.
eid
);
})
);
...
...
xim/index.ts
View file @
2aff577f
...
...
@@ -37,7 +37,8 @@ class Chat {
}
this
.
_sdk
=
option
.
sdk
;
this
.
_orgId
=
option
.
orgId
;
option
.
serviceType
!==
undefined
&&
(
this
.
serviceType
=
option
.
serviceType
);
option
.
serviceType
!==
undefined
&&
(
this
.
serviceType
=
option
.
serviceType
);
option
.
product
&&
(
this
.
product
=
option
.
product
);
this
.
eventHub
=
option
.
eventHub
||
null
;
if
(
option
.
user
)
{
...
...
@@ -47,7 +48,11 @@ class Chat {
};
}
dbController
.
setup
(
this
.
_sdk
().
global
.
uid
);
dbController
.
setup
(
this
.
_sdk
().
global
.
uid
+
"-"
+
(
this
.
_sdk
().
global
.
initData
.
orgId
||
0
)
);
this
.
token
=
async
()
=>
option
.
sdk
().
global
.
jwtToken
;
tokenManager
.
save
(
this
.
token
);
...
...
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