Page MenuHomePhabricator

[lib] Update `reduceThreadActivity` to handle `processUpdatesActionType` and others
ClosedPublic

Authored by atul on Oct 11 2023, 1:27 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Nov 25, 3:48 AM
Unknown Object (File)
Fri, Nov 15, 6:06 PM
Unknown Object (File)
Oct 28 2024, 8:18 PM
Unknown Object (File)
Oct 25 2024, 1:15 AM
Unknown Object (File)
Oct 18 2024, 9:42 PM
Unknown Object (File)
Oct 18 2024, 9:42 PM
Unknown Object (File)
Oct 18 2024, 9:42 PM
Unknown Object (File)
Oct 2 2024, 6:01 AM
Subscribers

Details

Summary

To address @tomek's point here: https://phab.comm.dev/D9402#276831

Went ahead and added all the actionTypes for that could include ClientUpdateInfo. @tomek wanted to get your thoughts on this approach, or if I should just add processUpdatesActionType.

Added an additional filter check to see if there were any DELETE_THREAD updates before creating a new state object as an optimization since presumably this action handler branch will be hit more times now.

Test Plan

Careful reading + flow, not sure if further testing is worthwile.

Diff Detail

Repository
rCOMM Comm
Branch
master
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

atul published this revision for review.Oct 11 2023, 1:28 PM
tomek requested changes to this revision.Oct 12 2023, 1:21 AM

Agree it is safer to handle all the actions that include the updates. But, at the same time, it is possible to introduce a new action that contains updates and forget to add it here. We probably should figure out a different approach and use it in all the places - e.g. instead of checking action.type, check if it has updateRedult.newUpdates (not sure if Flow will like it). - It isn't blocking this diff, but is a separate follow-up.

One issue with the approach from this diff is that it is a step backward in terms of https://linear.app/comm/issue/ENG-4244/update-redux-state-based-on-updates. What we should do instead is to introduce a new function to update specs and call it here.

This revision now requires changes to proceed.Oct 12 2023, 1:21 AM

Might be good for @tomek to meet with @atul to share more context about the update syncing specs. Or potentially could be a subject for a teamwide "office hours" this Wednesday (although not sure of the impact of blocking this diff until then... maybe could be a follow-up task?)

lib/reducers/thread-activity-reducer.js
84

I don't think it's okay to have invariants without a second param. I forget the context, but I think it's something like... Flow allows it but it breaks when it's triggered or something? I vaguely remember somebody having to do some follow-up diff to address it, but I might be misremembering

lib/reducers/thread-activity-reducer.js
84

Yeah, you're definitely right this has broken things before, will update

Might be good for @tomek to meet with @atul to share more context about the update syncing specs. Or potentially could be a subject for a teamwide "office hours" this Wednesday (although not sure of the impact of blocking this diff until then... maybe could be a follow-up task?)

Makes sense - we can make this a follow-up. The idea of update specs is quite simple - if some code in reducers depends on the update type, instead of having ifs, we should create a function in a spec for the corresponding type and select this function from update-specs object by a type.

This revision is now accepted and ready to land.Oct 16 2023, 7:07 AM

@atul can you make a Linear task to track refactoring this to use the new update specs approach, and link the task here before landing?

@atul can you make a Linear task to track refactoring this to use the new update specs approach, and link the task here before landing?

https://linear.app/comm/issue/ENG-5319/use-new-update-spec-approach-for-thread-activity-reducer

second invariant arg