Rocket.Chat icon indicating copy to clipboard operation
Rocket.Chat copied to clipboard

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

Open xareyli opened this issue 3 years ago • 9 comments

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 avatar Dec 11 '22 15:12 xareyli

@hugocostadev please review

xareyli avatar Dec 11 '22 15:12 xareyli

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 avatar Dec 11 '22 16:12 debdutdeb

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

@xareyli did you face some issues with this?

hugocostadev avatar Dec 20 '22 13:12 hugocostadev

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

xareyli avatar Dec 20 '22 18:12 xareyli

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.

debdutdeb avatar Dec 20 '22 18:12 debdutdeb

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 avatar Dec 20 '22 20:12 xareyli

@debdutdeb @hugocostadev please review. Think this should work

xareyli avatar Dec 20 '22 20:12 xareyli

Codecov Report

Merging #27513 (93ed99f) into develop (029af52) will increase coverage by 0.42%. The diff coverage is n/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

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%) :arrow_up:

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

codecov[bot] avatar Dec 20 '22 22:12 codecov[bot]

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 avatar Dec 22 '22 13:12 debdutdeb

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

xareyli avatar Jan 05 '23 15:01 xareyli