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
b3433377
authored
Dec 03, 2021
by
Sixong.Zhu
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
update
parent
540f3673
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
7 deletions
store/index.ts
store/index.ts
View file @
b3433377
...
@@ -7,6 +7,7 @@ import {
...
@@ -7,6 +7,7 @@ import {
MessageHandled
,
MessageHandled
,
RawChatItem
,
RawChatItem
,
BaseChatItemBusinessData
,
BaseChatItemBusinessData
,
MessageType
,
}
from
"../model"
;
}
from
"../model"
;
import
{
isAccessibleUrl
}
from
"../service/tools"
;
import
{
isAccessibleUrl
}
from
"../service/tools"
;
import
{
unique
}
from
"../utils"
;
import
{
unique
}
from
"../utils"
;
...
@@ -199,10 +200,15 @@ export default {
...
@@ -199,10 +200,15 @@ export default {
)
{
)
{
const
old
=
state
[
ChatStore
.
STATE_CHAT_MSG_HISTORY
]
||
[];
const
old
=
state
[
ChatStore
.
STATE_CHAT_MSG_HISTORY
]
||
[];
const
chatid
=
state
[
ChatStore
.
STATE_CHAT_CURRENT_CHAT_ID
];
const
chatid
=
state
[
ChatStore
.
STATE_CHAT_CURRENT_CHAT_ID
];
if
(
chatid
==
null
)
return
;
if
(
chatid
)
{
state
[
ChatStore
.
STATE_CHAT_MSG_HISTORY
]
=
Object
.
freeze
(
// 移除撤回的消息
filterMessages
([...
old
,
...(
data
||
[])],
chatid
)
const
newItems
=
data
||
[];
);
const
withdraw
=
newItems
.
filter
(
i
=>
i
.
type
===
MessageType
.
Withdraw
).
map
(
i
=>
+
i
.
msg
);
const
filterout
=
newItems
.
filter
(
i
=>
!
withdraw
.
includes
(
i
.
id
));
state
[
ChatStore
.
STATE_CHAT_MSG_HISTORY
]
=
Object
.
freeze
(
filterMessages
([...
old
,
...
filterout
],
chatid
)
);
}
},
},
[
ChatStore
.
MUTATION_SAVE_MYSELF_ID
](
state
)
{
[
ChatStore
.
MUTATION_SAVE_MYSELF_ID
](
state
)
{
if
(
!
state
[
ChatStore
.
STATE_CHAT_MY_ID
])
{
if
(
!
state
[
ChatStore
.
STATE_CHAT_MY_ID
])
{
...
@@ -667,10 +673,22 @@ export default {
...
@@ -667,10 +673,22 @@ 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
)
=>
{
if
(
e
.
chat_id
===
chatId
)
{
const
thenAction
=
()
=>
{
dispatch
(
ChatStore
.
ACTION_GET_FRESH_MESSAGE
);
if
(
e
.
type
===
MessageType
.
Withdraw
)
{
commit
(
ChatStore
.
MUTATION_WITHDRAW
,
+
e
.
msg
);
}
const
scroll
=
()
=>
state
[
ChatStore
.
STATE_FUNC_ON_NEW_MSG
](
e
);
if
(
e
.
chat_id
===
chatId
)
{
dispatch
(
ChatStore
.
ACTION_GET_FRESH_MESSAGE
).
finally
(()
=>
scroll
());
}
else
{
scroll
();
}
};
if
(
e
.
type
===
MessageType
.
Withdraw
)
{
dbController
.
removeMessage
(
e
.
chat_id
,
+
e
.
msg
).
finally
(()
=>
thenAction
());
}
else
{
thenAction
();
}
}
state
[
ChatStore
.
STATE_FUNC_ON_NEW_MSG
](
e
);
};
};
if
(
!
chatId
)
{
if
(
!
chatId
)
{
xim
.
off
(
"msg"
,
onNewMsg
);
xim
.
off
(
"msg"
,
onNewMsg
);
...
...
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