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

[FIX] Save button does not stay disabled in Notification Preferences for no change on mute group option #27513

Merged
merged 5 commits into from Jan 12, 2023

Conversation

xareyli
Copy link
Contributor

@xareyli xareyli commented Dec 11, 2022

Proposed changes (including videos or screenshots)

Added default value for "Mute @ALL and @here mentions" option

Issue(s)

Closes #27512

Steps to test or reproduce

Follow the instructions in the issue

Further comments

Lack of default value for muteGroupMentions may cause unexpected behavior

@xareyli
Copy link
Contributor Author

xareyli commented Dec 11, 2022

@hugocostadev please review

@debdutdeb
Copy link
Member

I think in this case we're using any falsy value indication. If that's the case not sure whether this patch is necessary or not.

@hugocostadev
Copy link
Contributor

@debdutdeb is right, I don't think that this is necessary.

@xareyli did you face some issues with this?

@xareyli
Copy link
Contributor Author

xareyli commented Dec 20, 2022

I haven't faced any issues with this. Through logging I have figured out that lack of initial value for muteGroupMentions causes the bug (#27512). Initially muteGroupMentions is undefined. When user toggles it the value turns to true. When they toggle it again, the value is false, which differs from undefined. On my opinion muteGroupMentions should have initial value. But if I am not right, please close the PR. Thanks

@hugocostadev @debdutdeb

@debdutdeb
Copy link
Member

I see.

Ok, for now, we don't have a standard for domain specific falsy values (i.e. for strings, '' instead of undefined, for boolean, false instead of undefined, and so on). I think, for now, a better approach to fixing this would be to figure out what frontend logic is handling the state diff first, and see if it can be fixed there.

@xareyli
Copy link
Contributor Author

xareyli commented Dec 20, 2022

I had a little research on this.

Here we define the muteGroupMentions as undefined, which then will be tried to cast to boolean, which leads to muteGroupMentions is defined with undefined value. My idea is to cast muteGroupMentions to boolean when getting defined (in the first line)
https://github.com/RocketChat/Rocket.Chat/blob/develop/apps/meteor/client/views/room/contextualBar/NotificationPreferences/NotificationPreferencesWithData.tsx#L33
https://github.com/RocketChat/Rocket.Chat/blob/develop/apps/meteor/client/views/room/contextualBar/NotificationPreferences/NotificationPreferencesWithData.tsx#L42

I understand my bad and I am going to create a commit for this PR, which will fix the issue correctly

@xareyli xareyli requested a review from a team as a code owner December 20, 2022 20:44
@xareyli
Copy link
Contributor Author

xareyli commented Dec 20, 2022

@debdutdeb @hugocostadev please review. Think this should work

@codecov
Copy link

codecov bot commented Dec 20, 2022

Codecov Report

Merging #27513 (93ed99f) into develop (029af52) will increase coverage by 0.42%.
The diff coverage is n/a.

❗ Current head 93ed99f differs from pull request most recent head d20510d. Consider uploading reports for the commit d20510d to get more accurate results

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #27513      +/-   ##
===========================================
+ Coverage    41.32%   41.74%   +0.42%     
===========================================
  Files          841      822      -19     
  Lines        17706    17726      +20     
  Branches      1996     1994       -2     
===========================================
+ Hits          7317     7400      +83     
+ Misses       10152    10061      -91     
- Partials       237      265      +28     
Flag Coverage Δ
e2e 41.74% <ø> (+0.42%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

@xareyli xareyli changed the title [FIX] Added default value for muteGroupMentions [FIX] muteGroupMentions option casted to boolean from undefined Dec 21, 2022
@debdutdeb
Copy link
Member

Change the pr title to what you're fixing, not what you're doing code-wise, as that doesn't give us context as to why we need the patch.

@xareyli xareyli changed the title [FIX] muteGroupMentions option casted to boolean from undefined [FIX] Save button does not stay disabled in Notification Preferences for no change on mute group option Dec 22, 2022
@xareyli
Copy link
Contributor Author

xareyli commented Jan 5, 2023

@debdutdeb @hugocostadev if you have spare time, please review

@dionisio-bot dionisio-bot bot added stat: ready to merge PR tested and approved waiting for merge and removed stat: needs QA labels Jan 5, 2023
@hugocostadev hugocostadev added this to the 6.0.0 milestone Jan 5, 2023
@kodiakhq kodiakhq bot merged commit f5f5bf8 into RocketChat:develop Jan 12, 2023
@sampaiodiego sampaiodiego mentioned this pull request Feb 17, 2023
@sampaiodiego sampaiodiego mentioned this pull request Mar 9, 2023
13 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
communityPR stat: QA skipped stat: ready to merge PR tested and approved waiting for merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] - Save button does not stay disabled in Notification Preferences for no change
3 participants