[FIX] Save button does not stay disabled in Notification Preferences for no change on mute group option
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
@hugocostadev please review
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.
@debdutdeb is right, I don't think that this is necessary.
@xareyli did you face some issues with this?
I haven't faced any issues with this. Through logging I have figured out that lack of initial value for muteGroupMentions causes the bug (https://github.com/RocketChat/Rocket.Chat/issues/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
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.
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
@debdutdeb @hugocostadev please review. Think this should work
Codecov Report
Merging #27513 (93ed99f) into develop (029af52) will increase coverage by
0.42%. The diff coverage isn/a.
:exclamation: Current head 93ed99f differs from pull request most recent head d20510d. Consider uploading reports for the commit d20510d to get more accurate results
@@ 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%) |
:arrow_up: |
Flags with carried forward coverage won't be shown. Click here to find out more.
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.
@debdutdeb @hugocostadev if you have spare time, please review