| 147 | |
| 148 | // Updates the typing event |
| 149 | const updateTyping = () => { |
| 150 | if (connected) { |
| 151 | if (!typing) { |
| 152 | typing = true; |
| 153 | socket.emit('typing'); |
| 154 | } |
| 155 | lastTypingTime = (new Date()).getTime(); |
| 156 | |
| 157 | setTimeout(() => { |
| 158 | const typingTimer = (new Date()).getTime(); |
| 159 | const timeDiff = typingTimer - lastTypingTime; |
| 160 | if (timeDiff >= TYPING_TIMER_LENGTH && typing) { |
| 161 | socket.emit('stop typing'); |
| 162 | typing = false; |
| 163 | } |
| 164 | }, TYPING_TIMER_LENGTH); |
| 165 | } |
| 166 | } |
| 167 | |
| 168 | // Gets the 'X is typing' messages of a user |
| 169 | const getTypingMessages = (data) => { |