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

Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
34d5fb9
addHoursMinSecFields
thepiyush-303 Oct 22, 2024
57161f7
Merge branch 'develop' into addingFeatureInUserPresence
thepiyush-303 Oct 22, 2024
49c34f7
chore:changeset
thepiyush-303 Oct 26, 2024
d4dc02c
Merge branch 'develop' into addingFeatureInUserPresence
thepiyush-303 Oct 26, 2024
ffbee29
Merge branch 'addingFeatureInUserPresence' of https://github.com/thep…
thepiyush-303 Oct 26, 2024
50ab19e
fix Some files
thepiyush-303 Oct 28, 2024
357db55
draft
thepiyush-303 Dec 15, 2024
1081ce2
Merge branch 'addingFeatureInUserPresence' of https://github.com/thep…
thepiyush-303 Dec 15, 2024
c1d385e
newApproach
thepiyush-303 Dec 15, 2024
1366917
newdraft
thepiyush-303 Dec 15, 2024
2d7506e
better approach
thepiyush-303 Dec 15, 2024
dbbe733
lint
thepiyush-303 Dec 15, 2024
7de98a7
lint
thepiyush-303 Dec 15, 2024
aeeb204
lint
thepiyush-303 Dec 15, 2024
0677a65
lint
thepiyush-303 Dec 15, 2024
4545ae7
lint
thepiyush-303 Dec 15, 2024
2003296
merge conflicts
thepiyush-303 Dec 25, 2024
526cdc0
conflicts
thepiyush-303 Dec 25, 2024
4137e43
Merge branch 'develop' into addingFeatureInUserPresence
thepiyush-303 Dec 25, 2024
88b0a1c
fix
thepiyush-303 Dec 31, 2024
c99ce7f
Merge branch 'addingFeatureInUserPresence' of https://github.com/thep…
thepiyush-303 Dec 31, 2024
30a7434
Merge branch 'develop' into addingFeatureInUserPresence
thepiyush-303 Dec 31, 2024
a55f028
fix1
thepiyush-303 Dec 31, 2024
f5159f1
Merge branch 'addingFeatureInUserPresence' of https://github.com/thep…
thepiyush-303 Dec 31, 2024
110689c
lint
thepiyush-303 Dec 31, 2024
b653d23
Merge branch 'develop' into addingFeatureInUserPresence
thepiyush-303 Jan 3, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/wild-sheep-hug.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/meteor': patch
---

