Skip to content

Commit

Permalink
presence: strip throttling from reportPresence wrapper
Browse files Browse the repository at this point in the history
The throttling logic currently loses, rather than delaying, an `idle`
which terminates a stream of `active` presence reports. Remove it.

Technically, this alone would fix #3699 as literally reported, since
the `idle` report is now emitted. However, the `active`-emitting
`setInterval` callback is still present and may still fire off events.
(Whether it actually does or not is presumably up to the underlying
OS.)
  • Loading branch information
rk-for-zulip committed Dec 13, 2019
1 parent 37c5bb7 commit e12c452
Showing 1 changed file with 0 additions and 10 deletions.
10 changes: 0 additions & 10 deletions src/users/usersActions.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* @flow strict-local */
import differenceInSeconds from 'date-fns/difference_in_seconds';
import * as typing_status from '@zulip/shared/js/typing_status';

import type { Dispatch, GetState, Narrow } from '../types';
Expand All @@ -9,8 +8,6 @@ import { getAuth, tryGetAuth } from '../selectors';
import { isPrivateOrGroupNarrow, caseNarrowPartial } from '../utils/narrow';
import { getAllUsersByEmail } from './userSelectors';

let lastReportPresence = new Date(0);

export const reportPresence = (isActive: boolean = true, newUserInput: boolean = false) => async (
dispatch: Dispatch,
getState: GetState,
Expand All @@ -20,13 +17,6 @@ export const reportPresence = (isActive: boolean = true, newUserInput: boolean =
return; // not logged in
}

const now = new Date();
if (differenceInSeconds(now, lastReportPresence) < 60) {
// TODO throttle properly; probably fold setInterval logic in here
return;
}
lastReportPresence = now;

const response = await api.reportPresence(auth, isActive, newUserInput);
dispatch({
type: PRESENCE_RESPONSE,
Expand Down

0 comments on commit e12c452

Please sign in to comment.