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
f129063c
authored
Oct 14, 2021
by
Sixong.Zhu
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
update
parent
c1153f8d
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
28 deletions
model/index.ts
store/index.ts
model/index.ts
View file @
f129063c
...
...
@@ -124,7 +124,12 @@ export interface Message {
export
type
MessageRequestResult
=
readonly
Message
[];
export
interface
BaseChatItem
{
export
interface
BaseChatItemBusinessData
{
model_name
:
string
;
obj_id
:
string
;
}
export
interface
BaseChatItem
extends
BaseChatItemBusinessData
{
id
:
number
;
org_id
:
string
;
uid
:
string
;
...
...
@@ -160,8 +165,6 @@ export interface BaseChatItem {
last_msg_ts
:
number
;
members_updated
:
number
;
user_updated
:
number
;
model_name
:
string
;
obj_id
:
string
;
}
export
interface
RawChatItem
extends
BaseChatItem
{
...
...
store/index.ts
View file @
f129063c
import
Vue
from
"vue"
;
import
{
Module
}
from
"vuex"
;
import
{
dbController
}
from
"../database"
;
import
{
ChatMember
,
MessageType
,
ServiceType
,
MessageHandled
,
RawChatItem
}
from
"../model"
;
import
{
ChatMember
,
MessageType
,
ServiceType
,
MessageHandled
,
RawChatItem
,
BaseChatItemBusinessData
,
}
from
"../model"
;
import
{
isAccessibleUrl
}
from
"../service/tools"
;
import
{
unique
}
from
"../utils"
;
import
{
getChatModelInfo
}
from
"../utils/chat-info"
;
...
...
@@ -77,10 +84,7 @@ async function preCacheImgs(msgs?: any[]) {
function
buildChatItem
(
chat
:
RawChatItem
)
{
if
(
!
chat
.
model_name
&&
chat
.
business_data
)
{
const
b
=
JSON
.
parse
(
chat
.
business_data
)
as
{
model_name
:
string
;
obj_id
:
string
;
};
const
b
=
JSON
.
parse
(
chat
.
business_data
)
as
BaseChatItemBusinessData
;
chat
.
model_name
=
b
.
model_name
;
b
.
obj_id
&&
(
chat
.
obj_id
=
b
.
obj_id
);
}
...
...
@@ -550,7 +554,10 @@ export default {
.
createChat
(
true
);
const
chatId
=
Number
(
imChatId
);
await
commit
(
ChatStore
.
MUTATION_SHOW_CHAT
,
true
);
await
dispatch
(
ChatStore
.
ACTION_SAVE_CURRENT_CHAT_ID_VERSION
,
chatId
);
await
dispatch
(
ChatStore
.
ACTION_SAVE_CURRENT_CHAT_ID_VERSION
,
chatId
);
// 打开会话后获取一下会话列表,刷新未读消息
dispatch
(
ChatStore
.
ACTION_GET_MY_CHAT_LIST
);
},
...
...
@@ -623,19 +630,10 @@ export default {
return
;
}
const
chat
=
data
.
args
[
0
]
as
RawChatItem
;
if
(
!
chat
.
model_name
&&
chat
.
business_data
)
{
const
b
=
JSON
.
parse
(
chat
.
business_data
)
as
{
model_name
:
string
;
obj_id
:
string
;
};
chat
.
model_name
=
b
.
model_name
;
chat
.
obj_id
=
b
.
obj_id
;
}
wantedChatRoom
=
{
...
chat
,
chat_id
:
chat
.
id
,
}
as
ChatType
;
commit
(
ChatStore
.
MUTATION_SAVE_SINGLE_CHAT
,
wantedChatRoom
);
commit
(
ChatStore
.
MUTATION_SAVE_SINGLE_CHAT
,
(
wantedChatRoom
=
buildChatItem
(
chat
))
);
}
else
{
commit
(
ChatStore
.
MUTATION_CLEAR_SINGLE_CHAT
);
}
...
...
@@ -663,7 +661,6 @@ export default {
);
})
.
catch
(
console
.
error
);
commit
(
ChatStore
.
MUTATION_INITING_CHAT
);
removeRegisterChatEvents
.
forEach
((
k
)
=>
k
());
removeRegisterChatEvents
=
[];
...
...
@@ -674,7 +671,7 @@ export default {
]);
commit
(
ChatStore
.
MUTATION_SAVE_CHAT_TITLE
,
wantedChatRoom
.
title
||
chatId
wantedChatRoom
.
title
||
`会话
${
chatId
}
`
);
commit
(
ChatStore
.
MUTATION_INITING_CHAT_DONE
);
commit
(
ChatStore
.
MUTATION_SCROLL_TO_BOTTOM
);
...
...
@@ -688,9 +685,9 @@ export default {
},
async
[
ChatStore
.
ACTION_GET_CHAT_MEMBERS
]({
commit
,
state
})
{
const
chatId
=
state
[
ChatStore
.
STATE_CHAT_CURRENT_CHAT_ID
];
if
(
chatId
==
null
)
return
;
if
(
!
chatId
)
return
;
const
getChatMembersResult
=
await
xim
.
fetchChatMembers
(
chatId
);
if
(
getChatMembersResult
==
null
)
return
;
if
(
!
getChatMembersResult
)
return
;
const
chatMembers
=
getChatMembersResult
.
args
[
0
]
as
ChatMember
[];
let
newChatMembers
=
await
Promise
.
all
(
chatMembers
.
map
(
async
(
member
)
=>
{
...
...
@@ -888,8 +885,10 @@ export default {
[
ChatStore
.
STATE_CHAT_MSG_HISTORY
](
state
)
{
// 过滤消息撤回
const
msgList
=
state
[
ChatStore
.
STATE_CHAT_MSG_HISTORY
]
??
[];
const
drawList
=
msgList
.
filter
(
i
=>
i
.
type
===
MessageType
.
Withdraw
).
map
(
i
=>
+
i
.
msg
);
return
msgList
.
filter
(
i
=>
!
drawList
.
includes
(
i
.
id
));
const
drawList
=
msgList
.
filter
((
i
)
=>
i
.
type
===
MessageType
.
Withdraw
)
.
map
((
i
)
=>
+
i
.
msg
);
return
msgList
.
filter
((
i
)
=>
!
drawList
.
includes
(
i
.
id
));
},
[
ChatStore
.
STATE_CHAT_SENDING_MESSAGES
](
state
)
{
return
state
[
ChatStore
.
STATE_CHAT_SENDING_MESSAGES
]
||
[];
...
...
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