Skip to content

Commit

Permalink
Merge branch 'develop' into fix/videoconf-ringer-fails-after-logout
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored Nov 27, 2024
2 parents 43920ea + 3afcb8d commit f9d20ba
Show file tree
Hide file tree
Showing 46 changed files with 1,234 additions and 1,269 deletions.
5 changes: 5 additions & 0 deletions .changeset/lucky-mirrors-tickle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/meteor': patch
---

Fixes an issue where premium settings were using the wrong `Tag` variant in Omnichannel Appearance configuration
5 changes: 5 additions & 0 deletions .changeset/strange-bulldogs-roll.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/meteor': patch
---

Sorts the list of language options by name correctly
925 changes: 0 additions & 925 deletions .yarn/releases/yarn-4.5.0.cjs

This file was deleted.

934 changes: 934 additions & 0 deletions .yarn/releases/yarn-4.5.3.cjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ plugins:
- path: .yarn/plugins/@yarnpkg/plugin-engines.cjs
spec: "https://raw.githubusercontent.com/devoto13/yarn-plugin-engines/main/bundles/%40yarnpkg/plugin-engines.js"

yarnPath: .yarn/releases/yarn-4.5.0.cjs
yarnPath: .yarn/releases/yarn-4.5.3.cjs
15 changes: 3 additions & 12 deletions apps/meteor/app/api/server/definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,7 @@ export type PartialThis = {
readonly logger: Logger;
};

export type UserInfo = IUser & {
email?: string;
settings: {
profile: object;
preferences: unknown;
};
avatarUrl: string;
};

export type ActionThis<TMethod extends Method, TPathPattern extends PathPattern, TOptions> = {
type ActionThis<TMethod extends Method, TPathPattern extends PathPattern, TOptions> = {
readonly requestIp: string;
urlParams: UrlParams<TPathPattern>;
readonly response: Response;
Expand Down Expand Up @@ -186,11 +177,11 @@ export type ResultFor<TMethod extends Method, TPathPattern extends PathPattern>
body: unknown;
};

export type Action<TMethod extends Method, TPathPattern extends PathPattern, TOptions> =
type Action<TMethod extends Method, TPathPattern extends PathPattern, TOptions> =
| ((this: ActionThis<TMethod, TPathPattern, TOptions>) => Promise<ResultFor<TMethod, TPathPattern>>)
| ((this: ActionThis<TMethod, TPathPattern, TOptions>) => ResultFor<TMethod, TPathPattern>);

export type Operation<TMethod extends Method, TPathPattern extends PathPattern, TEndpointOptions> =
type Operation<TMethod extends Method, TPathPattern extends PathPattern, TEndpointOptions> =
| Action<TMethod, TPathPattern, TEndpointOptions>
| ({
action: Action<TMethod, TPathPattern, TEndpointOptions>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,6 @@ export type UserConverterOptions = {
enableEmail2fa?: boolean;
};

export type ConvertUsersResult = {
inserted: string[];
updated: string[];
skipped: number;
failed: number;
};

export class UserConverter extends RecordConverter<IImportUserRecord, UserConverterOptions & RecordConverterOptions> {
private insertedIds = new Set<IUser['_id']>();

Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/app/livechat/server/lib/localTypes.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { IOmnichannelRoom, IUser, ILivechatVisitor, IMessage, MessageAttachment, IMessageInbox } from '@rocket.chat/core-typings';

export type GenericCloseRoomParams = {
type GenericCloseRoomParams = {
room: IOmnichannelRoom;
comment?: string;
options?: {
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/app/push/server/push.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const ajv = new Ajv({
coerceTypes: true,
});

export type FCMCredentials = {
type FCMCredentials = {
type: string;
project_id: string;
private_key_id: string;
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/app/statistics/server/lib/getAppsStatistics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import mem from 'mem';
import { SystemLogger } from '../../../../server/lib/logger/system';
import { Info } from '../../../utils/rocketchat.info';

export type AppsStatistics = {
type AppsStatistics = {
engineVersion: string;
totalInstalled: number | false;
totalActive: number | false;
Expand Down
16 changes: 0 additions & 16 deletions apps/meteor/client/apps/@types/IOrchestrator.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,5 @@
import type { ISetting } from '@rocket.chat/apps-engine/definition/settings/ISetting';

interface ILanguageInfo {
Params: string;
Description: string;
Setting_Name: string;
Setting_Description: string;
}

interface ILanguages {
[key: string]: ILanguageInfo;
}

export interface IAppLanguage {
id: string;
languages: ILanguages;
}

export interface IAppExternalURL {
url: string;
}
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/client/contexts/ImageGalleryContext.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createContext } from 'react';

export type ImageGalleryContextValue = {
type ImageGalleryContextValue = {
imageId: string;
isOpen: boolean;
onClose: () => void;
Expand Down
95 changes: 95 additions & 0 deletions apps/meteor/client/hooks/useHideRoomAction.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
import type { RoomType } from '@rocket.chat/core-typings';
import { useEffectEvent } from '@rocket.chat/fuselage-hooks';
import type { TranslationKey } from '@rocket.chat/ui-contexts';
import { useEndpoint, useSetModal, useToastMessageDispatch, useRouter, useUserId } from '@rocket.chat/ui-contexts';
import { useMutation } from '@tanstack/react-query';
import React from 'react';
import { useTranslation } from 'react-i18next';

import { useDontAskAgain } from './useDontAskAgain';
import { UiTextContext } from '../../definition/IRoomTypeConfig';
import { GenericModalDoNotAskAgain } from '../components/GenericModal';
import { updateSubscription } from '../lib/mutationEffects/updateSubscription';
import { roomCoordinator } from '../lib/rooms/roomCoordinator';

type HideRoomProps = {
rid: string;
type: RoomType;
name: string;
};

type HideRoomOptions = {
redirect?: boolean;
};

const CLOSE_ENDPOINTS_BY_ROOM_TYPE = {
p: '/v1/groups.close', // private
c: '/v1/channels.close', // channel
d: '/v1/im.close', // direct message
v: '/v1/channels.close', // omnichannel voip
l: '/v1/channels.close', // livechat
} as const;

export const useHideRoomAction = ({ rid: roomId, type, name }: HideRoomProps, { redirect = true }: HideRoomOptions = {}) => {
const { t } = useTranslation();
const setModal = useSetModal();
const closeModal = useEffectEvent(() => setModal());
const dispatchToastMessage = useToastMessageDispatch();
const dontAskHideRoom = useDontAskAgain('hideRoom');
const router = useRouter();
const userId = useUserId();

const hideRoomEndpoint = useEndpoint('POST', CLOSE_ENDPOINTS_BY_ROOM_TYPE[type]);

const hideRoom = useMutation({
mutationFn: () => hideRoomEndpoint({ roomId }),
onMutate: async () => {
closeModal();

if (userId) {
return updateSubscription(roomId, userId, { alert: false, open: false });
}
},
onSuccess: () => {
if (redirect) {
router.navigate('/home');
}
},
onError: async (error, _, rollbackDocument) => {
dispatchToastMessage({ type: 'error', message: error });

if (userId && rollbackDocument) {
const { alert, open } = rollbackDocument;
updateSubscription(roomId, userId, { alert, open });
}
},
});

const handleHide = useEffectEvent(async () => {
const warnText = roomCoordinator.getRoomDirectives(type).getUiText(UiTextContext.HIDE_WARNING);

if (dontAskHideRoom) {
hideRoom.mutate();
return;
}

setModal(
<GenericModalDoNotAskAgain
variant='danger'
confirmText={t('Yes_hide_it')}
cancelText={t('Cancel')}
onClose={closeModal}
onCancel={closeModal}
onConfirm={() => hideRoom.mutate()}
dontAskAgain={{
action: 'hideRoom',
label: t('Hide_room'),
}}
>
{t(warnText as TranslationKey, { postProcess: 'sprintf', sprintf: [name] })}
</GenericModalDoNotAskAgain>,
);
});

return handleHide;
};
2 changes: 0 additions & 2 deletions apps/meteor/client/lib/cachedCollections/CachedCollection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ import { isTruthy } from '../../../lib/isTruthy';
import { withDebouncing } from '../../../lib/utils/highOrderFunctions';
import { getConfig } from '../utils/getConfig';

export type EventType = 'notify-logged' | 'notify-all' | 'notify-user';

type Name = 'rooms' | 'subscriptions' | 'permissions' | 'public-settings' | 'private-settings';

const hasId = <T>(record: T): record is T & { _id: string } => typeof record === 'object' && record !== null && '_id' in record;
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/client/lib/minimongo/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export type FieldExpression<T> = {
$comment?: string;
};

export type Flatten<T> = T extends unknown[] ? T[0] : T;
type Flatten<T> = T extends unknown[] ? T[0] : T;

export type Query<T> = {
[P in keyof T]?: Flatten<T[P]> | RegExp | FieldExpression<Flatten<T[P]>>;
Expand Down
11 changes: 11 additions & 0 deletions apps/meteor/client/lib/mutationEffects/updateSubscription.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import type { ISubscription } from '@rocket.chat/core-typings';

import { Subscriptions } from '../../../app/models/client';

export const updateSubscription = (roomId: string, userId: string, data: Partial<ISubscription>) => {
const oldDocument = Subscriptions.findOne({ 'rid': roomId, 'u._id': userId });

Subscriptions.update({ 'rid': roomId, 'u._id': userId }, { $set: data });

return oldDocument;
};
25 changes: 0 additions & 25 deletions apps/meteor/client/methods/hideRoom.ts

This file was deleted.

1 change: 0 additions & 1 deletion apps/meteor/client/methods/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import './hideRoom';
import './openRoom';
import './pinMessage';
import './unpinMessage';
Expand Down
14 changes: 8 additions & 6 deletions apps/meteor/client/providers/TranslationProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,14 @@ const TranslationProvider = ({ children }: TranslationProviderProps): ReactEleme
ogName: i18nextInstance.t('Default'),
key: '',
},
...[...new Set([...i18nextInstance.languages, ...languages])].map((key) => ({
en: key,
name: getLanguageName(key, language),
ogName: getLanguageName(key, key),
key,
})),
...[...new Set([...i18nextInstance.languages, ...languages])]
.map((key) => ({
en: key,
name: getLanguageName(key, language),
ogName: getLanguageName(key, key),
key,
}))
.sort(({ name: nameA }, { name: nameB }) => nameA.localeCompare(nameB)),
],
[language, i18nextInstance],
);
Expand Down
51 changes: 3 additions & 48 deletions apps/meteor/client/sidebar/RoomMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ import React, { memo, useMemo } from 'react';

import { LegacyRoomManager } from '../../app/ui-utils/client';
import { UiTextContext } from '../../definition/IRoomTypeConfig';
import { GenericModalDoNotAskAgain } from '../components/GenericModal';
import WarningModal from '../components/WarningModal';
import { useDontAskAgain } from '../hooks/useDontAskAgain';
import { useHideRoomAction } from '../hooks/useHideRoomAction';
import { roomCoordinator } from '../lib/rooms/roomCoordinator';
import { useOmnichannelPrioritiesMenu } from '../omnichannel/hooks/useOmnichannelPrioritiesMenu';

Expand All @@ -43,15 +42,6 @@ type RoomMenuProps = {
hideDefaultOptions: boolean;
};

const closeEndpoints = {
p: '/v1/groups.close',
c: '/v1/channels.close',
d: '/v1/im.close',

v: '/v1/channels.close',
l: '/v1/groups.close',
} as const;

const leaveEndpoints = {
p: '/v1/groups.leave',
c: '/v1/channels.leave',
Expand Down Expand Up @@ -84,9 +74,6 @@ const RoomMenu = ({
const canFavorite = useSetting('Favorite_Rooms');
const isFavorite = Boolean(subscription?.f);

const dontAskHideRoom = useDontAskAgain('hideRoom');

const hideRoom = useEndpoint('POST', closeEndpoints[type]);
const readMessages = useEndpoint('POST', '/v1/subscriptions.read');
const toggleFavorite = useEndpoint('POST', '/v1/rooms.favorite');
const leaveRoom = useEndpoint('POST', leaveEndpoints[type]);
Expand All @@ -103,6 +90,8 @@ const RoomMenu = ({

const queryClient = useQueryClient();

const handleHide = useHideRoomAction({ rid, type, name }, { redirect: false });

const canLeave = ((): boolean => {
if (type === 'c' && !canLeaveChannel) {
return false;
Expand Down Expand Up @@ -140,40 +129,6 @@ const RoomMenu = ({
);
});

const handleHide = useMutableCallback(async () => {
const hide = async (): Promise<void> => {
try {
await hideRoom({ roomId: rid });
} catch (error) {
dispatchToastMessage({ type: 'error', message: error });
}
closeModal();
};

const warnText = roomCoordinator.getRoomDirectives(type).getUiText(UiTextContext.HIDE_WARNING);

if (dontAskHideRoom) {
return hide();
}

setModal(
<GenericModalDoNotAskAgain
variant='danger'
confirmText={t('Yes_hide_it')}
cancelText={t('Cancel')}
onClose={closeModal}
onCancel={closeModal}
onConfirm={hide}
dontAskAgain={{
action: 'hideRoom',
label: t('Hide_room'),
}}
>
{t(warnText as TranslationKey, name)}
</GenericModalDoNotAskAgain>,
);
});

const handleToggleRead = useMutableCallback(async () => {
try {
queryClient.invalidateQueries(['sidebar/search/spotlight']);
Expand Down
Loading

0 comments on commit f9d20ba

Please sign in to comment.