Enhanced userPresence options by adding hours and minutes fields alongside seconds for idleTimeLimit, allowing more flexible idle time configuration.
thepiyush-303 marked this conversation as resolved.
Show resolved Hide resolved
9 changes: 8 additions & 1 deletion apps/meteor/client/startup/startup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,14 @@ Meteor.startup(() => {
}

if (getUserPreference(user, 'enableAutoAway')) {
const idleTimeLimit = (getUserPreference(user, 'idleTimeLimit') as number | null | undefined) || 300;
const idleTimeLimitH = (getUserPreference(user, 'idleTimeLimitH') as number | null | undefined) || 0;
thepiyush-303 marked this conversation as resolved.
Show resolved Hide resolved

const idleTimeLimitM = (getUserPreference(user, 'idleTimeLimitM') as number | null | undefined) || 5;

const idleTimeLimitS = (getUserPreference(user, 'idleTimeLimitS') as number | null | undefined) || 0;

const idleTimeLimit = (idleTimeLimitH || 0) * 3600 + (idleTimeLimitM || 0)* 60 + (idleTimeLimitS || 0);
thepiyush-303 marked this conversation as resolved.
Show resolved Hide resolved

UserPresence.awayTime = idleTimeLimit * 1000;
} else {
delete UserPresence.awayTime;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ const PreferencesUserPresenceSection = () => {
const { register, control } = useFormContext();

const enableAutoAwayId = useUniqueId();
const idleTimeLimit = useUniqueId();
const idleTimeLimitH = useUniqueId();
const idleTimeLimitM = useUniqueId();
const idleTimeLimitS = useUniqueId();


return (
<Accordion.Item title={t('User_Presence')}>
Expand All @@ -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>
thepiyush-303 marked this conversation as resolved.
Show resolved Hide resolved
<FieldRow>
<NumberInput id={idleTimeLimit} {...register('idleTimeLimit')} />
<FieldLabel htmlFor="idleTimeLimitH">{t('hours')} </FieldLabel>
<NumberInput id={idleTimeLimitH} {...register('idleTimeLimitH')} />
<FieldLabel htmlFor="idleTimeLimitM">{t('minutes')} </FieldLabel>
<NumberInput id={idleTimeLimitM} {...register('idleTimeLimitM')} max={59} min={0} />
<FieldLabel htmlFor="idleTimeLimitS">{t('seconds')} </FieldLabel>
<NumberInput id={idleTimeLimitS} {...register('idleTimeLimitS')} max={59} min={0} />
</FieldRow>
</Field>
</FieldGroup>
</Accordion.Item>
);
};

export default PreferencesUserPresenceSection;
export default PreferencesUserPresenceSection;
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ export type AccountPreferencesData = {
language?: string;
dontAskAgainList?: string[];
enableAutoAway?: boolean;
idleTimeLimit?: number;
idleTimeLimitH?: number;
idleTimeLimitM?: number;
idleTimeLimitS?: number;
desktopNotificationRequireInteraction?: boolean;
desktopNotifications?: string;
pushNotifications?: string;
Expand Down Expand Up @@ -43,8 +45,10 @@ export const useAccountPreferencesValues = (): AccountPreferencesData => {
const userDontAskAgainList = useUserPreference<{ action: string; label: string }[]>('dontAskAgainList') || [];
const dontAskAgainList = userDontAskAgainList.map(({ action }) => action);
const enableAutoAway = useUserPreference<boolean>('enableAutoAway');
const idleTimeLimit = useUserPreference<number>('idleTimeLimit');

const idleTimeLimitH = useUserPreference<number>('idleTimeLimitH');
thepiyush-303 marked this conversation as resolved.
Show resolved Hide resolved
const idleTimeLimitM = useUserPreference<number>('idleTimeLimitM');
const idleTimeLimitS = useUserPreference<number>('idleTimeLimitS');

const desktopNotificationRequireInteraction = useUserPreference<boolean>('desktopNotificationRequireInteraction');
const desktopNotifications = useUserPreference<string>('desktopNotifications');
const pushNotifications = useUserPreference<string>('pushNotifications');
Expand Down Expand Up @@ -76,7 +80,9 @@ export const useAccountPreferencesValues = (): AccountPreferencesData => {
language,
dontAskAgainList,
enableAutoAway,
idleTimeLimit,
idleTimeLimitH,
idleTimeLimitM,
idleTimeLimitS,
desktopNotificationRequireInteraction,
desktopNotifications,
pushNotifications,
Expand Down
13 changes: 11 additions & 2 deletions apps/meteor/server/methods/saveUserPreferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ type UserPreferences = {
hideFlexTab: boolean;
sendOnEnter: string;
idleTimeLimit: number;
idleTimeLimitH: number;
idleTimeLimitM: number;
idleTimeLimitS: number;
sidebarShowFavorites: boolean;
sidebarShowUnread: boolean;
sidebarSortby: string;
Expand Down Expand Up @@ -107,6 +110,9 @@ export const saveUserPreferences = async (settings: Partial<UserPreferences>, us
displayAvatars: Match.Optional(Boolean),
hideFlexTab: Match.Optional(Boolean),
sendOnEnter: Match.Optional(String),
idleTimeLimitH: Match.Optional(Number),
idleTimeLimitM: Match.Optional(Number),
idleTimeLimitS: Match.Optional(Number),
idleTimeLimit: Match.Optional(Number),
sidebarShowFavorites: Match.Optional(Boolean),
sidebarShowUnread: Match.Optional(Boolean),
Expand Down Expand Up @@ -153,10 +159,13 @@ export const saveUserPreferences = async (settings: Partial<UserPreferences>, us
settings.emailNotificationMode = 'nothing';
}

if (settings.idleTimeLimit != null && settings.idleTimeLimit < 60) {
throw new Meteor.Error('invalid-idle-time-limit-value', 'Invalid idleTimeLimit');
const idleTimeLimit = (settings.idleTimeLimitH || 0) * 3600 + (settings.idleTimeLimitM || 0) * 60 + (settings.idleTimeLimitS || 0);
thepiyush-303 marked this conversation as resolved.
Show resolved Hide resolved

if (settings.idleTimeLimit != null && idleTimeLimit < 60) {
throw new Meteor.Error('invalid-idle-time-limit-value', 'Idle time limit must be at least 1 minutes.');
thepiyush-303 marked this conversation as resolved.
Show resolved Hide resolved
}


await Users.setPreferences(user._id, settings);

const diff = (Object.keys(settings) as (keyof UserPreferences)[]).reduce<Record<string, any>>((data, key) => {
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/server/settings/accounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -867,4 +867,4 @@ export const createAccountSettings = () =>
i18nDescription: 'Password_History_Amount_Description',
});
});
});
});
14 changes: 12 additions & 2 deletions packages/rest-typings/src/v1/users/UsersSetPreferenceParamsPOST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ export type UsersSetPreferencesParamsPOST = {
fontSize?: FontSize;
receiveLoginDetectionEmail?: boolean;
notifyCalendarEvents?: boolean;
idleTimeLimit?: number;
idleTimeLimitH?: number;
idleTimeLimitM?: number;
idleTimeLimitS?: number;
omnichannelTranscriptEmail?: boolean;
omnichannelTranscriptPDF?: boolean;
omnichannelHideConversationAfterClosing?: boolean;
Expand Down Expand Up @@ -231,7 +233,15 @@ const UsersSetPreferencesParamsPostSchema = {
type: 'boolean',
nullable: true,
},
idleTimeLimit: {
idleTimeLimitH: {
type: 'number',
nullable: true,
},
idleTimeLimitM: {
type: 'number',
nullable: true,
},
idleTimeLimitS: {
type: 'number',
nullable: true,
},
Expand Down