Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions apps/meteor/client/apps/gameCenter/GameCenter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { IExternalComponent } from '@rocket.chat/apps-engine/definition/ext
import { useEffectEvent } from '@rocket.chat/fuselage-hooks';
import { useRoomToolbox } from '@rocket.chat/ui-contexts';
import { useState } from 'react';
import type { MouseEvent, ReactElement } from 'react';
import type { MouseEvent } from 'react';

import GameCenterContainer from './GameCenterContainer';
import GameCenterList from './GameCenterList';
Expand All @@ -11,7 +11,7 @@ import { preventSyntheticEvent } from '../../lib/utils/preventSyntheticEvent';

export type IGame = IExternalComponent;

const GameCenter = (): ReactElement => {
const GameCenter = () => {
const [openedGame, setOpenedGame] = useState<IGame>();

const { closeTab } = useRoomToolbox();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
ContextualbarClose,
ContextualbarDialog,
} from '@rocket.chat/ui-client';
import type { ReactElement } from 'react';
import { useTranslation } from 'react-i18next';

import type { IGame } from './GameCenter';
Expand All @@ -18,7 +17,7 @@ interface IGameCenterContainerProps {
game: IGame;
}

const GameCenterContainer = ({ handleClose, handleBack, game }: IGameCenterContainerProps): ReactElement => {
const GameCenterContainer = ({ handleClose, handleBack, game }: IGameCenterContainerProps) => {
const { t } = useTranslation();

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import type { IUser } from '@rocket.chat/core-typings';
import { Box } from '@rocket.chat/fuselage';
import { Random } from '@rocket.chat/random';
import { GenericModal } from '@rocket.chat/ui-client';
import type { ReactElement } from 'react';
import { useState } from 'react';
import { useTranslation } from 'react-i18next';

Expand All @@ -20,7 +19,7 @@ interface IGameCenterInvitePlayersModalProps {
onClose: () => void;
}

const GameCenterInvitePlayersModal = ({ game, onClose }: IGameCenterInvitePlayersModalProps): ReactElement => {
const GameCenterInvitePlayersModal = ({ game, onClose }: IGameCenterInvitePlayersModalProps) => {
const { t } = useTranslation();
const [users, setUsers] = useState<Array<Username>>([]);
const { name } = game;
Expand Down
3 changes: 1 addition & 2 deletions apps/meteor/client/apps/gameCenter/GameCenterList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
ContextualbarSkeleton,
} from '@rocket.chat/ui-client';
import { useSetModal } from '@rocket.chat/ui-contexts';
import type { ReactElement } from 'react';
import { memo, useCallback } from 'react';
import { useTranslation } from 'react-i18next';

Expand All @@ -22,7 +21,7 @@ interface IGameCenterListProps {
isLoading: boolean;
}

const GameCenterList = ({ handleClose, handleOpenGame, games, isLoading }: IGameCenterListProps): ReactElement => {
const GameCenterList = ({ handleClose, handleOpenGame, games, isLoading }: IGameCenterListProps) => {
const { t } = useTranslation();
const setModal = useSetModal();

Expand Down
4 changes: 2 additions & 2 deletions apps/meteor/client/providers/ActionManagerProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ActionManagerContext, useRouter } from '@rocket.chat/ui-contexts';
import type { ReactNode, ReactElement } from 'react';
import type { ReactNode } from 'react';

import { ActionManager } from '../../app/ui-message/client/ActionManager';
import { useAppActionButtons } from '../hooks/useAppActionButtons';
Expand All @@ -12,7 +12,7 @@ type ActionManagerProviderProps = {
children?: ReactNode;
};

const ActionManagerProvider = ({ children }: ActionManagerProviderProps): ReactElement => {
const ActionManagerProvider = ({ children }: ActionManagerProviderProps) => {
const router = useRouter();
const actionManager = useInstance(() => [new ActionManager(router)], [router]);
useTranslationsForApps();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { capitalize } from '@rocket.chat/string-helpers';
import { AuthenticationContext, useSetting } from '@rocket.chat/ui-contexts';
import { Accounts } from 'meteor/accounts-base';
import { Meteor } from 'meteor/meteor';
import type { ContextType, ReactElement, ReactNode } from 'react';
import type { ContextType, ReactNode } from 'react';
import { useMemo, useSyncExternalStore } from 'react';

import { useLDAPAndCrowdCollisionWarning } from './hooks/useLDAPAndCrowdCollisionWarning';
Expand Down Expand Up @@ -57,7 +57,7 @@ const subscribeLoggingIn = (cb: () => void): (() => void) => {

const getLoggingInSnapshot = (): boolean => Accounts.loggingIn();

const AuthenticationProvider = ({ children }: AuthenticationProviderProps): ReactElement => {
const AuthenticationProvider = ({ children }: AuthenticationProviderProps) => {
const isLdapEnabled = useSetting('LDAP_Enable', false);
const isCrowdEnabled = useSetting('CROWD_Enable', false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useEffectEvent } from '@rocket.chat/fuselage-hooks';
import type { Device, DeviceContextValue } from '@rocket.chat/ui-contexts';
import { DeviceContext } from '@rocket.chat/ui-contexts';
import { useQuery, useQueryClient, keepPreviousData } from '@tanstack/react-query';
import type { ReactElement, ReactNode } from 'react';
import type { ReactNode } from 'react';
import { useEffect, useState, useMemo } from 'react';

import { isSetSinkIdAvailable } from './lib/isSetSinkIdAvailable';
Expand All @@ -28,7 +28,7 @@ const defaultDevices = {

const devicesQueryKey = ['media-devices-list'];

export const DeviceProvider = ({ children }: DeviceProviderProps): ReactElement => {
export const DeviceProvider = ({ children }: DeviceProviderProps) => {
const [enabled] = useState(typeof isSecureContext && isSecureContext);
const [selectedAudioOutputDevice, setSelectedAudioOutputDevice] = useState<Device | undefined>(undefined);
const [selectedAudioInputDevice, setSelectedAudioInputDevice] = useState<Device | undefined>(undefined);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useDebouncedState, useEffectEvent, useLocalStorage } from '@rocket.chat/fuselage-hooks';
import type { ReactNode, ReactElement, ContextType } from 'react';
import type { ReactNode, ContextType } from 'react';
import { useState, useCallback, useMemo, useSyncExternalStore } from 'react';

import { useUpdateCustomEmoji } from './useUpdateCustomEmoji';
Expand All @@ -12,8 +12,8 @@ const DEFAULT_ITEMS_LIMIT = 90;
// limit recent emojis to 27 (3 rows of 9)
const RECENT_EMOJIS_LIMIT = 27;

const EmojiPickerProvider = ({ children }: { children: ReactNode }): ReactElement => {
const [emojiPicker, setEmojiPicker] = useState<ReactElement | null>(null);
const EmojiPickerProvider = ({ children }: { children: ReactNode }) => {
const [emojiPicker, setEmojiPicker] = useState<ReactNode>(null);
const [emojiToPreview, setEmojiToPreview] = useDebouncedState<{ emoji: string; name: string } | null>(null, 100);
const [recentEmojis, setRecentEmojis] = useLocalStorage<string[]>('emoji.recent', []);
const [frequentEmojis, setFrequentEmojis] = useLocalStorage<[string, number][]>('emoji.frequent', []);
Expand Down
6 changes: 3 additions & 3 deletions apps/meteor/client/providers/TranslationProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import type { TranslationContextValue } from '@rocket.chat/ui-contexts';
import { useSetting, TranslationContext } from '@rocket.chat/ui-contexts';
import type i18next from 'i18next';
import I18NextHttpBackend from 'i18next-http-backend';
import type { ReactElement, ReactNode } from 'react';
import type { ReactNode } from 'react';
import { useEffect, useMemo } from 'react';
import { I18nextProvider, initReactI18next, useTranslation } from 'react-i18next';

Expand Down Expand Up @@ -188,7 +188,7 @@ type TranslationProviderProps = {
children: ReactNode;
};

const TranslationProvider = ({ children }: TranslationProviderProps): ReactElement => {
const TranslationProvider = ({ children }: TranslationProviderProps) => {
const language = useAutoLanguage();
const i18nextInstance = useI18next(language);
useCustomTranslations(i18nextInstance);
Expand Down Expand Up @@ -252,7 +252,7 @@ const TranslationProviderInner = ({
ogName: string;
key: string;
}[];
}): ReactElement => {
}) => {
const { t, i18n } = useTranslation();

const value: TranslationContextValue = useMemo(
Expand Down
4 changes: 2 additions & 2 deletions apps/meteor/client/providers/UserProvider/UserProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { UserContext, useRouteParameter, useSearchParameter } from '@rocket.chat
import { useQueryClient } from '@tanstack/react-query';
import { Meteor } from 'meteor/meteor';
import type { Filter, ObjectId } from 'mongodb';
import type { ContextType, ReactElement, ReactNode } from 'react';
import type { ContextType, ReactNode } from 'react';
import { useEffect, useMemo, useRef } from 'react';
import type { StoreApi, UseBoundStore } from 'zustand';

Expand Down Expand Up @@ -61,7 +61,7 @@ const queryRoom = (
return [subscribe, getSnapshot];
};

const UserProvider = ({ children }: UserProviderProps): ReactElement => {
const UserProvider = ({ children }: UserProviderProps) => {
const userId = userIdStore();

const user = Users.use((state) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { LegacyRoomManager } from '../../../../app/ui-utils/client';
import { roomCoordinator } from '../../../lib/rooms/roomCoordinator';

export const useReloadAfterLogin = (user: IUser | null) => {
const usernameRef = useRef<string>();
const usernameRef = useRef<string>(undefined);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Type annotation mismatch: useRef<string> initialized with undefined.

The ref is typed as useRef<string> but initialized with undefined, which creates a type mismatch. Lines 13-14 correctly treat usernameRef.current as possibly falsy, but the type annotation doesn't reflect this.

🔧 Correct the type annotation
-	const usernameRef = useRef<string>(undefined);
+	const usernameRef = useRef<string | undefined>(undefined);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const usernameRef = useRef<string>(undefined);
const usernameRef = useRef<string | undefined>(undefined);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/meteor/client/providers/UserProvider/hooks/useReloadAfterLogin.ts` at
line 9, The ref usernameRef in the hook useReloadAfterLogin is typed as
useRef<string> but initialized to undefined, causing a type mismatch; update the
ref's type to allow undefined (e.g., useRef<string | undefined>) or initialize
it with a string value so the declared type matches its initial value, and
ensure any usages of usernameRef.current still handle possible undefined values.

const router = useRouter();

useEffect(() => {
Expand Down
4 changes: 2 additions & 2 deletions apps/meteor/client/providers/VideoConfProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { useToastMessageDispatch, useSetting } from '@rocket.chat/ui-contexts';
import type { VideoConfPopupPayload, VideoConfContextValue } from '@rocket.chat/ui-video-conf';
import { VideoConfContext } from '@rocket.chat/ui-video-conf';
import type { ReactElement, ReactNode } from 'react';
import type { ReactNode } from 'react';
import { useState, useMemo, useEffect } from 'react';
import { useTranslation } from 'react-i18next';

import { VideoConfManager } from '../lib/VideoConfManager';
import VideoConfPopups from '../views/room/contextualBar/VideoConference/VideoConfPopups';
import { useVideoConfOpenCall } from '../views/room/contextualBar/VideoConference/hooks/useVideoConfOpenCall';

const VideoConfContextProvider = ({ children }: { children: ReactNode }): ReactElement => {
const VideoConfContextProvider = ({ children }: { children: ReactNode }) => {
const [outgoing, setOutgoing] = useState<VideoConfPopupPayload | undefined>();
const handleOpenCall = useVideoConfOpenCall();
const dispatchToastMessage = useToastMessageDispatch();
Expand Down
4 changes: 2 additions & 2 deletions apps/meteor/client/stories/contexts/ModalContextMock.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ModalContext } from '@rocket.chat/ui-contexts';
import { action } from '@storybook/addon-actions';
import type { ContextType, ReactElement, ReactNode } from 'react';
import type { ContextType, ReactNode } from 'react';
import { useContext, useMemo } from 'react';

const logAction = action('ModalContext');
Expand All @@ -9,7 +9,7 @@ type ModalContextMockProps = {
children: ReactNode;
};

const ModalContextMock = ({ children }: ModalContextMockProps): ReactElement => {
const ModalContextMock = ({ children }: ModalContextMockProps) => {
const context = useContext(ModalContext);

const value = useMemo(
Expand Down
4 changes: 2 additions & 2 deletions apps/meteor/client/stories/contexts/RouterContextMock.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { RouterContext } from '@rocket.chat/ui-contexts';
import { action } from '@storybook/addon-actions';
import type { ContextType, ReactElement, ReactNode } from 'react';
import type { ContextType, ReactNode } from 'react';
import { useContext, useMemo } from 'react';

const logAction = action('RouterContext');
Expand All @@ -15,7 +15,7 @@ window.__meteor_runtime_config__ = {
ROOT_URL_PATH_PREFIX: '',
};

const RouterContextMock = ({ children }: RouterContextMockProps): ReactElement => {
const RouterContextMock = ({ children }: RouterContextMockProps) => {
const parent = useContext(RouterContext);

const value = useMemo(
Expand Down
10 changes: 2 additions & 8 deletions apps/meteor/client/stories/contexts/ServerContextMock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { Method, OperationParams, OperationResult, PathFor, PathPattern } f
import type { UploadResult } from '@rocket.chat/ui-contexts';
import { ServerContext } from '@rocket.chat/ui-contexts';
import { action } from '@storybook/addon-actions';
import type { ContextType, ReactElement, ReactNode } from 'react';
import type { ContextType, ReactNode } from 'react';
import { useContext, useMemo } from 'react';

const logAction = action('ServerContext');
Expand Down Expand Up @@ -66,13 +66,7 @@ type ServerContextMockProps = Omit<Partial<ContextType<typeof ServerContext>>, '
};
};

const ServerContextMock = ({
children,
baseURL,
callEndpoint = {},
callMethod = {},
...overrides
}: ServerContextMockProps): ReactElement => {
const ServerContextMock = ({ children, baseURL, callEndpoint = {}, callMethod = {}, ...overrides }: ServerContextMockProps) => {
const parent = useContext(ServerContext);

const value = useMemo((): ContextType<typeof ServerContext> => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import type { TranslationKey } from '@rocket.chat/ui-contexts';
import { TranslationContext } from '@rocket.chat/ui-contexts';
import i18next from 'i18next';
import type { ContextType, ReactElement, ReactNode } from 'react';
import type { ContextType, ReactNode } from 'react';
import { useContext, useMemo } from 'react';

type TranslationContextMockProps = {
children: ReactNode;
};

const TranslationContextMock = ({ children }: TranslationContextMockProps): ReactElement => {
const TranslationContextMock = ({ children }: TranslationContextMockProps) => {
const parent = useContext(TranslationContext);

const value = useMemo<ContextType<typeof TranslationContext>>(() => {
Expand Down
Loading