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

Chore: Remove duplicated useUserRoom #25180

Merged
merged 1 commit into from
Apr 14, 2022
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
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { useDebouncedValue } from '@rocket.chat/fuselage-hooks';
import React, { useCallback, useMemo, useState } from 'react';

import { useUserId, useUserSubscription } from '../../../../contexts/UserContext';
import { useUserId, useUserRoom, useUserSubscription } from '../../../../contexts/UserContext';
import { useRecordList } from '../../../../hooks/lists/useRecordList';
import { AsyncStatePhase } from '../../../../hooks/useAsyncState';
import { useUserRoom } from '../../hooks/useUserRoom';
import { useTabBarClose } from '../../providers/ToolboxProvider';
import { useDiscussionsList } from './useDiscussionsList';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import UserAutoCompleteMultiple from '../../../../components/UserAutoCompleteMul
import { useEndpoint } from '../../../../contexts/ServerContext';
import { useToastMessageDispatch } from '../../../../contexts/ToastMessagesContext';
import { useTranslation } from '../../../../contexts/TranslationContext';
import { useUserRoom } from '../../../../contexts/UserContext';
import { useForm } from '../../../../hooks/useForm';
import { roomCoordinator } from '../../../../lib/rooms/roomCoordinator';
import { SelectedMessageContext, useCountSelected } from '../../MessageList/contexts/SelectedMessagesContext';
import { useUserRoom } from '../../hooks/useUserRoom';

type MailExportFormValues = {
dateFrom: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';

import { useUserRoom } from '../../../hooks/useUserRoom';
import { useUserRoom } from '../../../../../contexts/UserContext';
import { useTabBarClose } from '../../../providers/ToolboxProvider';
import EditChannel from './EditChannel';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
import { useDebouncedValue, useLocalStorage } from '@rocket.chat/fuselage-hooks';
import React, { FC, useCallback, useMemo, useState } from 'react';

import { useUserId, useUserSubscription } from '../../../../contexts/UserContext';
import { useUserId, useUserSubscription, useUserRoom } from '../../../../contexts/UserContext';
import { useRecordList } from '../../../../hooks/lists/useRecordList';
import { AsyncStatePhase } from '../../../../hooks/useAsyncState';
import { ThreadsListOptions } from '../../../../lib/lists/ThreadsList';
import { useUserRoom } from '../../hooks/useUserRoom';
import { useTabBarClose } from '../../providers/ToolboxProvider';
import { ThreadListProps } from './ThreadList';
import { useThreadsList } from './useThreadsList';

const subscriptionFields = { tunread: true, tunreadUser: true, tunreadGroup: true };
const roomFields = { t: 1, name: 1 };
const roomFields = { t: true, name: true };

export function withData(Component: FC<ThreadListProps>): FC<{ rid: string }> {
const WrappedComponent: FC<{ rid: string }> = ({ rid, ...props }) => {
const userId = useUserId();
const onClose = useTabBarClose();
const room = useUserRoom(rid, roomFields);
const subscription = useUserSubscription(rid, subscriptionFields);

const [type, setType] = useLocalStorage<'all' | 'following' | 'unread'>('thread-list-type', 'all');

const [text, setText] = useState('');
Expand Down Expand Up @@ -61,6 +59,10 @@ export function withData(Component: FC<ThreadListProps>): FC<{ rid: string }> {
setText(event.currentTarget.value);
}, []);

if (!room) {
throw new Error('No room available');
}

return (
<Component
{...props}
Expand Down
3 changes: 1 addition & 2 deletions apps/meteor/client/views/room/hooks/useUserInfoActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@ import { useRoute } from '../../../contexts/RouterContext';
import { useMethod } from '../../../contexts/ServerContext';
import { useToastMessageDispatch } from '../../../contexts/ToastMessagesContext';
import { useTranslation } from '../../../contexts/TranslationContext';
import { useUserId, useUserSubscription, useUserSubscriptionByName } from '../../../contexts/UserContext';
import { useUserId, useUserSubscription, useUserRoom, useUserSubscriptionByName } from '../../../contexts/UserContext';
import { useEndpointActionExperimental } from '../../../hooks/useEndpointActionExperimental';
import { useReactiveValue } from '../../../hooks/useReactiveValue';
import { roomCoordinator } from '../../../lib/rooms/roomCoordinator';
import RemoveUsersModal from '../../teams/contextualBar/members/RemoveUsersModal';
import { useUserRoom } from './useUserRoom';
import { useWebRTC } from './useWebRTC';

const useUserHasRoomRole = (uid, rid, role) =>
Expand Down
6 changes: 0 additions & 6 deletions apps/meteor/client/views/room/hooks/useUserRoom.js

This file was deleted.

2 changes: 1 addition & 1 deletion apps/meteor/packages/rocketchat-i18n/i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,7 @@
"Click_here": "Click here",
"Click_here_for_more_details_or_contact_sales_for_a_new_license": "<a target=\"_blank\" href=\"__url__\">Click here</a> for more details or contact <strong>__email__</strong> for a new license.",
"Click_here_for_more_info": "Click here for more info",
"Click_here_to_clear_the_selection": "Click_here_to_clear_the_selection",
"Click_here_to_clear_the_selection": "Click here to clear the selection",
"Click_here_to_enter_your_encryption_password": "Click here to enter your encryption password",
"Click_here_to_view_and_copy_your_password": "Click here to view and copy your password.",
"Click_the_messages_you_would_like_to_send_by_email": "Click the messages you would like to send by e-mail",
Expand Down