Page MenuHomePhabricator

[web] Lift `mainContent: React.Node` from `ThreadSettingsModal` to `ConnectedThreadSettingsModal`
ClosedPublic

Authored by atul on Apr 24 2022, 11:38 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Nov 23, 9:28 AM
Unknown Object (File)
Sat, Nov 23, 8:57 AM
Unknown Object (File)
Sat, Nov 9, 10:48 PM
Unknown Object (File)
Sat, Nov 9, 2:43 PM
Unknown Object (File)
Sat, Nov 9, 2:41 PM
Unknown Object (File)
Sat, Nov 9, 12:55 AM
Unknown Object (File)
Fri, Nov 8, 10:43 PM
Unknown Object (File)
Fri, Nov 8, 10:43 PM

Details

Summary

Lift mainContent from the ThreadSettingsModal class component to the ConnectedThreadSettingsModal functional component.

Doing this this to "stage" the lifting of JSX markup into separate steps to hopefully make it easier to review.

As part of the work to refactor ThreadSettingsModal... specifically to turn it into a functional component.


Depends on D3821

Test Plan
  1. Open ThreadSettingsModal
  2. Make sure the "main content" of the ThreadSettingsModal continues to look and behave as expected (since that was what was moved)
  3. Change some settings around, hit save, make sure things are saved as expected

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

web/modals/threads/thread-settings-modal.react.js
446 ↗(On Diff #11825)

Using nullish coalescing instead of possiblyChangedValue to avoid various flow issues with possiblyChangedValue (there are various value types in queuedChanges and threadInfo which makes things hard to type)

Also generally think it's a cleaner solution that avoids unnecessary (imo) redirection to a helper function that was probably (?) written before widespread support for nullish coalescing?

atul requested review of this revision.Apr 24 2022, 11:42 AM
tomek added a reviewer: ashoat.

Accepting, but it will be a good idea to get @ashoat's opinion

web/modals/threads/thread-settings-modal.react.js
446 ↗(On Diff #11825)

This helper function was quite useful as it:

  1. Made sure that we use the same key for both values
  2. Explained why do we check two values

So for me the solution with the function was slightly better, but not sure if it's worth to reintroduce it.

452 ↗(On Diff #11825)

We were using just this.possiblyChangedValue('description') here. Was that a mistake?

web/modals/threads/thread-settings-modal.react.js
446 ↗(On Diff #11825)

So for me the solution with the function was slightly better, but not sure if it's worth to reintroduce it.

That makes sense. Given the size of the stack it'll definitely be easier to re-introduce possiblyChangedValue at the end of the stack. I'll leave a comment here linking to that diff once it's put up.

452 ↗(On Diff #11825)

I made the threadDescriptionValue prop a non-optional string so we need to add an empty string at the end in case queuedChanges.description and threadInfo.description are null/undefined.

I can instead make threadDescriptionValue an optional string if that's cleaner

Agree with @palys-swm, and @atul's plan to address in a later diff makes sense

This revision is now accepted and ready to land.Apr 27 2022, 8:25 PM