-
Notifications
You must be signed in to change notification settings - Fork 65
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
Conversation
CALL_END, | ||
CALL_REC_PROMPT_DISMISSED, |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 ReportPatch coverage has no change and project coverage change:
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 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this 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!
webapp/src/selectors.ts
Outdated
|
||
export const connectedChannel: (state: GlobalState) => Channel | null = | ||
export const channelForCurrentCall: (state: GlobalState) => Channel = |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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.
CALL_END, | ||
CALL_REC_PROMPT_DISMISSED, |
There was a problem hiding this comment.
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!
// 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; | ||
} |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export type hostsState = { | ||
[channelID: string]: { | ||
hostID: string; | ||
hostChangeAt?: number; | ||
}; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this too?
export type recentlyJoinedUsersState = { | ||
[channelID: string]: string[]; |
There was a problem hiding this comment.
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 => { |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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.
Summary
PR reviews most of our reducers and selectors to try and improve a few things:
profilesInCallInCurrentChannel
), clarity over efficiency.createSelector
.Notes
Ticket Link
https://mattermost.atlassian.net/browse/MM-53081