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
be0ef3af
authored
Aug 02, 2021
by
吴云建
Browse files
Options
_('Browse Files')
Download
Plain Diff
Merge branch 'master' of
http://gitlab.corp.qinqinxiaobao.com:9880/uniplat/customer-service
parents
bd4fedae
95cd3bba
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
10 deletions
store/index.ts
store/model.ts
store/index.ts
View file @
be0ef3af
...
...
@@ -25,7 +25,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
);
});
}
...
...
@@ -256,7 +256,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
,
...
...
@@ -296,9 +296,10 @@ export default {
},
actions
:
{
async
[
ChatStore
.
ACTION_GET_MY_CHAT_LIST
]({
state
,
commit
,
})
/* ...params: Parameters<ChatStore.ACTION_GET_MY_CHAT_LIST> */
{
if
(
!
this
.
state
[
ChatStore
.
STATE_CHAT_CURRENT_USER_UID
])
{
if
(
!
state
[
ChatStore
.
STATE_CHAT_CURRENT_USER_UID
])
{
const
userInfo
=
await
sdk
().
getUserInfo
();
commit
(
ChatStore
.
MUTATION_SET_CURRENT_USER_UID
,
userInfo
.
id
);
}
...
...
@@ -334,7 +335,7 @@ export default {
const
chatId
=
state
[
ChatStore
.
STATE_CHAT_CURRENT_CHAT_ID
];
if
(
chatId
==
null
)
return
;
try
{
const
data
=
await
xim
.
queryLastPageMsg
(
chatType
,
chatId
,
20
,
!
this
.
state
[
ChatStore
.
STATE_CHAT_CURRENT_IS_CHAT_MEMBER
]);
const
data
=
await
xim
.
queryLastPageMsg
(
chatType
,
chatId
,
20
,
!
state
[
ChatStore
.
STATE_CHAT_CURRENT_IS_CHAT_MEMBER
]);
commit
(
ChatStore
.
MUTATION_PUSH_CHAT_MSG_HISTORY
,
data
);
await
preCacheImgs
(
data
);
commit
(
ChatStore
.
MUTATION_SCROLL_TO_BOTTOM
);
...
...
@@ -355,7 +356,7 @@ export default {
chatId
,
msgId
,
10
,
!
this
.
state
[
ChatStore
.
STATE_CHAT_CURRENT_IS_CHAT_MEMBER
]
!
state
[
ChatStore
.
STATE_CHAT_CURRENT_IS_CHAT_MEMBER
]
);
commit
(
ChatStore
.
MUTATION_UNSHIFT_CHAT_MSG_HISTORY
,
data
);
return
data
;
...
...
@@ -371,7 +372,7 @@ export default {
chatId
,
msgId
,
10
,
!
this
.
state
[
ChatStore
.
STATE_CHAT_CURRENT_IS_CHAT_MEMBER
]
!
state
[
ChatStore
.
STATE_CHAT_CURRENT_IS_CHAT_MEMBER
]
);
commit
(
ChatStore
.
MUTATION_PUSH_CHAT_MSG_HISTORY
,
data
);
return
data
;
...
...
@@ -492,8 +493,11 @@ export default {
},
async
[
ChatStore
.
ACTION_SAVE_CURRENT_CHAT_ID_VERSION
](
{
state
,
commit
,
dispatch
},
chatId
:
Parameters
<
ChatStore
.
ACTION_SAVE_CURRENT_CHAT_ID_VERSION
>
[
0
]
chatId
:
ChatStore
.
STATE_CHAT_CURRENT_CHAT_ID
)
{
if
(
!
chatId
)
{
return
;
}
const
chatList
=
state
[
ChatStore
.
STATE_MY_CHAT_ROOM_LIST
]?.
list
??
[];
let
wantedChatRoom
=
chatList
.
find
(
(
k
)
=>
k
.
chat_id
===
chatId
...
...
@@ -501,6 +505,9 @@ export default {
if
(
wantedChatRoom
==
null
||
wantedChatRoom
.
business_data
==
null
)
{
const
data
=
await
xim
.
fetchChat
(
chatId
);
if
(
!
data
)
{
return
;
}
let
chat
=
data
.
args
[
0
];
let
business_data
;
if
(
chat
.
business_data
)
{
...
...
@@ -573,14 +580,14 @@ export default {
})
);
newChatMembers
=
newChatMembers
.
filter
(
it
=>
!
it
.
is_exited
)
if
(
newChatMembers
.
findIndex
(
it
=>
it
.
eid
==
state
[
ChatStore
.
STATE_CHAT_CURRENT_USER_UID
]
)
>
-
1
)
{
if
(
newChatMembers
.
findIndex
(
it
=>
it
.
eid
==
=
String
(
state
[
ChatStore
.
STATE_CHAT_CURRENT_USER_UID
])
)
>
-
1
)
{
commit
(
ChatStore
.
MUTATION_CHAT_UPDATE_IS_MEMBER
,
true
);
}
else
{
commit
(
ChatStore
.
MUTATION_CHAT_UPDATE_IS_MEMBER
,
false
);
}
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
);
})
);
...
...
store/model.ts
View file @
be0ef3af
...
...
@@ -272,7 +272,6 @@ export namespace ChatStore {
}
export
interface
ChatStoreState
{
[
ChatStore
.
STATE_CHAT_MSG_HISTORY
]:
ChatStore
.
STATE_CHAT_MSG_HISTORY
;
[
ChatStore
.
STATE_CHAT_SENDING_MESSAGES
]:
ChatStore
.
STATE_CHAT_SENDING_MESSAGES
;
[
ChatStore
.
STATE_CHAT_CURRENT_CHAT_ID
]:
ChatStore
.
STATE_CHAT_CURRENT_CHAT_ID
;
...
...
@@ -288,6 +287,10 @@ export interface ChatStoreState {
[
ChatStore
.
STATE_CURRENT_CHAT_INITING
]:
ChatStore
.
STATE_CURRENT_CHAT_INITING
;
[
ChatStore
.
STATE_MY_CHAT_ROOM_LIST
]:
ChatStore
.
STATE_MY_CHAT_ROOM_LIST
;
[
ChatStore
.
STATE_CHAT_DIALOG_VISIBLE
]:
ChatStore
.
STATE_CHAT_DIALOG_VISIBLE
;
[
ChatStore
.
STATE_CHAT_DIALOG_IS_SINGLE
]:
ChatStore
.
STATE_CHAT_DIALOG_IS_SINGLE
[
ChatStore
.
STATE_SINGLE_CHAT
]:
ChatStore
.
STATE_SINGLE_CHAT
[
ChatStore
.
STATE_CHAT_CURRENT_IS_CHAT_MEMBER
]:
ChatStore
.
STATE_CHAT_CURRENT_IS_CHAT_MEMBER
[
ChatStore
.
STATE_CHAT_CURRENT_USER_UID
]:
ChatStore
.
STATE_CHAT_CURRENT_USER_UID
}
export
const
chatStore
=
namespace
(
ChatStore
.
ns
);
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