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

feat: Add Hours, Minutes, Seconds fields while taking input as idleTimeLimit #33708

Open
wants to merge 19 commits into
base: develop
Choose a base branch
from

Conversation

thepiyush-303
Copy link
Contributor

Proposed changes (including videos or screenshots)

Before
image

After
Screenshot from 2024-10-22 21-18-46

Issue(s)

#33566

@thepiyush-303 thepiyush-303 requested review from a team as code owners October 22, 2024 16:56
Copy link
Contributor

dionisio-bot bot commented Oct 22, 2024

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is missing the 'stat: QA assured' label
  • This PR is missing the required milestone or project

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

Copy link

changeset-bot bot commented Oct 22, 2024

🦋 Changeset detected

Latest commit: 4137e43

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 35 packages
Name Type
@rocket.chat/meteor Patch
@rocket.chat/core-typings Patch
@rocket.chat/rest-typings Patch
@rocket.chat/uikit-playground Patch
@rocket.chat/api-client Patch
@rocket.chat/apps Patch
@rocket.chat/core-services Patch
@rocket.chat/cron Patch
@rocket.chat/ddp-client Patch
@rocket.chat/freeswitch Patch
@rocket.chat/fuselage-ui-kit Patch
@rocket.chat/gazzodown Patch
@rocket.chat/livechat Patch
@rocket.chat/model-typings Patch
@rocket.chat/ui-contexts Patch
@rocket.chat/account-service Patch
@rocket.chat/authorization-service Patch
@rocket.chat/ddp-streamer Patch
@rocket.chat/omnichannel-transcript Patch
@rocket.chat/presence-service Patch
@rocket.chat/queue-worker Patch
@rocket.chat/stream-hub-service Patch
@rocket.chat/license Patch
@rocket.chat/omnichannel-services Patch
@rocket.chat/pdf-worker Patch
@rocket.chat/presence Patch
rocketchat-services Patch
@rocket.chat/network-broker Patch
@rocket.chat/models Patch
@rocket.chat/ui-avatar Patch
@rocket.chat/ui-client Patch
@rocket.chat/ui-video-conf Patch
@rocket.chat/ui-voip Patch
@rocket.chat/web-ui-registration Patch
@rocket.chat/instance-status Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@thepiyush-303
Copy link
Contributor Author

Hello @dougfabris ,
Can you please review my changes.

@Gustrb
Copy link
Contributor

Gustrb commented Oct 27, 2024

Hey @thepiyush-303 thanks for your contribution :)
There is no need to ping anyone, your PR will be reviewed as soon as possible.

But taking a closer look at it, it concerns me that we would need to have 3 redundant settings, I think that if we want to follow the approach of having 3 input fields, we could convert their respective values to seconds and just store that, wdyt?

@thepiyush-303
Copy link
Contributor Author

I understand your concern about having redundant settings. Converting the input values to seconds and storing that sounds like a more efficient approach.

However, I’ve encountered a couple of issues while implementing this. Firstly, when I change the field values and save them, they revert to the default values when I navigate back to edit them again.

Additionally, I'm running into an "invalid params" error when I attempt to save the values. This appears to be due to the extra fields not being recognized by the form.

@Gustrb
Copy link
Contributor

Gustrb commented Oct 28, 2024

I am not a frontend dev, but I don't think there is a need to store the value the same way the user put in, for example:

the user inserts 61 minutes, we convert it to 3660 seconds and whenever we load the page we display the value as 1 hour and 1 minute.

it does not sound like a complicated algorithm

The invalid fields error is probably because the backend is not expecting those new fields you are sending

.changeset/wild-sheep-hug.md Outdated Show resolved Hide resolved
apps/meteor/client/startup/startup.ts Outdated Show resolved Hide resolved
apps/meteor/server/methods/saveUserPreferences.ts Outdated Show resolved Hide resolved
@thepiyush-303
Copy link
Contributor Author

I am not a frontend dev, but I don't think there is a need to store the value the same way the user put in, for example:

