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
50e9105f
authored
Jan 10, 2022
by
Sixong.Zhu
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
移除个别的撤回处理,统一放到全局;新增列表自刷新功能
parent
d56b1d02
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
58 additions
and
49 deletions
components/controller/chat-list.ts
components/message-list.vue
components/message.vue
store/index.ts
components/controller/chat-list.ts
View file @
50e9105f
...
@@ -7,6 +7,8 @@ import { ChatUserInfoService } from "@/customer-service/utils/user-info";
...
@@ -7,6 +7,8 @@ import { ChatUserInfoService } from "@/customer-service/utils/user-info";
@
Component
({
components
:
{}
})
@
Component
({
components
:
{}
})
export
default
class
ChatList
extends
Vue
{
export
default
class
ChatList
extends
Vue
{
private
nextTimer
=
0
;
@
chatStore
.
Action
(
ChatStore
.
ACTION_GET_MY_CHAT_LIST
)
@
chatStore
.
Action
(
ChatStore
.
ACTION_GET_MY_CHAT_LIST
)
protected
readonly
getMyChatList
!
:
ChatStore
.
ACTION_GET_MY_CHAT_LIST
;
protected
readonly
getMyChatList
!
:
ChatStore
.
ACTION_GET_MY_CHAT_LIST
;
...
@@ -91,4 +93,18 @@ export default class ChatList extends Vue {
...
@@ -91,4 +93,18 @@ export default class ChatList extends Vue {
}
}
return
this
.
parseMesage
(
item
);
return
this
.
parseMesage
(
item
);
}
}
/**
* 一分钟更新一次会话列表
*/
protected
enableAutoRefresh
()
{
this
.
nextTimer
=
setTimeout
(
()
=>
this
.
getMyChatList
().
finally
(()
=>
this
.
enableAutoRefresh
()),
60
*
1000
);
}
beforeDestroy
()
{
clearTimeout
(
this
.
nextTimer
);
}
}
}
components/message-list.vue
View file @
50e9105f
...
@@ -190,15 +190,6 @@
...
@@ -190,15 +190,6 @@
public
created
()
{
public
created
()
{
this
.
handleScrollWrapper
();
this
.
handleScrollWrapper
();
this
.
onNewMessage
((
e
)
=>
{
if
(
e
.
type
===
MessageType
.
Withdraw
)
{
const
ids
=
xim
.
withDrawMsgHandle
(
e
);
this
.
executeWithDraw
(
ids
);
dbController
.
removeMessage
(
e
.
chat_id
,
ids
)
.
finally
(()
=>
this
.
refresh
());
}
});
}
}
public
mounted
()
{
public
mounted
()
{
...
...
components/message.vue
View file @
50e9105f
...
@@ -230,9 +230,6 @@
...
@@ -230,9 +230,6 @@
@
chatStore
.
State
(
ChatStore
.
STATE_CHAT_CURRENT_CHAT_ID
)
@
chatStore
.
State
(
ChatStore
.
STATE_CHAT_CURRENT_CHAT_ID
)
private
readonly
chatId
!
:
ChatStore
.
STATE_CHAT_CURRENT_CHAT_ID
;
private
readonly
chatId
!
:
ChatStore
.
STATE_CHAT_CURRENT_CHAT_ID
;
@
chatStore
.
Mutation
(
ChatStore
.
MUTATION_WITHDRAW
)
private
readonly
executeWithDraw
!
:
ChatStore
.
MUTATION_WITHDRAW
;
@
chatStore
.
Action
(
ChatStore
.
ACTION_SET_HANDLED
)
@
chatStore
.
Action
(
ChatStore
.
ACTION_SET_HANDLED
)
private
readonly
setHandled
!
:
ChatStore
.
ACTION_SET_HANDLED
;
private
readonly
setHandled
!
:
ChatStore
.
ACTION_SET_HANDLED
;
...
@@ -562,14 +559,7 @@
...
@@ -562,14 +559,7 @@
},
},
});
});
}
}
ximInstance
.
withdraw
(
this
.
chatId
,
this
.
data
.
id
).
finally
(()
=>
{
ximInstance
.
withdraw
(
this
.
chatId
,
this
.
data
.
id
);
dbController
.
removeMessage
(
this
.
chatId
,
[
this
.
data
.
id
])
.
finally
(()
=>
{
this
.
executeWithDraw
([
this
.
data
.
id
]);
this
.
$emit
(
"withdraw"
,
this
.
data
.
id
);
});
});
}
}
private
hoverWithdraw
()
{
private
hoverWithdraw
()
{
...
...
store/index.ts
View file @
50e9105f
...
@@ -28,22 +28,24 @@ const UniplatChatModelName = "UniplatChat";
...
@@ -28,22 +28,24 @@ const UniplatChatModelName = "UniplatChat";
const
model
=
()
=>
Chat
.
getSdk
().
model
(
UniplatChatModelName
);
const
model
=
()
=>
Chat
.
getSdk
().
model
(
UniplatChatModelName
);
const
orgId
=
()
=>
Chat
.
getOrgId
()
as
string
;
const
orgId
=
()
=>
Chat
.
getOrgId
()
as
string
;
function
uniqueMessages
(
function
combineMessages
(
messages
:
NonNullable
<
ChatStore
.
STATE_CHAT_MSG_HISTORY
>
items1
:
ChatStore
.
STATE_CHAT_MSG_HISTORY
,
items2
:
ChatStore
.
STATE_CHAT_MSG_HISTORY
,
chat
:
number
)
{
)
{
const
arr
=
[...
messages
]
;
const
set
=
new
Set
<
number
>
()
;
return
unique
(
arr
,
function
(
item
,
all
)
{
const
items
:
Message
[]
=
[];
return
all
.
findIndex
((
k
)
=>
k
.
id
===
item
.
id
);
for
(
const
item
of
[...
items1
,
...
items2
])
{
});
if
(
item
.
chat_id
!==
chat
)
{
}
continue
;
}
function
filterMessages
(
const
id
=
item
.
id
;
messages
:
NonNullable
<
ChatStore
.
STATE_CHAT_MSG_HISTORY
>
,
if
(
!
set
.
has
(
id
))
{
chatid
:
number
set
.
add
(
id
);
)
{
items
.
push
(
item
);
return
uniqueMessages
(
Array
.
from
(
messages
)).
filter
(
}
(
k
)
=>
k
.
chat_id
===
chatid
}
);
return
items
.
sort
((
x
,
y
)
=>
(
x
.
id
-
y
.
id
?
1
:
-
1
)
);
}
}
let
removeRegisterChatEvents
:
(()
=>
void
)[]
=
[];
let
removeRegisterChatEvents
:
(()
=>
void
)[]
=
[];
...
@@ -230,14 +232,14 @@ export default {
...
@@ -230,14 +232,14 @@ export default {
);
);
const
withdraw
=
hasWithdraw
const
withdraw
=
hasWithdraw
?
newItems
?
newItems
.
filter
((
i
)
=>
i
.
type
===
MessageType
.
Withdraw
)
.
filter
((
i
)
=>
i
.
type
===
MessageType
.
Withdraw
)
.
map
((
i
)
=>
+
i
.
msg
)
.
map
((
i
)
=>
+
i
.
msg
)
:
[];
:
[];
const
filterout
=
withdraw
.
length
const
filterout
=
withdraw
.
length
?
newItems
.
filter
((
i
)
=>
!
withdraw
.
includes
(
i
.
id
))
?
newItems
.
filter
((
i
)
=>
!
withdraw
.
includes
(
i
.
id
))
:
newItems
;
:
newItems
;
state
[
ChatStore
.
STATE_CHAT_MSG_HISTORY
]
=
Object
.
freeze
(
state
[
ChatStore
.
STATE_CHAT_MSG_HISTORY
]
=
Object
.
freeze
(
filterMessages
([...
old
,
...
filterout
]
,
chatid
)
combineMessages
(
old
,
filterout
,
chatid
)
);
);
}
}
},
},
...
@@ -274,7 +276,7 @@ export default {
...
@@ -274,7 +276,7 @@ export default {
const
chatId
=
state
[
ChatStore
.
STATE_CHAT_CURRENT_CHAT_ID
];
const
chatId
=
state
[
ChatStore
.
STATE_CHAT_CURRENT_CHAT_ID
];
if
(
!
chatId
)
return
;
if
(
!
chatId
)
return
;
state
[
ChatStore
.
STATE_CHAT_MSG_HISTORY
]
=
Object
.
freeze
(
state
[
ChatStore
.
STATE_CHAT_MSG_HISTORY
]
=
Object
.
freeze
(
filterMessages
([...(
data
||
[]),
...
old
]
,
chatId
)
combineMessages
(
data
||
[],
old
,
chatId
)
);
);
},
},
[
ChatStore
.
MUTATION_SAVE_CURRENT_CHAT_MEMBERS
](
[
ChatStore
.
MUTATION_SAVE_CURRENT_CHAT_MEMBERS
](
...
@@ -374,7 +376,7 @@ export default {
...
@@ -374,7 +376,7 @@ export default {
state
[
ChatStore
.
STATE_CHAT_SENDING_MESSAGES
]
=
[...
current
];
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
}
=
{};
const
setTimeoutId
:
{
[
key
:
string
]:
number
}
=
{};
return
(
return
(
state
:
ChatStoreState
,
state
:
ChatStoreState
,
...
@@ -588,11 +590,17 @@ export default {
...
@@ -588,11 +590,17 @@ export default {
.
updateChat4UnreadCount
(
p
.
chat
,
p
.
unread
)
.
updateChat4UnreadCount
(
p
.
chat
,
p
.
unread
)
.
then
(()
=>
.
then
(()
=>
dispatch
(
ChatStore
.
ACTION_REBUILD_UNREAD_MESSAGE_COUNT
)
dispatch
(
ChatStore
.
ACTION_REBUILD_UNREAD_MESSAGE_COUNT
)
).
finally
(()
=>
{
)
.
finally
(()
=>
{
if
(
!
p
.
unread
)
{
if
(
!
p
.
unread
)
{
const
messages
=
state
[
ChatStore
.
STATE_CHAT_MSG_HISTORY
];
const
messages
=
state
[
ChatStore
.
STATE_CHAT_MSG_HISTORY
];
if
(
messages
&&
messages
.
length
)
{
if
(
messages
&&
messages
.
length
)
{
xim
.
setRead
(
p
.
chat
,
messages
[
0
].
id
,
messages
[
messages
.
length
-
1
].
id
);
xim
.
setRead
(
p
.
chat
,
messages
[
0
].
id
,
messages
[
messages
.
length
-
1
].
id
);
}
}
}
}
});
});
...
@@ -770,7 +778,11 @@ export default {
...
@@ -770,7 +778,11 @@ export default {
const
chatId
=
state
[
ChatStore
.
STATE_CHAT_CURRENT_CHAT_ID
];
const
chatId
=
state
[
ChatStore
.
STATE_CHAT_CURRENT_CHAT_ID
];
const
onNewMsg
=
(
e
:
Message
)
=>
{
const
onNewMsg
=
(
e
:
Message
)
=>
{
const
thenAction
=
()
=>
{
const
thenAction
=
()
=>
{
if
(
e
.
type
===
MessageType
.
Withdraw
)
{
if
(
e
.
type
===
MessageType
.
Withdraw
&&
// 这里再取一次当前chatId避免数据和当前不一致
e
.
chat_id
===
state
[
ChatStore
.
STATE_CHAT_CURRENT_CHAT_ID
]
)
{
commit
(
commit
(
ChatStore
.
MUTATION_WITHDRAW
,
ChatStore
.
MUTATION_WITHDRAW
,
xim
.
withDrawMsgHandle
(
e
)
xim
.
withDrawMsgHandle
(
e
)
...
@@ -981,7 +993,7 @@ export default {
...
@@ -981,7 +993,7 @@ export default {
commit
(
commit
(
ChatStore
.
MUTATION_SAVE_CURRENT_CHAT_MEMBERS
,
ChatStore
.
MUTATION_SAVE_CURRENT_CHAT_MEMBERS
,
unique
(
newChatMembers
,
function
(
item
,
all
)
{
unique
(
newChatMembers
,
function
(
item
,
all
)
{
return
all
.
findIndex
((
k
)
=>
k
.
eid
===
item
.
eid
);
return
all
.
findIndex
((
k
)
=>
k
.
eid
===
item
.
eid
);
})
})
);
);
...
@@ -1238,8 +1250,8 @@ export default {
...
@@ -1238,8 +1250,8 @@ export default {
p
.
read_count
=
option
.
all
p
.
read_count
=
option
.
all
?
p
.
total_read_count
?
p
.
total_read_count
:
option
.
readed
:
option
.
readed
?
option
.
readed
?
option
.
readed
:
p
.
read_count
+
1
;
:
p
.
read_count
+
1
;
}
}
}
}
}
else
{
}
else
{
...
@@ -1248,8 +1260,8 @@ export default {
...
@@ -1248,8 +1260,8 @@ export default {
p
.
read_count
=
option
.
all
p
.
read_count
=
option
.
all
?
p
.
total_read_count
?
p
.
total_read_count
:
option
.
readed
:
option
.
readed
?
option
.
readed
?
option
.
readed
:
p
.
read_count
+
1
;
:
p
.
read_count
+
1
;
}
}
}
}
}
}
...
...
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