Skip to content

Clean up "actionCreator" and part of typing-status expiry#4227

Merged
chrisbobbe merged 4 commits intozulip:masterfrom
gnprice:pr-expire-typing
Sep 24, 2020
Merged

Clean up "actionCreator" and part of typing-status expiry#4227
chrisbobbe merged 4 commits intozulip:masterfrom
gnprice:pr-expire-typing

Conversation

@gnprice
Copy link
Copy Markdown
Member

@gnprice gnprice commented Aug 13, 2020

This follows up on #4216 to clean out the very odd actionCreator function and a bit of the logic around expiring typing status.

This doesn't include fixes for all the things that are off about how we expire typing status -- notably the loop at a fixed 15s period, which means that a status might wait as long as 30s before we get around to expiring it. But it should at least isolate all the oddness to specifically the typing-status code, and get it out of the way of the general event-handling code.

@gnprice gnprice requested a review from chrisbobbe August 13, 2020 22:47

/** Start the typing-status expiry loop, if there isn't one already. */
export const ensureTypingStatusExpiryLoop = () => async (dispatch: Dispatch, getState: GetState) => {
export const ensureTypingStatusExpiryLoop = () => async (
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To me, this line-break change suggests that you're also affected by the auto-formatting issue I mentioned here, hmm. IIUC this should have been done in the "ensureTypingStatusExpiryLoop" rename commit.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah indeed, thanks. Pushed a fix.

@chrisbobbe
Copy link
Copy Markdown
Contributor

chrisbobbe commented Aug 14, 2020

Thanks! This looks good to me; looks like you fixed that one formatting nit. Did you find any others, though? Currently I've been running tools/test prettier --fix at each of my commits.

The existing name was very confusing because it sounded like something
that would clear the typing indicators/notifications *now*, not like
something that would start a loop to repeatedly check back in the
future to expire them as appropriate.  Confusing not only in potential
but in actual confusion; see:
  zulip#4216 (comment)
  https://chat.zulip.org/#narrow/stream/243-mobile-team/topic/Typing-state.20client.20timer/near/986619

This also makes a good time to fold it into a module with a more
general name, so that the filename isn't tied to the function's name.
The condition about whether there are any existing typing-status
indicators is kind of mysterious when read literally, and even seems
backward: we only start trying to clear them if there are *none*?

The point of it is that that's also the break condition for the
loop that otherwise sits around continuously, looking for expirable
typing statuses and expiring them.  That's an implementation detail
of that loop, and kind of a subtle one.  Move it to sit next to the
loop's own implementation.
The one side effect we currently do here is indifferent to whether
it happens before or after we dispatch the event actions.  But we
have another side effect found in the oddly-named `actionCreator`
function, which we'd like to fold into this mechanism, and for that
one it's essential that it happens before the events are dispatched.
So, reorder to accommodate that.

If in the future we have some other side effect that needs to happen
after dispatch, and still have this one or another that needs to
happen before, then we can have both kinds separately.
This isn't much of an "action creator" at all.  In reality it has a
very different job -- one we have another mechanism for with a much
better name, doEventActionSideEffects.  So we can make things clearer
by folding its logic into that one.
@chrisbobbe
Copy link
Copy Markdown
Contributor

Merged, thanks, @gnprice! (I ran tools/test at each commit first.)

There's a planned followup to this, currently at your dev-expire-typing branch; discussion here. Would you like me to take that up? Or, later in that discussion, you said this:

... As I think more about that, the conclusion I'm coming to is that the good systematic solution is really for us to get on with maintaining the user's data from all their logged-in accounts at once, rather than focusing on one "active" account as we do.

Does that mean we should hold off on the followup until we do that reorganization?

@chrisbobbe chrisbobbe merged commit 37c094b into zulip:master Sep 24, 2020
@gnprice gnprice deleted the pr-expire-typing branch September 25, 2020 07:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants