Skip to content
Open
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
2 changes: 1 addition & 1 deletion CONTEXT.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ Subscription fields: **Unread** (count; _avoid_ Badge count), **User Mentions**
## Flagged ambiguities

- **Server**: legacy name for Workspace, still in code (`server`, `serversHistory`, `selectServer`). Use Workspace in prose, new names, and copy; renaming is a migration. "Server" as the remote side (_server response_, _server clock_) stays valid.
- **Room types `'e2e'` and `'thread'`** in the `SubscriptionType` enum are FIXME-marked flags, not room types.
- **Room type** (`RoomType`) is only `'c'`, `'p'`, `'d'` or `'l'`. A Thread is not a room type: a RoomView with `tmid` is a Thread and carries its parent Room's type.
- **Account**: means a User, which authenticates on a Workspace.
- **Channel** strictly means type `'c'`.
- **History**: Workspace History vs Room History.
Expand Down
16 changes: 9 additions & 7 deletions app/actions/room.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { type Action } from 'redux';

import { type ERoomType, type RoomType } from '../definitions';
import { type RoomType } from '../definitions';
import { ROOM } from './actionsTypes';

// TYPE RETURN RELATED
Expand All @@ -22,14 +22,16 @@ type TUnsubscribeRoom = IBaseReturn;

type TRoom = Record<string, any>;

export type TRoomRemovalScope = 'room' | 'team';

interface ILeaveRoom extends Action {
roomType: ERoomType;
scope: TRoomRemovalScope;
room: TRoom;
selected?: ISelected;
}

interface IDeleteRoom extends Action {
roomType: ERoomType;
scope: TRoomRemovalScope;
room: TRoom;
selected?: ISelected;
}
Expand Down Expand Up @@ -92,20 +94,20 @@ export function unsubscribeRoom(rid: string): TUnsubscribeRoom {
};
}

export function leaveRoom(roomType: ERoomType, room: TRoom, selected?: ISelected): ILeaveRoom {
export function leaveRoom(scope: TRoomRemovalScope, room: TRoom, selected?: ISelected): ILeaveRoom {
return {
type: ROOM.LEAVE,
room,
roomType,
scope,
selected
};
}

export function deleteRoom(roomType: ERoomType, room: TRoom, selected?: ISelected): IDeleteRoom {
export function deleteRoom(scope: TRoomRemovalScope, room: TRoom, selected?: ISelected): IDeleteRoom {
return {
type: ROOM.DELETE,
room,
roomType,
scope,
selected
};
}
Expand Down
4 changes: 2 additions & 2 deletions app/containers/Avatar/Avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { settings as RocketChatSettings } from '@rocket.chat/sdk';
import Emoji from '../markdown/components/emoji/Emoji';
import { getAvatarURL } from '~/lib/methods/helpers/getAvatarUrl';
import { headers } from '~/lib/methods/helpers/fetch';
import { SubscriptionType } from '~/definitions';
import { RoomType } from '~/definitions';
import { type IAvatar } from './interfaces';
import I18n from '~/i18n';
import Touch from '../Touch';
Expand All @@ -30,7 +30,7 @@ const Avatar = memo(
text,
size = 25,
borderRadius = AVATAR_BORDER_RADIUS,
type = SubscriptionType.DIRECT,
type = RoomType.DIRECT,
avatarExternalProviderUrl,
roomAvatarExternalProviderUrl,
cdnPrefix,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useDispatch } from 'react-redux';
import { A11y } from 'react-native-a11y-order';

import { acceptCall, cancelCall } from '~/actions/videoConf';
import { type ISubscription, type SubscriptionType } from '~/definitions';
import { type ISubscription, type RoomType } from '~/definitions';
import i18n from '~/i18n';
import { useMasterDetail } from '~/lib/hooks/useMasterDetail';
import { useEndpointData } from '~/lib/hooks/useEndpointData';
Expand All @@ -22,7 +22,7 @@ export interface INotifierComponent {
text: string;
payload: {
sender: { username: string };
type: SubscriptionType;
type: RoomType;
} & Pick<ISubscription, '_id' | 'name' | 'rid' | 'prid'>;
title: string;
avatar: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { type ReactNode } from 'react';
import { ThemeContext, type TSupportedThemes } from '~/theme';
import { themes } from '~/lib/constants/colors';
import NotifierComponent from './NotifierComponent';
import { SubscriptionType } from '~/definitions';
import { RoomType } from '~/definitions';
import {
BASE_ROW_HEIGHT,
BASE_ROW_HEIGHT_CONDENSED,
Expand All @@ -27,7 +27,7 @@ const baseNotification = {
rid: 'rid-1',
name: 'general',
sender: { username: 'rocket.cat' },
type: SubscriptionType.CHANNEL
type: RoomType.CHANNEL
},
title: 'general',
avatar: 'rocket.cat'
Expand All @@ -50,7 +50,7 @@ export const DirectMessage = () => (
...baseNotification,
payload: {
...baseNotification.payload,
type: SubscriptionType.DIRECT,
type: RoomType.DIRECT,
sender: { username: 'diego.mello' }
},
title: 'diego.mello',
Expand Down
4 changes: 2 additions & 2 deletions app/containers/InAppNotification/NotifierComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import sharedStyles from '~/views/Styles';
import { themes } from '~/lib/constants/colors';
import { useTheme } from '~/theme';
import { goRoom } from '~/lib/methods/helpers/goRoom';
import { type ISubscription, type SubscriptionType } from '~/definitions';
import { type ISubscription, type RoomType } from '~/definitions';
import { hideNotification } from '~/lib/methods/helpers/notifications';
import { useResponsiveLayout } from '~/lib/hooks/useResponsiveLayout/useResponsiveLayout';
import { withMasterDetail } from '~/lib/hooks/useMasterDetail';
Expand All @@ -19,7 +19,7 @@ export interface INotifierComponent {
text: string;
payload: {
sender: { username: string };
type: SubscriptionType;
type: RoomType;
message?: { message?: string; msg?: string; t?: string };
} & Pick<ISubscription, '_id' | 'name' | 'rid' | 'prid'>;
title: string;
Expand Down
4 changes: 2 additions & 2 deletions app/containers/RoomItem/__tests__/Touchable.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { makeMutable } from 'react-native-reanimated';

import Touchable from '../Touchable';
import { settleSwipeRow, unregisterOpenSwipeItem } from '../utils/openSwipeItem';
import { SubscriptionType } from '~/definitions';
import { RoomType } from '~/definitions';

jest.mock('~/lib/hooks/useAppSelector', () => ({ useAppSelector: () => '7.0.0' }));
jest.mock('react-native-gesture-handler', () => {
Expand All @@ -18,7 +18,7 @@ const setup = ({ swipeEnabled = true } = {}) => {
const onPress = jest.fn();
const { getByText } = render(
<Touchable
type={SubscriptionType.CHANNEL}
type={RoomType.CHANNEL}
onPress={onPress}
width={300}
favorite={false}
Expand Down
4 changes: 2 additions & 2 deletions app/containers/RoomItem/getRoomActionsOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { toggleFav } from '~/lib/methods/toggleFav';
import { toggleRead } from '~/lib/methods/toggleRead';
import { hideRoom } from '~/lib/methods/hideRoom';
import { type TActionSheetOptionsItem } from '../ActionSheet';
import { type SubscriptionType } from '~/definitions';
import { type RoomType } from '~/definitions';

export interface IRoomActionsParams {
rid: string;
type: SubscriptionType;
type: RoomType;
isRead: boolean;
favorite: boolean;
serverVersion: string;
Expand Down
16 changes: 5 additions & 11 deletions app/containers/RoomItem/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,7 @@ import { type SharedValue } from 'react-native-reanimated';
import { type ReactElement } from 'react';

import { type TSupportedThemes } from '~/theme';
import {
type TUserStatus,
type ILastMessage,
type SubscriptionType,
type IOmnichannelSource,
type ISubscription
} from '~/definitions';
import { type TUserStatus, type ILastMessage, type RoomType, type IOmnichannelSource, type ISubscription } from '~/definitions';

export interface ILeftActionsProps {
transX: SharedValue<number>;
Expand Down Expand Up @@ -66,7 +60,7 @@ export interface ITypeIconProps {
interface IRoomItemTouchables {
toggleFav?: (rid: string, favorite: boolean) => Promise<void>;
toggleRead?: (rid: string, tIsRead: boolean) => Promise<void>;
hideChannel?: (rid: string, type: SubscriptionType) => Promise<void>;
hideChannel?: (rid: string, type: RoomType) => Promise<void>;
onPress: (item?: any) => void;
onLongPress?: (item?: any) => void;
onMoveToCategoryPress?: () => void;
Expand Down Expand Up @@ -96,7 +90,7 @@ export interface IRoomItemContainerProps extends IBaseRoomItem {

export interface IRoomItemProps extends IBaseRoomItem {
rid: string;
type: SubscriptionType;
type: RoomType;
prid: string;
name: string;
avatar: string;
Expand Down Expand Up @@ -126,15 +120,15 @@ export interface IRoomItemProps extends IBaseRoomItem {

export interface ILastMessageProps {
lastMessage: ILastMessage;
type: SubscriptionType;
type: RoomType;
showLastMessage: boolean;
username: string;
useRealName: boolean;
}

export interface ITouchableProps extends IRoomItemTouchables {
children: ReactElement;
type: SubscriptionType;
type: RoomType;
width: number;
favorite: boolean;
isRead: boolean;
Expand Down
4 changes: 2 additions & 2 deletions app/containers/message/components/MessageAvatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { View } from 'react-native';
import Avatar from '~/containers/Avatar';
import styles from '../styles';
import { type IMessageAvatar } from '../interfaces';
import { SubscriptionType } from '~/definitions';
import { RoomType } from '~/definitions';
import { useResponsiveLayout } from '~/lib/hooks/useResponsiveLayout/useResponsiveLayout';
import { useAvatar, useMessageField, useMessageGrouping } from '../stores/MessageStore';
import { useMessageUser, useNavToRoomInfo } from '../stores/MessageRoomStore';
Expand All @@ -31,7 +31,7 @@ const MessageAvatar = ({ small }: IMessageAvatar) => {
if (isHeader && author) {
const onPress = () =>
navToRoomInfo?.({
t: SubscriptionType.DIRECT,
t: RoomType.DIRECT,
rid: author._id,
itsMe: author._id === user?.id
});
Expand Down
4 changes: 2 additions & 2 deletions app/containers/message/components/User.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Pressable, StyleSheet, Text, View } from 'react-native';

import { type MessageTypesValues, SubscriptionType } from '~/definitions';
import { type MessageTypesValues, RoomType } from '~/definitions';
import { useTheme } from '~/theme';
import sharedStyles from '~/views/Styles';
import RightIcons from './RightIcons';
Expand Down Expand Up @@ -56,7 +56,7 @@ const User = () => {

const onUserPress = () => {
navToRoomInfo?.({
t: SubscriptionType.DIRECT,
t: RoomType.DIRECT,
rid: author?._id || '',
itsMe
});
Expand Down
7 changes: 0 additions & 7 deletions app/definitions/ERoomType.ts

This file was deleted.

18 changes: 12 additions & 6 deletions app/definitions/IRoom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type Model from '@nozbe/watermelondb/Model';
import { type IMessage } from './IMessage';
import { type IRocketChatRecord } from './IRocketChatRecord';
import { type IServedBy } from './IServedBy';
import { type ISubscription, type IVisitor, type SubscriptionType } from './ISubscription';
import { type ISubscription, type IVisitor } from './ISubscription';
import { type IUser, type TNotifications } from './IUser';

interface IRequestTranscript {
Expand All @@ -19,7 +19,7 @@ export interface IRoomInfoParam {
room?: ISubscription;
member?: any;
rid: string;
t: SubscriptionType;
t: RoomType;
joined?: boolean;
itsMe?: boolean;
}
Expand All @@ -30,7 +30,7 @@ export interface IRoom {
id: string;
rid: string;
prid: string;
t: SubscriptionType;
t: RoomType;
name: string;
teamMain: boolean;
alert?: boolean;
Expand Down Expand Up @@ -79,7 +79,7 @@ export interface IRoomSettings {
roomDescription?: string;
roomTopic?: string;
roomAnnouncement?: string;
roomType?: SubscriptionType;
roomType?: RoomType;
readOnly?: boolean;
reactWhenReadOnly?: boolean;
systemMessages?: string[];
Expand Down Expand Up @@ -116,7 +116,7 @@ export interface IOmnichannelSource {
export interface IOmnichannelRoom extends Partial<Omit<IRoom, 'default' | 'featured' | 'broadcast'>> {
_id: string;
rid: string;
t: SubscriptionType.OMNICHANNEL;
t: 'l';
v: IVisitor;
email?: {
// Data used when the room is created from an email, via email Integration.
Expand Down Expand Up @@ -153,7 +153,13 @@ export interface IOmnichannelRoom extends Partial<Omit<IRoom, 'default' | 'featu

export type TRoomModel = IRoom & Model;

export type RoomType = 'c' | 'd' | 'p' | 'l';
export const RoomType = {
CHANNEL: 'c',
GROUP: 'p',
DIRECT: 'd',
OMNICHANNEL: 'l'
} as const;
export type RoomType = (typeof RoomType)[keyof typeof RoomType];
export type RoomID = string;
export type ChannelName = string;

Expand Down
17 changes: 1 addition & 16 deletions app/definitions/ISubscription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,6 @@ import { type TThreadMessageModel } from './IThreadMessage';
import { type TUploadModel } from './IUpload';
import { type IUser } from './IUser';

export enum SubscriptionType {
GROUP = 'p',
DIRECT = 'd',
CHANNEL = 'c',
OMNICHANNEL = 'l',
E2E = 'e2e', // FIXME: this is not a type of subscription
THREAD = 'thread' // FIXME: this is not a type of subscription
}

export interface IVisitor {
_id?: string;
token?: string;
Expand All @@ -27,12 +18,6 @@ export interface IVisitor {
lastMessageTs?: Date;
}

export enum ERoomTypes {
DIRECT = 'direct',
GROUP = 'group',
CHANNEL = 'channel'
}

type RelationModified<T extends Model> = { fetch(): Promise<T[]> } & Relation<T>;

type OldKey = { e2eKeyId: string; ts: Date; E2EKey: string };
Expand All @@ -43,7 +28,7 @@ export interface ISubscription {
_updatedAt?: string;
v?: IVisitor;
f: boolean;
t: SubscriptionType; // TODO: we need to review this type later
t: RoomType;
ts: string | Date;
ls: Date;
name: string;
Expand Down
5 changes: 4 additions & 1 deletion app/definitions/TRoom.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import { type ILastMessage } from './IMessage';
import { type RoomType } from './IRoom';
import { type IVisitor, type TSubscriptionModel } from './ISubscription';

export type TPreviewRoom = {
rid: string;
t: string;
t: RoomType;
name?: string;
fname?: string;
prid?: string;
uids?: string[];
usernames?: string[];
visitor?: IVisitor;
joinCodeRequired?: boolean;
lastMessage?: ILastMessage;
Expand Down
1 change: 0 additions & 1 deletion app/definitions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { type NativeStackNavigationProp } from '@react-navigation/native-stack';
import { type TNavigation } from '../stacks/stackType';
import { type TColors, type TSupportedThemes } from '../theme';

export * from './ERoomType';
export * from './IAttachment';
export * from './IBiometricTrustStore';
export * from './ICannedResponse';
Expand Down
Loading
Loading