Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MM-53081] Redux store refactor #510

Merged
merged 25 commits into from
Sep 7, 2023
Merged

[MM-53081] Redux store refactor #510

merged 25 commits into from
Sep 7, 2023

Conversation

streamer45
Copy link
Collaborator

Summary

PR reviews most of our reducers and selectors to try and improve a few things:

  • Renaming a bunch of very badly thought and/or confusing objects.
    • Preferring to be on the verbose side (e.g. profilesInCallInCurrentChannel), clarity over efficiency.
  • Make selectors more performant through proper use of createSelector.
    • Mostly tried to optimize all those instances in which we wanted something for the current call or channel. There may be a couple of additional improvements but nothing major I think.
  • Trying to find some consistency in how we design reducers.
    • On this I am trying to stick to the idea that for anything immutable related to a call (e.g. startAt, threadID) we can use a common call state but if something can change throughout the call then we should have a dedicated reducer (e.g. hostID, screenSharingID).

Notes

  • E2E passing is the first step to validate this but there's always a chance we will break something untested so we should plan a long enough soaking time on Community.
  • It would be preferable if any future non urgent PRs touching these files could be based on top of this one to avoid endless conflicts.

Ticket Link

https://mattermost.atlassian.net/browse/MM-53081

@streamer45 streamer45 added 2: Dev Review Requires review by a core committer Do Not Merge Should not be merged until this label is removed labels Aug 30, 2023
@streamer45 streamer45 requested a review from cpoile August 30, 2023 18:45
@streamer45 streamer45 self-assigned this Aug 30, 2023
Comment on lines +29 to +30
CALL_END,
CALL_REC_PROMPT_DISMISSED,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I stripped most of the unnecessary prefixes in this file with the assumption that it's all Calls related. Please let me know if you'd prefer a more verbose take on this side as well.

Copy link
Member

Choose a reason for hiding this comment

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

Definitely this is better, thanks!

@codecov-commenter
Copy link

codecov-commenter commented Aug 30, 2023

Codecov Report

Patch coverage has no change and project coverage change: +0.07% 🎉

Comparison is base (9fdbb65) 5.50% compared to head (e0a6a8c) 5.58%.

Additional details and impacted files
@@           Coverage Diff            @@
##            main    #510      +/-   ##
========================================
+ Coverage   5.50%   5.58%   +0.07%     
========================================
  Files         23      23              
  Lines       4265    4265              
========================================
+ Hits         235     238       +3     
+ Misses      4012    4010       -2     
+ Partials      18      17       -1     

see 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@cpoile cpoile left a comment

Choose a reason for hiding this comment

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

Sorry I don't have any more substantive comments, it looks good. Should bring more clarity when you're deep into the code and searching for the right selector.
Thanks!


export const connectedChannel: (state: GlobalState) => Channel | null =
export const channelForCurrentCall: (state: GlobalState) => Channel =
Copy link
Member

Choose a reason for hiding this comment

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

should this be typed to return Channel | undefined?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, would be safer. I'll update.

Comment on lines +29 to +30
CALL_END,
CALL_REC_PROMPT_DISMISSED,
Copy link
Member

Choose a reason for hiding this comment

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

Definitely this is better, thanks!

Comment on lines +616 to +624
// callState should only hold immutable data, meaning those
// fields that don't change for the whole duration of a call.
export type callState = {
ID: string;
startAt: number;
channelID: string;
threadID: string;
ownerID: string;
}
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we should put this in the types file?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, I am trying to find a compromise between client side state, server side state and redux state. Not super easy at times. Will look into this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@cpoile Let me track a proper review of types as a separate effort especially since I am planning some changes on that front.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Comment on lines +651 to +657
export type hostsState = {
[channelID: string]: {
hostID: string;
hostChangeAt?: number;
};
}

Copy link
Member

Choose a reason for hiding this comment

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

Maybe this too?

Comment on lines +809 to +810
export type recentlyJoinedUsersState = {
[channelID: string]: string[];
Copy link
Member

Choose a reason for hiding this comment

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

I guess this too, if it's being used outside the current file?

};

export const voiceChannelCallHostID = (state: GlobalState, channelID: string) => {
return pluginState(state).voiceChannelCalls[channelID]?.hostID;
const hostsInCalls = (state: GlobalState): hostsState => {
Copy link
Member

Choose a reason for hiding this comment

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

I'm not crazy about the name here... But I can't think of anything better. Something like hostByCall?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's really just internal given it's the base selector so we may as well just call it hosts or callsHosts. Ultimately it doesn't matter that much I guess.

@streamer45 streamer45 added 3: Reviews Complete All reviewers have approved the pull request and removed 2: Dev Review Requires review by a core committer Do Not Merge Should not be merged until this label is removed labels Sep 6, 2023
@streamer45 streamer45 added this to the v0.19.0 - MM 9.0 milestone Sep 6, 2023
@streamer45 streamer45 merged commit 7b200f3 into main Sep 7, 2023
@streamer45 streamer45 deleted the MM-53081 branch September 7, 2023 00:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3: Reviews Complete All reviewers have approved the pull request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants