Skip to content

refactor: remove startup from Meteor#35915

Draft
juliajforesti wants to merge 2 commits into
developfrom
refactor/startup
Draft

refactor: remove startup from Meteor#35915
juliajforesti wants to merge 2 commits into
developfrom
refactor/startup

Conversation

@juliajforesti
Copy link
Copy Markdown
Contributor

@juliajforesti juliajforesti commented Apr 30, 2025

ARCH-1551

Proposed changes (including videos or screenshots)

WIP

Issue(s)

Steps to test or reproduce

Further comments


This pull request refactors the Rocket.Chat codebase by removing the startup logic from Meteor and introducing a new React hook named useStartup. The useStartup hook is responsible for handling user-specific initialization tasks after login, such as synchronizing user data, setting the UTC offset, configuring user presence based on preferences (including auto-away settings), and managing initial status updates through global events. Additionally, the useStartup hook has been integrated into the AppLayout component. The changes are made in the apps/meteor/client/hooks/useStartup.ts and apps/meteor/client/views/root/AppLayout.tsx files. The source branch for this refactor is refactor/startup, and the target branch is develop.

@dionisio-bot
Copy link
Copy Markdown
Contributor

dionisio-bot Bot commented Apr 30, 2025

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

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 30, 2025

⚠️ No Changeset found

Latest commit: 98487a1

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@kody-ai
Copy link
Copy Markdown

kody-ai Bot commented Apr 30, 2025

Code Review Completed! 🔥

The code review was successfully completed based on your current configurations.

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Security
Code Style
Kody Rules
Refactoring
Error Handling
Maintainability
Potential Issues
Documentation And Comments
Performance And Optimization
Breaking Changes

Access your configuration settings here.

return;
}

const getUser = async () => {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

kody code-review Error Handling high

const getUser = async () => {
			try {
				const utcOffset = moment().utcOffset() / 60;
				const user = await synchronizeUserData(uid);
				if (!user) {
					console.error('User data synchronization failed.'); // Or handle more gracefully
					return;
				}
				if (user.utcOffset !== utcOffset) {
					await sdk.call('userSetUtcOffset', utcOffset);
				}

				if (getUserPreference(user, 'enableAutoAway')) {
					const idleTimeLimit = (getUserPreference(user, 'idleTimeLimit') as number | null | undefined) || 300;
					UserPresence.awayTime = idleTimeLimit * 1000;
				} else {
					delete UserPresence.awayTime;
					UserPresence.stopTimer();
				}

				setStatus(user.status);
				UserPresence.start();
			} catch (error) {
				console.error('Error during user startup sequence:', error);
				// Potentially set an error state or notify the user
			}
		};

The useStartup hook lacks proper documentation, making it difficult to understand its purpose and usage.

This issue appears in multiple locations:

  • apps/meteor/client/hooks/useStartup.ts: Lines 32-52
  • apps/meteor/client/hooks/useStartup.ts: Lines 14-14
  • apps/meteor/client/views/root/AppLayout.tsx: Lines 27-27
    Please add JSDoc comments to the useStartup hook to clearly explain its functionality and any side effects.

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.

import { synchronizeUserData, removeLocalUserData } from '../lib/userData';
import { fireGlobalEvent } from '../lib/utils/fireGlobalEvent';

export const useStartup = () => {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

kody code-review Documentation and Comments high

/**
 * @description Hook to handle user-specific initialization after login.
 * Synchronizes user data, sets UTC offset, configures presence (auto-away),
 * updates status, starts presence tracking, and fires 'startup' and 'status-changed' global events.
 */
export const useStartup = () => {

The useStartup hook lacks proper documentation, making it difficult to understand its purpose and usage.

This issue appears in multiple locations:

  • apps/meteor/client/hooks/useStartup.ts: Lines 14-14
    Please add JSDoc comments to the useStartup hook to clearly explain its functionality and any side effects.

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 30, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 61.15%. Comparing base (4f0bc99) to head (98487a1).
⚠️ Report is 1844 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #35915      +/-   ##
===========================================
- Coverage    61.16%   61.15%   -0.01%     
===========================================
  Files         3014     3014              
  Lines        71625    71560      -65     
  Branches     16403    16390      -13     
===========================================
- Hits         43808    43762      -46     
+ Misses       24850    24830      -20     
- Partials      2967     2968       +1     
Flag Coverage Δ
unit 75.10% <ø> (ø)

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions
Copy link
Copy Markdown
Contributor

PR Preview Action v1.6.1

🚀 View preview at
https://RocketChat.github.io/Rocket.Chat/pr-preview/pr-35915/

Built to branch gh-pages at 2025-04-30 18:02 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

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.

1 participant