Skip to content

Commit 901ce98

Browse files
authored
Merge branch 'develop' into fix/room-loadhistory
2 parents 64c1c82 + 2f5e287 commit 901ce98

File tree

114 files changed

+581
-428
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+581
-428
lines changed

apps/meteor/client/apps/gameCenter/GameCenter.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { IExternalComponent } from '@rocket.chat/apps-engine/definition/externalComponent';
22
import { useEffectEvent } from '@rocket.chat/fuselage-hooks';
33
import { useState } from 'react';
4-
import type { ReactElement } from 'react';
4+
import type { MouseEvent, ReactElement } from 'react';
55

66
import GameCenterContainer from './GameCenterContainer';
77
import GameCenterList from './GameCenterList';
@@ -18,12 +18,12 @@ const GameCenter = (): ReactElement => {
1818

1919
const result = useExternalComponentsQuery();
2020

21-
const handleClose = useEffectEvent((e) => {
21+
const handleClose = useEffectEvent((e: MouseEvent) => {
2222
preventSyntheticEvent(e);
2323
closeTab();
2424
});
2525

26-
const handleBack = useEffectEvent((e) => {
26+
const handleBack = useEffectEvent((e: MouseEvent) => {
2727
setOpenedGame(undefined);
2828
preventSyntheticEvent(e);
2929
});

apps/meteor/client/components/avatar/RoomAvatarEditor.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const RoomAvatarEditor = ({ disabled = false, room, roomAvatar, onChangeAvatar }
2424
const { t } = useTranslation();
2525
const dispatchToastMessage = useToastMessageDispatch();
2626

27-
const handleChangeAvatar = useEffectEvent(async (file) => {
27+
const handleChangeAvatar = useEffectEvent(async (file: File) => {
2828
const reader = new FileReader();
2929
reader.readAsDataURL(file);
3030
reader.onloadend = async (): Promise<void> => {

apps/meteor/client/hooks/useClipboardWithToast.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ export default function useClipboardWithToast(text: string): UseClipboardReturn
99

1010
return useClipboard(text, {
1111
onCopySuccess: useEffectEvent(() => dispatchToastMessage({ type: 'success', message: t('Copied') })),
12-
onCopyError: useEffectEvent((e) => dispatchToastMessage({ type: 'error', message: e })),
12+
onCopyError: useEffectEvent((e?: Error) => dispatchToastMessage({ type: 'error', message: e })),
1313
});
1414
}

apps/meteor/client/hooks/usePreventPropagation.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { useEffectEvent } from '@rocket.chat/fuselage-hooks';
22
import type { UIEvent } from 'react';
33

44
export const usePreventPropagation = (fn?: (e: UIEvent) => void): ((e: UIEvent) => void) => {
5-
const preventClickPropagation = useEffectEvent((e): void => {
5+
const preventClickPropagation = useEffectEvent((e: UIEvent): void => {
66
e.stopPropagation();
77
fn?.(e);
88
});
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
import { useHasLicenseModule } from '../../hooks/useHasLicenseModule';
22
import AutoCompleteTagsMultiple from '../tags/AutoCompleteTagsMultiple';
33

4-
type CurrentChatTagsProps = { value: Array<{ value: string; label: string }>; handler: any; department?: string; viewAll?: boolean };
4+
type CurrentChatTagsProps = {
5+
value: Array<{ value: string; label: string }>;
6+
handler: (value: { label: string; value: string }[]) => void;
7+
department?: string;
8+
viewAll?: boolean;
9+
};
510

611
const CurrentChatTags = ({ value, handler, department, viewAll }: CurrentChatTagsProps) => {
712
const hasLicense = useHasLicenseModule('livechat-enterprise');
@@ -10,7 +15,14 @@ const CurrentChatTags = ({ value, handler, department, viewAll }: CurrentChatTag
1015
return null;
1116
}
1217

13-
return <AutoCompleteTagsMultiple onChange={handler} value={value} department={department} viewAll={viewAll} />;
18+
return (
19+
<AutoCompleteTagsMultiple
20+
onChange={handler as any} // FIXME: any
21+
value={value}
22+
department={department}
23+
viewAll={viewAll}
24+
/>
25+
);
1426
};
1527

1628
export default CurrentChatTags;

apps/meteor/client/omnichannel/businessHours/useRemoveBusinessHour.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const useRemoveBusinessHour = () => {
1212
const removeBusinessHour = useMethod('livechat:removeBusinessHour');
1313
const queryClient = useQueryClient();
1414

15-
const handleRemove = useEffectEvent((_id, type) => {
15+
const handleRemove = useEffectEvent((_id: string, type: string) => {
1616
const onDeleteBusinessHour = async () => {
1717
try {
1818
await removeBusinessHour(_id, type);

apps/meteor/client/omnichannel/cannedResponses/CannedResponsesTable.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ const CannedResponsesTable = () => {
6464

6565
const handleAddNew = useEffectEvent(() => router.navigate('/omnichannel/canned-responses/new'));
6666

67-
const onRowClick = useEffectEvent((id, scope) => (): void => {
67+
const onRowClick = useEffectEvent((id: string, scope: string) => (): void => {
6868
if (scope === 'global' && isMonitor && !isManager) {
6969
return dispatchToastMessage({
7070
type: 'error',

apps/meteor/client/omnichannel/cannedResponses/contextualBar/CannedResponse/CannedResponseList.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ type CannedResponseListProps = {
3131
type: string;
3232
setType: Dispatch<SetStateAction<string>>;
3333
isRoomOverMacLimit: boolean;
34-
onClickItem: (data: any) => void;
34+
onClickItem: (data: any) => void; // FIXME: fix typings
3535
onClickCreate: (e: MouseEvent<HTMLOrSVGElement>) => void;
3636
onClickUse: (e: MouseEvent<HTMLOrSVGElement>, text: string) => void;
3737
reload: () => void;

apps/meteor/client/omnichannel/cannedResponses/contextualBar/CannedResponse/WrapCannedResponseList.tsx

+18-11
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { IOmnichannelCannedResponse, ILivechatDepartment } from '@rocket.chat/core-typings';
12
import { useDebouncedValue, useLocalStorage, useEffectEvent } from '@rocket.chat/fuselage-hooks';
23
import { useSetModal, useRouter } from '@rocket.chat/ui-contexts';
34
import type { ChangeEvent, MouseEvent } from 'react';
@@ -38,18 +39,24 @@ export const WrapCannedResponseList = () => {
3839
);
3940
const { phase, items, itemCount } = useRecordList(cannedList);
4041

41-
const onClickItem = useEffectEvent((data) => {
42-
const { _id: context } = data;
43-
44-
router.navigate({
45-
name: router.getRouteName() ?? 'live',
46-
params: {
47-
id: room._id,
48-
tab: 'canned-responses',
49-
context,
42+
const onClickItem = useEffectEvent(
43+
(
44+
data: IOmnichannelCannedResponse & {
45+
departmentName: ILivechatDepartment['name'];
5046
},
51-
});
52-
});
47+
) => {
48+
const { _id: context } = data;
49+
50+
router.navigate({
51+
name: router.getRouteName() ?? 'live',
52+
params: {
53+
id: room._id,
54+
tab: 'canned-responses',
55+
context,
56+
},
57+
});
58+
},
59+
);
5360

5461
const composer = useChat()?.composer;
5562

apps/meteor/client/omnichannel/cannedResponses/useRemoveCannedResponse.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export const useRemoveCannedResponse = () => {
1414
const dispatchToastMessage = useToastMessageDispatch();
1515
const removeCannedResponse = useMethod('removeCannedResponse');
1616

17-
const handleDelete = useEffectEvent((id) => {
17+
const handleDelete = useEffectEvent((id: string) => {
1818
const onDeleteCannedResponse: () => Promise<void> = async () => {
1919
try {
2020
await removeCannedResponse(id);

apps/meteor/client/omnichannel/reports/components/AgentsTable.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ type AgentsTableProps = {
2424
export const AgentsTable = memo(({ data, sortBy, sortDirection, setSort }: AgentsTableProps) => {
2525
const { t } = useTranslation();
2626

27-
const onHeaderClick = useEffectEvent((id) => {
27+
const onHeaderClick = useEffectEvent((id: 'name' | 'total') => {
2828
setSort(id, sortDirection === 'asc' ? 'desc' : 'asc');
2929
});
3030

apps/meteor/client/omnichannel/slaPolicies/RemoveSlaButton.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { IconButton } from '@rocket.chat/fuselage';
22
import { useEffectEvent } from '@rocket.chat/fuselage-hooks';
33
import { useRoute, useEndpoint, useSetModal, useToastMessageDispatch } from '@rocket.chat/ui-contexts';
4+
import type { MouseEvent } from 'react';
45
import { useTranslation } from 'react-i18next';
56

67
import GenericModal from '../../components/GenericModal';
@@ -14,7 +15,7 @@ const RemoveSlaButton = ({ _id, reload }: { _id: string; reload: () => void }) =
1415

1516
const removeSLA = useEndpoint('DELETE', `/v1/livechat/sla/:slaId`, { slaId: _id });
1617

17-
const handleDelete = useEffectEvent((e) => {
18+
const handleDelete = useEffectEvent((e: MouseEvent) => {
1819
e.stopPropagation();
1920
const onDeleteAgent = async (): Promise<void> => {
2021
try {

apps/meteor/client/omnichannel/slaPolicies/SlaTable.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ const SlaTable = ({ reload }: { reload: MutableRefObject<() => void> }) => {
5656
}, [reload, refetch]);
5757

5858
const handleAddNew = useEffectEvent(() => router.navigate('/omnichannel/sla-policies/new'));
59-
const onRowClick = useEffectEvent((id) => () => router.navigate(`/omnichannel/sla-policies/edit/${id}`));
59+
const onRowClick = useEffectEvent((id: string) => () => router.navigate(`/omnichannel/sla-policies/edit/${id}`));
6060

6161
const headers = (
6262
<>

apps/meteor/client/omnichannel/tags/TagsTable.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const TagsTable = () => {
2727
const { current, itemsPerPage, setItemsPerPage: onSetItemsPerPage, setCurrent: onSetCurrent, ...paginationProps } = usePagination();
2828
const { sortBy, sortDirection, setSort } = useSort<'name' | 'description'>('name');
2929

30-
const onRowClick = useEffectEvent((id) => router.navigate(`/omnichannel/tags/edit/${id}`));
30+
const onRowClick = useEffectEvent((id: string) => router.navigate(`/omnichannel/tags/edit/${id}`));
3131
const handleAddNew = useEffectEvent(() => router.navigate('/omnichannel/tags/new'));
3232
const handleDeleteTag = useRemoveTag();
3333

apps/meteor/client/omnichannel/tags/useRemoveTag.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export const useRemoveTag = () => {
1313
const queryClient = useQueryClient();
1414
const router = useRouter();
1515

16-
const handleDeleteTag = useEffectEvent((tagId) => {
16+
const handleDeleteTag = useEffectEvent((tagId: string) => {
1717
const handleDelete = async () => {
1818
try {
1919
await removeTag(tagId);

apps/meteor/client/omnichannel/units/UnitEdit.tsx

+15-2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,19 @@ import { AsyncStatePhase } from '../../hooks/useAsyncState';
3434
import { useDepartmentsByUnitsList } from '../../views/hooks/useDepartmentsByUnitsList';
3535
import { useMonitorsList } from '../../views/hooks/useMonitorsList';
3636

37+
type UnitEditFormData = {
38+
name: string;
39+
visibility: string;
40+
departments: {
41+
value: string;
42+
label: string;
43+
}[];
44+
monitors: {
45+
value: string;
46+
label: string;
47+
}[];
48+
};
49+
3750
type UnitEditProps = {
3851
unitData?: Serialized<IOmnichannelBusinessUnit>;
3952
unitMonitors?: Serialized<ILivechatUnitMonitor>[];
@@ -97,7 +110,7 @@ const UnitEdit = ({ unitData, unitMonitors, unitDepartments }: UnitEditProps) =>
97110
formState: { errors, isDirty },
98111
handleSubmit,
99112
watch,
100-
} = useForm({
113+
} = useForm<UnitEditFormData>({
101114
mode: 'onBlur',
102115
values: {
103116
name: unitData?.name || '',
@@ -127,7 +140,7 @@ const UnitEdit = ({ unitData, unitMonitors, unitDepartments }: UnitEditProps) =>
127140
return [...mappedMonitorsItems, ...pending];
128141
}, [monitors, monitorsItems]);
129142

130-
const handleSave = useEffectEvent(async ({ name, visibility }) => {
143+
const handleSave = useEffectEvent(async ({ name, visibility }: UnitEditFormData) => {
131144
const departmentsData = departments.map((department) => ({ departmentId: department.value }));
132145

133146
const monitorsData = monitors.map((monitor) => ({

apps/meteor/client/omnichannel/units/UnitsTable.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const UnitsTable = () => {
5151
const queryHasChanged = defaultQuery !== hashKey([query]);
5252

5353
const handleAddNew = useEffectEvent(() => router.navigate('/omnichannel/units/new'));
54-
const onRowClick = useEffectEvent((id) => () => router.navigate(`/omnichannel/units/edit/${id}`));
54+
const onRowClick = useEffectEvent((id: string) => () => router.navigate(`/omnichannel/units/edit/${id}`));
5555
const handleDelete = useRemoveUnit();
5656

5757
const headers = (

apps/meteor/client/omnichannel/units/useRemoveUnit.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export const useRemoveUnit = () => {
1313
const queryClient = useQueryClient();
1414
const removeUnit = useMethod('livechat:removeUnit');
1515

16-
const handleDelete = useEffectEvent((id) => {
16+
const handleDelete = useEffectEvent((id: string) => {
1717
const onDeleteAgent = async () => {
1818
try {
1919
await removeUnit(id);

apps/meteor/client/sidebar/Item/Condensed.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { IconButton, Sidebar } from '@rocket.chat/fuselage';
22
import { useEffectEvent, usePrefersReducedMotion } from '@rocket.chat/fuselage-hooks';
33
import type { Keys as IconName } from '@rocket.chat/icons';
4-
import type { ReactElement } from 'react';
4+
import type { ReactElement, UIEvent } from 'react';
55
import { memo, useState } from 'react';
66

77
type CondensedProps = {
@@ -24,8 +24,8 @@ const Condensed = ({ icon, title = '', avatar, actions, href, unread, menu, badg
2424

2525
const isReduceMotionEnabled = usePrefersReducedMotion();
2626

27-
const handleMenu = useEffectEvent((e) => {
28-
setMenuVisibility(e.target.offsetWidth > 0 && Boolean(menu));
27+
const handleMenu = useEffectEvent((e: UIEvent<HTMLElement>) => {
28+
setMenuVisibility(e.currentTarget.offsetWidth > 0 && Boolean(menu));
2929
});
3030
const handleMenuEvent = {
3131
[isReduceMotionEnabled ? 'onMouseEnter' : 'onTransitionEnd']: handleMenu,

apps/meteor/client/sidebar/Item/Extended.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Sidebar, IconButton } from '@rocket.chat/fuselage';
22
import { useEffectEvent, usePrefersReducedMotion } from '@rocket.chat/fuselage-hooks';
33
import type { Keys as IconName } from '@rocket.chat/icons';
4-
import type { ReactNode } from 'react';
4+
import type { ReactNode, UIEvent } from 'react';
55
import { memo, useState } from 'react';
66

77
import { useShortTimeAgo } from '../../hooks/useTimeAgo';
@@ -45,8 +45,8 @@ const Extended = ({
4545

4646
const isReduceMotionEnabled = usePrefersReducedMotion();
4747

48-
const handleMenu = useEffectEvent((e) => {
49-
setMenuVisibility(e.target.offsetWidth > 0 && Boolean(menu));
48+
const handleMenu = useEffectEvent((e: UIEvent<HTMLElement>) => {
49+
setMenuVisibility(e.currentTarget.offsetWidth > 0 && Boolean(menu));
5050
});
5151

5252
const handleMenuEvent = {

apps/meteor/client/sidebar/Item/Medium.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Sidebar, IconButton } from '@rocket.chat/fuselage';
22
import { useEffectEvent, usePrefersReducedMotion } from '@rocket.chat/fuselage-hooks';
3-
import type { ReactNode } from 'react';
3+
import type { ReactNode, UIEvent } from 'react';
44
import { memo, useState } from 'react';
55

66
type MediumProps = {
@@ -22,8 +22,8 @@ const Medium = ({ icon, title = '', avatar, actions, href, badges, unread, menu,
2222

2323
const isReduceMotionEnabled = usePrefersReducedMotion();
2424

25-
const handleMenu = useEffectEvent((e) => {
26-
setMenuVisibility(e.target.offsetWidth > 0 && Boolean(menu));
25+
const handleMenu = useEffectEvent((e: UIEvent<HTMLElement>) => {
26+
setMenuVisibility(e.currentTarget.offsetWidth > 0 && Boolean(menu));
2727
});
2828
const handleMenuEvent = {
2929
[isReduceMotionEnabled ? 'onMouseEnter' : 'onTransitionEnd']: handleMenu,

apps/meteor/client/sidebar/search/SearchList.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { escapeRegExp } from '@rocket.chat/string-helpers';
66
import { useUserPreference, useUserSubscriptions, useSetting, useTranslation, useMethod } from '@rocket.chat/ui-contexts';
77
import type { UseQueryResult } from '@tanstack/react-query';
88
import { useQuery } from '@tanstack/react-query';
9-
import type { ReactElement, MutableRefObject, SetStateAction, Dispatch, FormEventHandler, Ref, MouseEventHandler } from 'react';
9+
import type { ReactElement, MutableRefObject, SetStateAction, Dispatch, FormEventHandler, Ref, MouseEventHandler, FormEvent } from 'react';
1010
import { forwardRef, useState, useMemo, useEffect, useRef } from 'react';
1111
import type { VirtuosoHandle } from 'react-virtuoso';
1212
import { Virtuoso } from 'react-virtuoso';
@@ -166,7 +166,7 @@ const useSearchItems = (filterText: string): UseQueryResult<(ISubscription & IRo
166166

167167
const useInput = (initial: string): { value: string; onChange: FormEventHandler; setValue: Dispatch<SetStateAction<string>> } => {
168168
const [value, setValue] = useState(initial);
169-
const onChange = useEffectEvent((e) => {
169+
const onChange = useEffectEvent((e: FormEvent<HTMLInputElement>) => {
170170
setValue(e.currentTarget.value);
171171
});
172172
return { value, onChange, setValue };
@@ -231,7 +231,7 @@ const SearchList = forwardRef(function SearchList({ onClose }: SearchListProps,
231231
[avatarTemplate, extended, items, useRealName, sideBarItemTemplate, sidebarViewMode, t],
232232
);
233233

234-
const changeSelection = useEffectEvent((dir) => {
234+
const changeSelection = useEffectEvent((dir: 'up' | 'down') => {
235235
let nextSelectedElement = null;
236236

237237
if (dir === 'up') {

apps/meteor/client/sidebar/sections/OmnichannelSection.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const OmnichannelSection = () => {
2323
const queueListRoute = useRoute('livechat-queue');
2424
const isWorkspaceOverMacLimit = useIsOverMacLimit();
2525

26-
const handleRoute = useEffectEvent((route) => {
26+
const handleRoute = useEffectEvent((route: string) => {
2727
sidebar.toggle();
2828

2929
switch (route) {

apps/meteor/client/sidebarv2/Item/Condensed.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { IconButton, SidebarV2Item, SidebarV2ItemAvatarWrapper, SidebarV2ItemMenu, SidebarV2ItemTitle } from '@rocket.chat/fuselage';
22
import { useEffectEvent, usePrefersReducedMotion } from '@rocket.chat/fuselage-hooks';
33
import type { Keys as IconName } from '@rocket.chat/icons';
4-
import type { HTMLAttributes, ReactElement } from 'react';
4+
import type { HTMLAttributes, ReactElement, UIEvent } from 'react';
55
import { memo, useState } from 'react';
66

77
type CondensedProps = {
@@ -24,8 +24,8 @@ const Condensed = ({ icon, title, avatar, actions, unread, menu, badges, ...prop
2424

2525
const isReduceMotionEnabled = usePrefersReducedMotion();
2626

27-
const handleMenu = useEffectEvent((e) => {
28-
setMenuVisibility(e.target.offsetWidth > 0 && Boolean(menu));
27+
const handleMenu = useEffectEvent((e: UIEvent<HTMLDivElement>) => {
28+
setMenuVisibility(e.currentTarget.offsetWidth > 0 && Boolean(menu));
2929
});
3030
const handleMenuEvent = {
3131
[isReduceMotionEnabled ? 'onMouseEnter' : 'onTransitionEnd']: handleMenu,

0 commit comments

Comments
 (0)