squash 30 diff refactor into one diff. Refactor setModal to context
Details
n/a this doesn't do anything yet.
Diff Detail
- Repository
- rCOMM Comm
- Branch
- copy-modalthatsworking
- Lint
No Lint Coverage - Unit
No Test Coverage
Event Timeline
Lots of issues here. Two high-level buckets:
- In many places, you didn't pay attention to code conventions. Please always look for existing conventions in what you're doing.
- For a huge diff like this to work, it has to have a very specific scope. You stuffed way too many unrelated changes into this diff. Those all need to be factored out.
web/chat/chat-thread-list-see-more-sidebars.react.js | ||
---|---|---|
23 ↗ | (On Diff #9911) | You should always be as specific as possible in a dep list. Rather than specifying modalContext here, you should specify modalContext.setModal. That way onClick will only be redefined if modalContext.setModal changes, rather than being redefined whenever modalContext changes |
web/media/multimedia-modal.react.js | ||
70 ↗ | (On Diff #9911) | Instead of extracting uri specifically, please do what every out ConnectedComponent does and spread every prop. That way we won't have to update this code when a new prop is introduced |
web/media/multimedia.react.js | ||
20–27 ↗ | (On Diff #9911) | Can we make all of these $ReadOnly? |
120–126 ↗ | (On Diff #9911) | See comment above. In general, when doing something new you should look to see how it's done in the codebase. If you had looked at any ConnectedComponent, you would see we're spreading all props instead of individually pulling each of them out... In an ideal world this isn't a comment I need to leave, it's just something you learn by reading code. |
web/modals/account/log-in-first-modal.react.js | ||
13 ↗ | (On Diff #9911) | You're converting a class component into a function component. In general, each diff should have a concrete, specific purpose. This is extra important for these huge diffs. Huge diffs should be dead simple. As soon as you sneak changes like this in, you ruin the simplicity and make it hard to review. Please pull this refactor out of this diff. If you feel like that the class-to-function refactor is necessary to make the setModal refactor easier, that's fine – you can just pull the class-to-function refactor into its own preceding diff. |
16–21 ↗ | (On Diff #9911) | By attempting this refactor here, you are asking for trouble. Class-to-function refactor should be trivial, but you're still new to a lot of this stuff. So your class-to-function refactor diff is going to end up needing revisions, which because you've bundled it all together into this unrelated diff, are going to end up blocking this diff. Concretely, here you are introducing a callback that gets recreated on every render. We've talked repeatedly over the past several days about React.useCallback, why it exists, its purpose, etc. Here it seems clear you still don't understand its purpose. onClickLogIn needs to be wrapped in a React.useCallback. |
web/modals/chat/invalid-upload.react.js | ||
9 ↗ | (On Diff #9911) | Yeah that makes sense, but it should not be in the same diff. A huge diff like this can only exist if it is immaculately well-scoped. Please factor this change out into a separate (probably preceding) diff |
web/modals/chat/sidebar-list-modal.react.js | ||
21–28 ↗ | (On Diff #9911) | Please avoid defining threadInfo twice. The core problem here is that you aren't spending time figuring out the right convention for doing something. When you're righting code like this, you should know that we're already doing something similar in the codebase. You must've encountered this already when reading code, but even if you haven't – you should know that this isn't the first time somebody is writing BaseProps/Props. So you should start by finding an existing implementation, and trying to follow what the existing convention is. This comment is the same high-level comment as the one about using object-spread in the ConnectedComponent. Your job isn't just to find something that works – it's to maintain the consistency of the codebase; to learn and implement best practices/conventions. |
150 ↗ | (On Diff #9911) | Once again, please don't do this... use object spread so the next person to add a prop to this component doesn't have to also edit this line |
web/modals/modal.react.js | ||
13 ↗ | (On Diff #9911) |
|
89 ↗ | (On Diff #9911) | Please don't do this – use object spread |
web/root.js | ||
25 ↗ | (On Diff #9911) | We agreed that this shouldn't go here! Why is it back here now? |
web/sidebar/community-picker.react.js | ||
16 ↗ | (On Diff #9911) | Be maximally specific in your dep list |
web/app.react.js | ||
---|---|---|
233 ↗ | (On Diff #9926) | I decided to just wrap the app in a provider, and not use the React.memo higher-order component here since it's wrapped in ConnectedApp Generally wanted to keep the diff as small as possible. |
web/chat/chat-thread-list-see-more-sidebars.react.js | ||
23 ↗ | (On Diff #9911) | updated |
web/media/multimedia-modal.react.js | ||
70 ↗ | (On Diff #9911) | updated. Moving forward I'll pay more attention to the convention of spreading props in ConnectedComponent |
web/media/multimedia.react.js | ||
20–27 ↗ | (On Diff #9911) | I'm assuming you mean, adding + to each key, and you're not saying to type Props = $ReadOnly<{}>; Grepping around the (web) codebase i don't see any examples of what you're suggesting: |
120–126 ↗ | (On Diff #9911) | updated |
web/modals/chat/sidebar-list-modal.react.js | ||
21–28 ↗ | (On Diff #9911) | It was an oversight. I've seen BaseProps spread into Props in the codebase. You're right I should spend a bit more time reviewing my code and looking for similar patterns in the codebase. Just for the record. grepped through the codebase and confirmed. |
web/root.js | ||
25 ↗ | (On Diff #9911) | It was an oversight. I fixed it in my previous stack but forgot to remove it when squashing my diffs. |
I need to do a bit more self-review before asking for review.
web/calendar/day.react.js | ||
---|---|---|
48 ↗ | (On Diff #9926) | I changed all instances on clearModal on the Modal component that you commented on. re-reading my diff, I think this makes sense. |
self review
web/calendar/day.react.js | ||
---|---|---|
48 ↗ | (On Diff #9926) | this should go, clear modal isnt' used in the component |
web/media/multimedia-modal.react.js | ||
69 ↗ | (On Diff #9926) | I should change clearModal back to onClose here too. This Modal doesn't use the <Modal /> component which was the only component I reverted. If we're going to revert the <Modal /> component we should revert this one too. |
web/modals/account/log-in-modal.react.js | ||
64 ↗ | (On Diff #9926) | clearModal was used here last time, so I didn't change the props from clearModal to onClose |
web/modals/chat/invalid-upload.react.js | ||
23 ↗ | (On Diff #9926) | I should still get rid of this clearModal and use the context. |
web/modals/threads/thread-settings-modal.react.js | ||
489 ↗ | (On Diff #9926) | I shouldn't change these either. |
594 ↗ | (On Diff #9926) | any component with Modal in it's name should probably stick with onClose in it's prop like it did before. Going to revert this. |
web/sidebar/community-picker.react.js | ||
14 ↗ | (On Diff #9926) | if setModal is a constant, do we even need to wrap this in a useCallback hook? |
web/sidebar/community-picker.react.js | ||
---|---|---|
14 ↗ | (On Diff #9926) | nvm, if we didn't have this useCallback we'd be creating a new anonymous function on each render. |
web/modals/chat/invalid-upload.react.js | ||
---|---|---|
27 ↗ | (On Diff #9927) | This component was using a clearModal already and I thought less is more, rather than changing it to an onClose. Also, the clearModal isn't a part of an API that a developer would use when using this component. |
Didn't have time for a full review
web/modals/account/log-in-first-modal.react.js | ||
---|---|---|
38–40 ↗ | (On Diff #9927) | Everywhere else in this diff, you delete functions named clearModal and replace them with modalContext.clearModal. This appears to be the only place you left the clearModal function in place. What's the reason for this inconsistency? |
web/modals/chat/invalid-upload.react.js | ||
27 ↗ | (On Diff #9927) | Not sure what you mean |
web/modals/modal.react.js | ||
88 ↗ | (On Diff #9927) |
|
web/modals/account/log-in-first-modal.react.js | ||
---|---|---|
38–40 ↗ | (On Diff #9927) | I missed it. This was one of the two "revert back to class components" and I was thinking just do less here. But, if I'm removing them everywhere in the code base I should do it here too. |
web/modals/chat/invalid-upload.react.js | ||
27 ↗ | (On Diff #9927) | The convention so far has been any <ThingModal /> will take a onClose prop. But since this component isn't taking a users onClose I thought just leaving the prop as clearModal was the right move. |
web/modals/modal.react.js | ||
88 ↗ | (On Diff #9927) |
|
web/modals/chat/invalid-upload.react.js | ||
---|---|---|
27 ↗ | (On Diff #9927) | Correction: But since this component isn't taking a users onClose I thought just leaving the prop as clearModal was the right move. Ment to say: This component doesn't have a public interface to pass an onClose function so I thought leaving this prop as clearModal was okay. |
Ton of issues here... I didn't have time to get through it before my meetings started this morning.
@benschac, it shouldn't take a full review from me for these issues to be spotted, much less three reviews from me. You should be able to spot these issues independently. Until you're able to do that, every time we consider giving you some refactor work we'll have to weigh that it will substantially slow down your ability to make progress on product work, and that's a really hard tradeoff for me to make :(
web/media/multimedia-modal.react.js | ||
---|---|---|
69 ↗ | (On Diff #9947) | Let's rename this to clearModal, to match every single other usage. We want Modal's prop to be called onClose, but for every case where we are simply pulling out clearModal from ModalContext, let's be consistent about naming |
web/media/multimedia.react.js | ||
27 ↗ | (On Diff #9947) | Why is this prop optional? |
web/modals/account/user-settings-modal.react.js | ||
435 ↗ | (On Diff #9947) | This prop does not appear to be used |
web/modals/chat/sidebar-list-modal.react.js | ||
36–38 ↗ | (On Diff #9947) | Why are we still defining this here |
Going to do another round of self review before asking for additional review.
web/media/multimedia-modal.react.js | ||
---|---|---|
69 ↗ | (On Diff #9947) | Sounds good. I'm going to take another look at this diff and make sure everything is consistent. |
web/media/multimedia.react.js | ||
27 ↗ | (On Diff #9947) | Shouldn't have been! I didn't use BaseProps when defining the ConnectedMultimedaContainer. |
web/modals/chat/sidebar-list-modal.react.js | ||
36–38 ↗ | (On Diff #9947) | yeah, this whole ConnectedSidebarListModal didn't need to happen either. Should have just used the context. |
web/media/multimedia-modal.react.js | ||
---|---|---|
69 ↗ | (On Diff #9947) | Just grepped through all clearModal= prop definitions plus the onClose= prop definitions and we're following the rule:
|
Did a full review this time and only found one issue.
web/modals/modal.react.js | ||
---|---|---|
88–90 |
|
web/modals/modal.react.js | ||
---|---|---|
88–90 |
|