Page MenuHomePhabricator

[web] [refactor] move use unread into its own hook
ClosedPublic

Authored by benschac on Mar 14 2022, 7:57 AM.
Tags
None
Referenced Files
F3378441: D3418.diff
Wed, Nov 27, 10:35 AM
Unknown Object (File)
Sun, Nov 10, 12:10 AM
Unknown Object (File)
Sun, Nov 10, 12:10 AM
Unknown Object (File)
Sun, Nov 10, 12:10 AM
Unknown Object (File)
Sun, Nov 10, 12:10 AM
Unknown Object (File)
Fri, Nov 8, 7:42 AM
Unknown Object (File)
Fri, Nov 8, 2:55 AM
Unknown Object (File)
Tue, Nov 5, 1:03 AM

Details

Summary

Move unread toggle into it's own hook. This functionality is used in native as well.
https://linear.app/comm/issue/ENG-861/refactor-unreadstatus-into-hook-for-both-native-and-web

Screen Recording 2022-03-14 at 10.59.16 AM.gif (717×891 px, 1 MB)

Test Plan

Toggle unread in web, make sure the functionality still works.

Diff Detail

Repository
rCOMM Comm
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

tomek added inline comments.
lib/hooks/toggle-unread-status.js
19 ↗(On Diff #10329)

We usually use onSomething name when something is an action, e.g. onClose or onFinish. onAfter doesn't sound right to me, but it might be just me. It is hard to find a good name that starts with on and expresses that it happens after toggle (onToggle might happen before, after, in the middle, etc. but we want to explicitly state that it is after). So maybe just afterAction? We don't need to start the name of every callback with on. And if we like to make this more reusable, afterAction should be an optional parameter,

45–49 ↗(On Diff #10329)

I know this code is only moved, but it might be good idea to be a little more explicit with the dependencies here (in a new diff), e.g. the callback doesn't depend on the whole threadInfo but instead on threadInfo.id and threadInfo.currentUser.unread.

This revision is now accepted and ready to land.Mar 14 2022, 9:27 AM
lib/hooks/toggle-unread-status.js
19 ↗(On Diff #10329)

afterAction makes sense. I'm not too married to onAfter just thought it made sense.

45–49 ↗(On Diff #10329)

ty for the catch! I'm just moving in this diff. I will update the deps in a follow up diff.

update onAfter --> actionAfter