Merge branch 'develop' into TC-782-Mobile-Troubleshoot-notifications
This commit is contained in:
commit
b7f2cbfc2e
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,22 @@
|
||||||
|
import React, { memo } from 'react';
|
||||||
|
import { View } from 'react-native';
|
||||||
|
|
||||||
|
import { CustomIcon } from '../../../CustomIcon';
|
||||||
|
import { useTheme } from '../../../../theme';
|
||||||
|
import styles from '../../styles';
|
||||||
|
|
||||||
|
const Translated = memo(({ isTranslated }: { isTranslated: boolean }) => {
|
||||||
|
const { colors } = useTheme();
|
||||||
|
|
||||||
|
if (!isTranslated) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<View style={styles.rightIcons}>
|
||||||
|
<CustomIcon name='language' size={16} color={colors.auxiliaryText} />
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
export default Translated;
|
|
@ -5,6 +5,7 @@ import Encrypted from './Encrypted';
|
||||||
import Edited from './Edited';
|
import Edited from './Edited';
|
||||||
import MessageError from './MessageError';
|
import MessageError from './MessageError';
|
||||||
import ReadReceipt from './ReadReceipt';
|
import ReadReceipt from './ReadReceipt';
|
||||||
|
import Translated from './Translated';
|
||||||
import { MessageType } from '../../../../definitions';
|
import { MessageType } from '../../../../definitions';
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
|
@ -20,13 +21,15 @@ interface IRightIcons {
|
||||||
isReadReceiptEnabled?: boolean;
|
isReadReceiptEnabled?: boolean;
|
||||||
unread?: boolean;
|
unread?: boolean;
|
||||||
hasError: boolean;
|
hasError: boolean;
|
||||||
|
isTranslated: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const RightIcons = ({ type, msg, isEdited, hasError, isReadReceiptEnabled, unread }: IRightIcons) => (
|
const RightIcons = ({ type, msg, isEdited, hasError, isReadReceiptEnabled, unread, isTranslated }: IRightIcons) => (
|
||||||
<View style={styles.actionIcons}>
|
<View style={styles.actionIcons}>
|
||||||
<Encrypted type={type} />
|
<Encrypted type={type} />
|
||||||
<Edited testID={`${msg}-edited`} isEdited={isEdited} />
|
<Edited testID={`${msg}-edited`} isEdited={isEdited} />
|
||||||
<MessageError hasError={hasError} />
|
<MessageError hasError={hasError} />
|
||||||
|
<Translated isTranslated={isTranslated} />
|
||||||
<ReadReceipt isReadReceiptEnabled={isReadReceiptEnabled} unread={unread} />
|
<ReadReceipt isReadReceiptEnabled={isReadReceiptEnabled} unread={unread} />
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
|
|
|
@ -127,6 +127,13 @@ export const Edited = () => (
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const Translated = () => (
|
||||||
|
<>
|
||||||
|
<Message msg='Message header' isTranslated />
|
||||||
|
<Message msg='Message without header' isTranslated isHeader={false} />
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
|
||||||
export const Encrypted = () => (
|
export const Encrypted = () => (
|
||||||
<>
|
<>
|
||||||
<Message msg='Message' type='e2e' />
|
<Message msg='Message' type='e2e' />
|
||||||
|
@ -939,6 +946,7 @@ export const LongNameUser = () => (
|
||||||
<>
|
<>
|
||||||
<Message msg={'this is a normal message'} author={longNameAuthor} />
|
<Message msg={'this is a normal message'} author={longNameAuthor} />
|
||||||
<Message msg={'Edited message'} author={longNameAuthor} isEdited />
|
<Message msg={'Edited message'} author={longNameAuthor} isEdited />
|
||||||
|
<Message msg={'Translated message'} author={longNameAuthor} isTranslated />
|
||||||
<Message msg={'Encrypted message'} author={longNameAuthor} type={E2E_MESSAGE_TYPE} />
|
<Message msg={'Encrypted message'} author={longNameAuthor} type={E2E_MESSAGE_TYPE} />
|
||||||
<Message msg={'Error message'} author={longNameAuthor} hasError />
|
<Message msg={'Error message'} author={longNameAuthor} hasError />
|
||||||
<Message msg={'Message with read receipt'} author={longNameAuthor} isReadReceiptEnabled read />
|
<Message msg={'Message with read receipt'} author={longNameAuthor} isReadReceiptEnabled read />
|
||||||
|
@ -947,6 +955,7 @@ export const LongNameUser = () => (
|
||||||
msg={'Show all icons '}
|
msg={'Show all icons '}
|
||||||
author={longNameAuthor}
|
author={longNameAuthor}
|
||||||
isEdited
|
isEdited
|
||||||
|
isTranslated
|
||||||
type={E2E_MESSAGE_TYPE}
|
type={E2E_MESSAGE_TYPE}
|
||||||
hasError
|
hasError
|
||||||
isReadReceiptEnabled
|
isReadReceiptEnabled
|
||||||
|
@ -958,6 +967,7 @@ export const LongNameUser = () => (
|
||||||
author={longNameAuthor}
|
author={longNameAuthor}
|
||||||
isHeader={false}
|
isHeader={false}
|
||||||
isEdited
|
isEdited
|
||||||
|
isTranslated
|
||||||
type={E2E_MESSAGE_TYPE}
|
type={E2E_MESSAGE_TYPE}
|
||||||
hasError
|
hasError
|
||||||
isReadReceiptEnabled
|
isReadReceiptEnabled
|
||||||
|
@ -969,6 +979,7 @@ export const LongNameUser = () => (
|
||||||
author={longNameAuthor}
|
author={longNameAuthor}
|
||||||
isHeader={false}
|
isHeader={false}
|
||||||
isEdited
|
isEdited
|
||||||
|
isTranslated
|
||||||
type={E2E_MESSAGE_TYPE}
|
type={E2E_MESSAGE_TYPE}
|
||||||
hasError
|
hasError
|
||||||
isReadReceiptEnabled
|
isReadReceiptEnabled
|
||||||
|
|
|
@ -117,6 +117,7 @@ const Message = React.memo((props: IMessage) => {
|
||||||
hasError={props.hasError}
|
hasError={props.hasError}
|
||||||
isReadReceiptEnabled={props.isReadReceiptEnabled}
|
isReadReceiptEnabled={props.isReadReceiptEnabled}
|
||||||
unread={props.unread}
|
unread={props.unread}
|
||||||
|
isTranslated={props.isTranslated}
|
||||||
/>
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
</View>
|
</View>
|
||||||
|
|
|
@ -60,10 +60,24 @@ interface IMessageUser {
|
||||||
isEdited: boolean;
|
isEdited: boolean;
|
||||||
isReadReceiptEnabled?: boolean;
|
isReadReceiptEnabled?: boolean;
|
||||||
unread?: boolean;
|
unread?: boolean;
|
||||||
|
isTranslated: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const User = React.memo(
|
const User = React.memo(
|
||||||
({ isHeader, useRealName, author, alias, ts, timeFormat, hasError, navToRoomInfo, type, isEdited, ...props }: IMessageUser) => {
|
({
|
||||||
|
isHeader,
|
||||||
|
useRealName,
|
||||||
|
author,
|
||||||
|
alias,
|
||||||
|
ts,
|
||||||
|
timeFormat,
|
||||||
|
hasError,
|
||||||
|
navToRoomInfo,
|
||||||
|
type,
|
||||||
|
isEdited,
|
||||||
|
isTranslated,
|
||||||
|
...props
|
||||||
|
}: IMessageUser) => {
|
||||||
const { user } = useContext(MessageContext);
|
const { user } = useContext(MessageContext);
|
||||||
const { colors } = useTheme();
|
const { colors } = useTheme();
|
||||||
|
|
||||||
|
@ -110,6 +124,7 @@ const User = React.memo(
|
||||||
hasError={hasError}
|
hasError={hasError}
|
||||||
isReadReceiptEnabled={props.isReadReceiptEnabled}
|
isReadReceiptEnabled={props.isReadReceiptEnabled}
|
||||||
unread={props.unread}
|
unread={props.unread}
|
||||||
|
isTranslated={isTranslated}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
import { LISTENER } from '../../../containers/Toast';
|
||||||
|
import i18n from '../../../i18n';
|
||||||
|
import EventEmitter from './events';
|
||||||
|
import log from './log';
|
||||||
|
|
||||||
|
export const emitErrorCreateDirectMessage = (e: any): void => {
|
||||||
|
if (e?.errorType === 'error-not-allowed') {
|
||||||
|
if (e?.details?.method === 'createDirectMessage')
|
||||||
|
EventEmitter.emit(LISTENER, {
|
||||||
|
message: i18n.t('error-action-not-allowed', { action: i18n.t('Create_Direct_Messages') })
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
log(e);
|
||||||
|
}
|
||||||
|
};
|
|
@ -4,6 +4,7 @@ import Navigation from '../../navigation/appNavigation';
|
||||||
import { IOmnichannelRoom, SubscriptionType, IVisitor, TSubscriptionModel, ISubscription } from '../../../definitions';
|
import { IOmnichannelRoom, SubscriptionType, IVisitor, TSubscriptionModel, ISubscription } from '../../../definitions';
|
||||||
import { getRoomTitle, getUidDirectMessage } from './helpers';
|
import { getRoomTitle, getUidDirectMessage } from './helpers';
|
||||||
import { Services } from '../../services';
|
import { Services } from '../../services';
|
||||||
|
import { emitErrorCreateDirectMessage } from './emitErrorCreateDirectMessage';
|
||||||
|
|
||||||
interface IGoRoomItem {
|
interface IGoRoomItem {
|
||||||
search?: boolean; // comes from spotlight
|
search?: boolean; // comes from spotlight
|
||||||
|
@ -111,8 +112,8 @@ export const goRoom = async ({
|
||||||
...props
|
...props
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} catch {
|
} catch (e: any) {
|
||||||
// Do nothing
|
emitErrorCreateDirectMessage(e?.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,13 +10,11 @@ import UAParser from 'ua-parser-js';
|
||||||
import * as HeaderButton from '../../containers/HeaderButton';
|
import * as HeaderButton from '../../containers/HeaderButton';
|
||||||
import SafeAreaView from '../../containers/SafeAreaView';
|
import SafeAreaView from '../../containers/SafeAreaView';
|
||||||
import StatusBar from '../../containers/StatusBar';
|
import StatusBar from '../../containers/StatusBar';
|
||||||
import { LISTENER } from '../../containers/Toast';
|
|
||||||
import { ISubscription, IUser, SubscriptionType } from '../../definitions';
|
import { ISubscription, IUser, SubscriptionType } from '../../definitions';
|
||||||
import I18n from '../../i18n';
|
import I18n from '../../i18n';
|
||||||
import { getSubscriptionByRoomId } from '../../lib/database/services/Subscription';
|
import { getSubscriptionByRoomId } from '../../lib/database/services/Subscription';
|
||||||
import { useAppSelector } from '../../lib/hooks';
|
import { useAppSelector } from '../../lib/hooks';
|
||||||
import { getRoomTitle, getUidDirectMessage, hasPermission } from '../../lib/methods/helpers';
|
import { getRoomTitle, getUidDirectMessage, hasPermission } from '../../lib/methods/helpers';
|
||||||
import EventEmitter from '../../lib/methods/helpers/events';
|
|
||||||
import { goRoom } from '../../lib/methods/helpers/goRoom';
|
import { goRoom } from '../../lib/methods/helpers/goRoom';
|
||||||
import { handleIgnore } from '../../lib/methods/helpers/handleIgnore';
|
import { handleIgnore } from '../../lib/methods/helpers/handleIgnore';
|
||||||
import log, { events, logEvent } from '../../lib/methods/helpers/log';
|
import log, { events, logEvent } from '../../lib/methods/helpers/log';
|
||||||
|
@ -29,6 +27,7 @@ import RoomInfoViewAvatar from './components/RoomInfoViewAvatar';
|
||||||
import RoomInfoViewBody from './components/RoomInfoViewBody';
|
import RoomInfoViewBody from './components/RoomInfoViewBody';
|
||||||
import RoomInfoViewTitle from './components/RoomInfoViewTitle';
|
import RoomInfoViewTitle from './components/RoomInfoViewTitle';
|
||||||
import styles from './styles';
|
import styles from './styles';
|
||||||
|
import { emitErrorCreateDirectMessage } from '../../lib/methods/helpers/emitErrorCreateDirectMessage';
|
||||||
|
|
||||||
type TRoomInfoViewNavigationProp = CompositeNavigationProp<
|
type TRoomInfoViewNavigationProp = CompositeNavigationProp<
|
||||||
StackNavigationProp<ChatsStackParamList, 'RoomInfoView'>,
|
StackNavigationProp<ChatsStackParamList, 'RoomInfoView'>,
|
||||||
|
@ -215,8 +214,8 @@ const RoomInfoView = (): React.ReactElement => {
|
||||||
try {
|
try {
|
||||||
const result = await Services.createDirectMessage(roomUser.username);
|
const result = await Services.createDirectMessage(roomUser.username);
|
||||||
if (result.success) return resolve({ ...roomUser, rid: result.room.rid });
|
if (result.success) return resolve({ ...roomUser, rid: result.room.rid });
|
||||||
} catch {
|
} catch (e) {
|
||||||
reject();
|
reject(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -251,10 +250,8 @@ const RoomInfoView = (): React.ReactElement => {
|
||||||
if (direct) r = direct;
|
if (direct) r = direct;
|
||||||
}
|
}
|
||||||
handleGoRoom(r);
|
handleGoRoom(r);
|
||||||
} catch {
|
} catch (e: any) {
|
||||||
EventEmitter.emit(LISTENER, {
|
emitErrorCreateDirectMessage(e?.data);
|
||||||
message: I18n.t('error-action-not-allowed', { action: I18n.t('Create_Direct_Messages') })
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ import appNavigation from '../../lib/navigation/appNavigation';
|
||||||
import { Services } from '../../lib/services';
|
import { Services } from '../../lib/services';
|
||||||
import database from '../../lib/database';
|
import database from '../../lib/database';
|
||||||
import { RoomTypes } from '../../lib/methods';
|
import { RoomTypes } from '../../lib/methods';
|
||||||
|
import { emitErrorCreateDirectMessage } from '../../lib/methods/helpers/emitErrorCreateDirectMessage';
|
||||||
|
|
||||||
export type TRoomType = SubscriptionType.CHANNEL | SubscriptionType.GROUP | SubscriptionType.OMNICHANNEL;
|
export type TRoomType = SubscriptionType.CHANNEL | SubscriptionType.GROUP | SubscriptionType.OMNICHANNEL;
|
||||||
|
|
||||||
|
@ -89,8 +90,8 @@ export const navToDirectMessage = async (item: IUser, isMasterDetail: boolean):
|
||||||
handleGoRoom({ rid: result.room?._id as string, name: item.username, t: SubscriptionType.DIRECT }, isMasterDetail);
|
handleGoRoom({ rid: result.room?._id as string, name: item.username, t: SubscriptionType.DIRECT }, isMasterDetail);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e: any) {
|
||||||
log(e);
|
emitErrorCreateDirectMessage(e?.data);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue