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