remove logging
This commit is contained in:
parent
d787d3d821
commit
1db6f1b652
1 changed files with 4 additions and 21 deletions
|
@ -75,23 +75,14 @@ module.exports = React.createClass({
|
||||||
onRoomTimeline: function(event, room) {
|
onRoomTimeline: function(event, room) {
|
||||||
if (room.roomId === this.props.room.roomId) {
|
if (room.roomId === this.props.room.roomId) {
|
||||||
const userId = event.getSender();
|
const userId = event.getSender();
|
||||||
const userWasTyping = this.state.usersTyping.some((m) => m.userId === userId);
|
// remove user from usersTyping
|
||||||
if (userWasTyping) {
|
|
||||||
console.log(`WhoIsTypingTile: remove ${userId} from usersTyping`);
|
|
||||||
}
|
|
||||||
const usersTyping = this.state.usersTyping.filter((m) => m.userId !== userId);
|
const usersTyping = this.state.usersTyping.filter((m) => m.userId !== userId);
|
||||||
this.setState({usersTyping});
|
this.setState({usersTyping});
|
||||||
|
this._abortUserTimer(userId);
|
||||||
if (this.state.userTimers[userId]) {
|
|
||||||
console.log(`WhoIsTypingTile: incoming timeline event for ${userId}`);
|
|
||||||
}
|
|
||||||
this._abortUserTimer(userId, "timeline event");
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onRoomMemberTyping: function(ev, member) {
|
onRoomMemberTyping: function(ev, member) {
|
||||||
//TODO: don't we need to check the roomId here?
|
|
||||||
console.log(`WhoIsTypingTile: incoming typing event for`, ev.getContent().user_ids);
|
|
||||||
const usersTyping = WhoIsTyping.usersTypingApartFromMeAndIgnored(this.props.room);
|
const usersTyping = WhoIsTyping.usersTypingApartFromMeAndIgnored(this.props.room);
|
||||||
this.setState({
|
this.setState({
|
||||||
userTimers: this._updateUserTimers(usersTyping),
|
userTimers: this._updateUserTimers(usersTyping),
|
||||||
|
@ -115,24 +106,17 @@ module.exports = React.createClass({
|
||||||
let userTimers = Object.assign({}, this.state.userTimers);
|
let userTimers = Object.assign({}, this.state.userTimers);
|
||||||
// remove members that started typing again
|
// remove members that started typing again
|
||||||
userTimers = usersThatStartedTyping.reduce((userTimers, m) => {
|
userTimers = usersThatStartedTyping.reduce((userTimers, m) => {
|
||||||
if (userTimers[m.userId]) {
|
|
||||||
console.log(`WhoIsTypingTile: stopping timer for ${m.userId} because started typing again`);
|
|
||||||
}
|
|
||||||
delete userTimers[m.userId];
|
delete userTimers[m.userId];
|
||||||
return userTimers;
|
return userTimers;
|
||||||
}, userTimers);
|
}, userTimers);
|
||||||
// start timer for members that stopped typing
|
// start timer for members that stopped typing
|
||||||
userTimers = usersThatStoppedTyping.reduce((userTimers, m) => {
|
userTimers = usersThatStoppedTyping.reduce((userTimers, m) => {
|
||||||
if (!userTimers[m.userId]) {
|
if (!userTimers[m.userId]) {
|
||||||
console.log(`WhoIsTypingTile: starting 5s timer for ${m.userId}`);
|
|
||||||
const timer = new Timer(5000);
|
const timer = new Timer(5000);
|
||||||
userTimers[m.userId] = timer;
|
userTimers[m.userId] = timer;
|
||||||
timer.start();
|
timer.start();
|
||||||
timer.finished().then(
|
timer.finished().then(
|
||||||
() => {
|
() => this._removeUserTimer(m.userId), //on elapsed
|
||||||
console.log(`WhoIsTypingTile: elapsed 5s timer for ${m.userId}`);
|
|
||||||
this._removeUserTimer(m.userId);
|
|
||||||
}, //on elapsed
|
|
||||||
() => {/* aborted */},
|
() => {/* aborted */},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -142,10 +126,9 @@ module.exports = React.createClass({
|
||||||
return userTimers;
|
return userTimers;
|
||||||
},
|
},
|
||||||
|
|
||||||
_abortUserTimer: function(userId, reason) {
|
_abortUserTimer: function(userId) {
|
||||||
const timer = this.state.userTimers[userId];
|
const timer = this.state.userTimers[userId];
|
||||||
if (timer) {
|
if (timer) {
|
||||||
console.log(`WhoIsTypingTile: aborting timer for ${userId} because ${reason}`);
|
|
||||||
timer.abort();
|
timer.abort();
|
||||||
this._removeUserTimer(userId);
|
this._removeUserTimer(userId);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue