-
Notifications
You must be signed in to change notification settings - Fork 7.1k
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
fix(lobby-notifications): Prevent lobby notification to remain on scr… #11054
fix(lobby-notifications): Prevent lobby notification to remain on scr… #11054
Conversation
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.
Some minor comments, PTAL!
react/features/lobby/middleware.js
Outdated
dispatch(rejectKnockingParticipant(firstParticipant.id)); | ||
}) ]; | ||
} | ||
if (knockingParticipants.length === 0) { |
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.
Can you please move this up? Otherwise the code will first create a notification that will never be used. We can check this the first thing and return early.
react/features/lobby/middleware.js
Outdated
let icon; | ||
|
||
const knockingParticipants = getKnockingParticipants(getState()); | ||
const firstParticipant = knockingParticipants[0]; |
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.
Move this constant to the branch where its actually used please.
react/features/lobby/middleware.js
Outdated
dispatch(hideNotification(LOBBY_NOTIFICATION_ID)); | ||
dispatch(openParticipantsPane()); | ||
}) ]; | ||
} else { |
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.
While we are here, please let's reverse the logic. Check if length === 1, and do the other part in the else.
react/features/lobby/middleware.js
Outdated
dispatch(hideNotification(LOBBY_NOTIFICATION_ID)); | ||
dispatch(rejectKnockingParticipant(firstParticipant.id)); | ||
}) ]; | ||
} else if (knockingParticipants.length > 1) { |
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.
make this an else pl
|
||
if (knockingParticipants.length === 0) { | ||
dispatch(hideNotification(LOBBY_NOTIFICATION_ID)); | ||
} else { |
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.
You could just return
in the if branch, to avoid a large else.
customActionHandler, | ||
icon | ||
}, NOTIFICATION_TIMEOUT_TYPE.STICKY)); | ||
_handleLobbyNotification({ |
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.
nit: leave a newline for for extra breathing room :-)
Perfect! |
…een.