the user inserts 61 minutes, we convert it to 3660 seconds and whenever we load the page we display the value as 1 hour and 1 minute.

it does not sound like a complicated algorithm

The invalid fields error is probably because the backend is not expecting those new fields you are sending

Thanks for your input! The issue is that the user needs to provide input in hours, minutes, and seconds. Once they enter the values, if they want to see the changes in the fields, the backend would indeed need to support that. That’s why I chose the approach in the PR. If I'm misunderstanding something, please let me know!

@Gustrb
Copy link
Contributor

Gustrb commented Oct 28, 2024

That is what I mean, the backend should not support multiple settings because we should not have multiple settings.
I am pretty sure no one will approve that, the settings for hour, minute and second should be just comestic, internally we should convert to seconds, otherwise we will need to have a specifc way to fetch a specific user preference everytime, we should avoid that bacause it is error prone and confusing

@thepiyush-303
Copy link
Contributor Author

Got it, thanks for the clarification! Should I leave this issue as is, or is there anything else you'd like me to address?

@Gustrb
Copy link
Contributor

Gustrb commented Oct 28, 2024

I mean, if you have the time I think it would be a cool addition to do it in the client

@thepiyush-303
Copy link
Contributor Author

I mean, if you have the time I think it would be a cool addition to do it in the client

but since you mentioned that having multiple settings might not be approved by other collaborators, I'm hesitant to continue with this approach. If it’s a significant enhancement, I’d be happy to explore it further if it aligns with the team's direction.

@Gustrb
Copy link
Contributor

Gustrb commented Oct 28, 2024

What I mean by that is, we have user preferences that we store in the database, I don't think those inputs should be mapped to actual values in the database, I think it would be interesting to convert their values to seconds and keep storing seconds.
The only change that I think would fit in this case is adding the inputs so we can have a better granularity in that field, I don't think that granularity should go all the way to the databse, it should be nothing more than an abstraction.

@thepiyush-303 thepiyush-303 requested a review from Gustrb November 11, 2024 13:40
@thepiyush-303
Copy link
Contributor Author

@Gustrb
I have made the requested changes.

@Gustrb
Copy link
Contributor

Gustrb commented Nov 12, 2024

Hey @thepiyush-303 did you update the PR?
I couldn't see your changes :)

also, thanks for your dedication

@Gustrb Gustrb changed the title feat: Add Hours ,Minutes,Seconds fields while taking input as idleTimeLimit feat: Add Hours, Minutes, Seconds fields while taking input as idleTimeLimit Nov 12, 2024
@@ -27,14 +30,19 @@ const PreferencesUserPresenceSection = () => {
</FieldRow>
</Field>
<Field>
<FieldLabel htmlFor={idleTimeLimit}>{t('Idle_Time_Limit')}</FieldLabel>
<FieldLabel htmlFor={idleTimeLimitH}>{t('Idle_Time_Limit')}</FieldLabel>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't you have access to a OnChange callback or smth?
so you can update idleTimeLimit without needing to have 3 separate settings

@thepiyush-303
Copy link
Contributor Author

thepiyush-303 commented Nov 14, 2024

As per your suggestion, I'm working on the second approach to resolve this issue, but I'm currently stuck on a particular challenge.

When I modify the seconds, minutes, and hours fields, I'm able to convert and store these values as a total in seconds. If you'd like more details, I'm happy to raise a new PR for further clarification.

@thepiyush-303 thepiyush-303 reopened this Dec 15, 2024
@thepiyush-303
Copy link
Contributor Author

Hello @Gustrb ,
I have made the changes you suggested. Specifically:

  1. I updated my approach to storing values in three different settings, aligning with your earlier suggestion.
  2. I have tested the changes, and everything is working fine.

Additionally, I have added a new file. Could you please advise on the appropriate location for this file?

Finally, could you suggest any changes needed to ensure that my code adheres to Rocket's coding standards?

@thepiyush-303 thepiyush-303 requested a review from Gustrb December 15, 2024 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants