increase time between UsersTyping collection updates
This commit is contained in:
parent
50165922c5
commit
85ce9feb18
@ -4,7 +4,7 @@ import Users from '/imports/api/users';
|
||||
import { UsersTyping } from '/imports/api/group-chat-msg';
|
||||
import stopTyping from './stopTyping';
|
||||
|
||||
const TYPING_TIMEOUT = 3000;
|
||||
const TYPING_TIMEOUT = 5000;
|
||||
|
||||
export default function startTyping(meetingId, userId, chatId) {
|
||||
check(meetingId, String);
|
||||
@ -25,10 +25,14 @@ export default function startTyping(meetingId, userId, chatId) {
|
||||
time: (new Date()),
|
||||
};
|
||||
|
||||
const typingUser = UsersTyping.findOne(selector);
|
||||
const typingUser = UsersTyping.findOne(selector, {
|
||||
fields: {
|
||||
time: 1,
|
||||
},
|
||||
});
|
||||
|
||||
if (typingUser) {
|
||||
if (mod.time - typingUser.time <= 2900) return;
|
||||
if (mod.time - typingUser.time <= TYPING_TIMEOUT - 100) return;
|
||||
}
|
||||
|
||||
const cb = (err) => {
|
||||
|
@ -25,9 +25,6 @@ const propTypes = {
|
||||
partnerIsLoggedOut: PropTypes.bool.isRequired,
|
||||
stopUserTyping: PropTypes.func.isRequired,
|
||||
startUserTyping: PropTypes.func.isRequired,
|
||||
currentChatPartner: PropTypes.string.isRequired,
|
||||
currentUserId: PropTypes.string.isRequired,
|
||||
typingUsers: PropTypes.arrayOf(Object).isRequired,
|
||||
};
|
||||
|
||||
const defaultProps = {
|
||||
|
@ -19,20 +19,21 @@ class TypingIndicatorContainer extends PureComponent {
|
||||
export default withTracker(() => {
|
||||
const idChatOpen = Session.get('idChatOpen');
|
||||
|
||||
let typingUsers = null;
|
||||
if (idChatOpen === 'public') {
|
||||
typingUsers = UsersTyping.find({
|
||||
meetingId: Auth.meetingID,
|
||||
isTypingTo: PUBLIC_CHAT_KEY,
|
||||
}).fetch();
|
||||
} else {
|
||||
typingUsers = UsersTyping.find({
|
||||
let selector = {
|
||||
meetingId: Auth.meetingID,
|
||||
isTypingTo: PUBLIC_CHAT_KEY,
|
||||
};
|
||||
|
||||
if (idChatOpen !== PUBLIC_CHAT_KEY) {
|
||||
selector = {
|
||||
meetingId: Auth.meetingID,
|
||||
isTypingTo: Auth.userID,
|
||||
userId: idChatOpen,
|
||||
}).fetch();
|
||||
};
|
||||
}
|
||||
|
||||
const typingUsers = UsersTyping.find(selector).fetch();
|
||||
|
||||
const currentUser = Users.findOne({
|
||||
meetingId: Auth.meetingID,
|
||||
userId: Auth.userID,
|
||||
|
Loading…
Reference in New Issue
Block a user