Skip to content

Commit

Permalink
chore: Merge 4.49.0 into master (#5684)
Browse files Browse the repository at this point in the history
  • Loading branch information
diegolmello authored May 28, 2024
2 parents a4a9456 + a035211 commit 9191d47
Show file tree
Hide file tree
Showing 42 changed files with 292 additions and 430 deletions.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ android {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode VERSIONCODE as Integer
versionName "4.48.0"
versionName "4.49.0"
vectorDrawables.useSupportLibrary = true
if (!isFoss) {
manifestPlaceholders = [BugsnagAPIKey: BugsnagAPIKey as String]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@
import java.util.Arrays;
import java.util.concurrent.TimeUnit;

import com.RNFetchBlob.RNFetchBlob;

import com.reactnativecommunity.webview.RNCWebViewManager;

import com.dylanvann.fastimage.FastImageOkHttpUrlLoader;
Expand Down Expand Up @@ -104,8 +102,6 @@ public void setCertificate(String data, Promise promise) {
WebSocketModule.setCustomClientBuilder(new CustomClient());
// Image networking react-native layer
ReactOkHttpNetworkFetcher.setOkHttpClient(getOkHttpClient());
// RNFetchBlob networking layer
RNFetchBlob.applyCustomOkHttpClient(getOkHttpClient());
// RNCWebView onReceivedClientCertRequest
RNCWebViewManager.setCertificateAlias(data);
// FastImage Glide network layer
Expand Down
2 changes: 1 addition & 1 deletion app/containers/MessageComposer/hooks/useChooseMedia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export const useChooseMedia = ({
// FIXME: use useNavigation
Navigation.navigate('ShareView', {
room,
thread,
thread: thread || tmid,
attachments,
action,
finishShareView,
Expand Down
5 changes: 3 additions & 2 deletions app/containers/Toast.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ const styles = StyleSheet.create({
},
text: {
fontSize: 14,
...sharedStyles.textRegular,
...sharedStyles.textAlignCenter
// jest error: TypeError: Cannot read property 'textRegular' of undefined
...sharedStyles?.textRegular,
...sharedStyles?.textAlignCenter
}
});

Expand Down
11 changes: 11 additions & 0 deletions app/containers/message/Components/RightIcons/Pinned.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React from 'react';

import { CustomIcon } from '../../../CustomIcon';
import styles from '../../styles';

const Pinned = ({ pinned, testID }: { pinned?: boolean; testID?: string }): React.ReactElement | null => {
if (pinned) return <CustomIcon testID={testID} name='pin' size={16} style={styles.rightIcons} />;
return null;
};

export default Pinned;
18 changes: 15 additions & 3 deletions app/containers/message/Components/RightIcons/index.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import React from 'react';
import { StyleSheet, View } from 'react-native';

import Encrypted from './Encrypted';
import { MessageType } from '../../../../definitions';
import Edited from './Edited';
import Encrypted from './Encrypted';
import MessageError from './MessageError';
import Pinned from './Pinned';
import ReadReceipt from './ReadReceipt';
import Translated from './Translated';
import { MessageType } from '../../../../definitions';

const styles = StyleSheet.create({
actionIcons: {
Expand All @@ -22,10 +23,21 @@ interface IRightIcons {
unread?: boolean;
hasError: boolean;
isTranslated: boolean;
pinned?: boolean;
}

const RightIcons = ({ type, msg, isEdited, hasError, isReadReceiptEnabled, unread, isTranslated }: IRightIcons) => (
const RightIcons = ({
type,
msg,
isEdited,
hasError,
isReadReceiptEnabled,
unread,
isTranslated,
pinned
}: IRightIcons): React.ReactElement => (
<View style={styles.actionIcons}>
<Pinned pinned={pinned} testID={`${msg}-pinned`} />
<Encrypted type={type} />
<Edited testID={`${msg}-edited`} isEdited={isEdited} />
<MessageError hasError={hasError} />
Expand Down
7 changes: 7 additions & 0 deletions app/containers/message/Message.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,13 @@ export const Edited = () => (
</>
);

export const Pinned = () => (
<>
<Message msg='Message header' pinned />
<Message msg='Message without header' pinned isHeader={false} />
</>
);

export const Translated = () => (
<>
<Message msg='Message header' isTranslated />
Expand Down
1 change: 1 addition & 0 deletions app/containers/message/Message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ const Message = React.memo((props: IMessage) => {
hasError={props.hasError}
isReadReceiptEnabled={props.isReadReceiptEnabled}
unread={props.unread}
pinned={props.pinned}
isTranslated={props.isTranslated}
/>
) : null}
Expand Down
20 changes: 10 additions & 10 deletions app/containers/message/Reply.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import { dequal } from 'dequal';
import moment from 'moment';
import React, { useContext, useState } from 'react';
import { StyleSheet, Text, View } from 'react-native';
import moment from 'moment';
import { dequal } from 'dequal';
import FastImage from 'react-native-fast-image';

import Touchable from './Touchable';
import Markdown from '../markdown';
import { IAttachment, TGetCustomEmoji } from '../../definitions';
import { themes } from '../../lib/constants';
import { fileDownloadAndPreview } from '../../lib/methods/helpers';
import { formatAttachmentUrl } from '../../lib/methods/helpers/formatAttachmentUrl';
import openLink from '../../lib/methods/helpers/openLink';
import { TSupportedThemes, useTheme } from '../../theme';
import sharedStyles from '../../views/Styles';
import { themes } from '../../lib/constants';
import MessageContext from './Context';
import { fileDownloadAndPreview } from './helpers/fileDownload';
import { IAttachment, TGetCustomEmoji } from '../../definitions';
import RCActivityIndicator from '../ActivityIndicator';
import Markdown from '../markdown';
import Attachments from './Attachments';
import { TSupportedThemes, useTheme } from '../../theme';
import { formatAttachmentUrl } from '../../lib/methods/helpers/formatAttachmentUrl';
import MessageContext from './Context';
import Touchable from './Touchable';
import messageStyles from './styles';

const styles = StyleSheet.create({
Expand Down
2 changes: 2 additions & 0 deletions app/containers/message/User.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ interface IMessageUser {
isEdited: boolean;
isReadReceiptEnabled?: boolean;
unread?: boolean;
pinned?: boolean;
isTranslated: boolean;
}

Expand Down Expand Up @@ -124,6 +125,7 @@ const User = React.memo(
hasError={hasError}
isReadReceiptEnabled={props.isReadReceiptEnabled}
unread={props.unread}
pinned={props.pinned}
isTranslated={isTranslated}
/>
</View>
Expand Down
3 changes: 1 addition & 2 deletions app/containers/message/Video.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
isDownloadActive,
resumeMediaFile
} from '../../lib/methods/handleMediaDownload';
import { isIOS } from '../../lib/methods/helpers';
import { fileDownload, isIOS } from '../../lib/methods/helpers';
import EventEmitter from '../../lib/methods/helpers/events';
import { formatAttachmentUrl } from '../../lib/methods/helpers/formatAttachmentUrl';
import { useTheme } from '../../theme';
Expand All @@ -24,7 +24,6 @@ import Markdown from '../markdown';
import BlurComponent from './Components/OverlayComponent';
import MessageContext from './Context';
import Touchable from './Touchable';
import { fileDownload } from './helpers/fileDownload';
import { DEFAULT_MESSAGE_HEIGHT } from './utils';

const SUPPORTED_TYPES = ['video/quicktime', 'video/mp4', ...(isIOS ? [] : ['video/3gp', 'video/mkv'])];
Expand Down
53 changes: 0 additions & 53 deletions app/containers/message/helpers/fileDownload/index.ts

This file was deleted.

4 changes: 3 additions & 1 deletion app/containers/message/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,8 @@ class MessageContainer extends React.Component<IMessageContainerProps, IMessageC
autoTranslate: autoTranslateMessage,
replies,
md,
comment
comment,
pinned
} = item;

let message = msg;
Expand Down Expand Up @@ -485,6 +486,7 @@ class MessageContainer extends React.Component<IMessageContainerProps, IMessageC
isTranslated={isTranslated}
isBeingEdited={isBeingEdited}
isPreview={isPreview}
pinned={pinned}
/>
</MessageContext.Provider>
);
Expand Down
1 change: 1 addition & 0 deletions app/containers/message/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export interface IMessageContent {
hasError: boolean;
isHeader: boolean;
isTranslated: boolean;
pinned?: boolean;
}

export interface IMessageEmoji {
Expand Down
1 change: 0 additions & 1 deletion app/lib/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export * from './environment';
export * from './keys';
export * from './links';
export * from './localAuthentication';
export * from './localPath';
export * from './messagesStatus';
export * from './messageTypeLoad';
export * from './notifications';
Expand Down
4 changes: 0 additions & 4 deletions app/lib/constants/localPath.ts

This file was deleted.

17 changes: 8 additions & 9 deletions app/lib/methods/getServerInfo.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import RNFetchBlob from 'rn-fetch-blob';
import { settings as RocketChatSettings } from '@rocket.chat/sdk';
import { KJUR } from 'jsrsasign';
import moment from 'moment';
Expand Down Expand Up @@ -45,20 +44,20 @@ const verifyJWT = (jwt?: string): ISupportedVersionsData | null => {

export async function getServerInfo(server: string): Promise<TServerInfoResult> {
try {
const response = await RNFetchBlob.fetch('GET', `${server}/api/info`, {
const response = await fetch(`${server}/api/info`, {
...RocketChatSettings.customHeaders
});
try {
const jsonRes: IApiServerInfo = response.json();
if (!jsonRes?.success) {
const serverInfo: IApiServerInfo = await response.json();
if (!serverInfo?.success) {
return {
success: false,
message: I18n.t('Not_RC_Server', { contact: I18n.t('Contact_your_server_admin') })
};
}

// Makes use of signed JWT to get supported versions
const supportedVersions = verifyJWT(jsonRes.supportedVersions?.signed);
const supportedVersions = verifyJWT(serverInfo.supportedVersions?.signed);

// if backend doesn't have supported versions or JWT is invalid, request from cloud
if (!supportedVersions) {
Expand All @@ -69,7 +68,7 @@ export async function getServerInfo(server: string): Promise<TServerInfoResult>
moment(new Date()).diff(serverRecord?.supportedVersionsUpdatedAt, 'hours') <= SV_CLOUD_UPDATE_INTERVAL
) {
return {
...jsonRes,
...serverInfo,
success: true
};
}
Expand All @@ -79,7 +78,7 @@ export async function getServerInfo(server: string): Promise<TServerInfoResult>
// Allows airgapped servers to use the app until enforcementStartDate
if (!cloudInfo) {
return {
...jsonRes,
...serverInfo,
success: true
};
}
Expand All @@ -88,14 +87,14 @@ export async function getServerInfo(server: string): Promise<TServerInfoResult>
const supportedVersionsCloud = verifyJWT(cloudInfo?.signed);

return {
...jsonRes,
...serverInfo,
success: true,
supportedVersions: supportedVersionsCloud
};
}

return {
...jsonRes,
...serverInfo,
success: true,
supportedVersions
};
Expand Down
33 changes: 33 additions & 0 deletions app/lib/methods/helpers/fileDownload.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import * as FileSystem from 'expo-file-system';
import FileViewer from 'react-native-file-viewer';

import { LISTENER } from '../../../containers/Toast';
import { IAttachment } from '../../../definitions';
import i18n from '../../../i18n';
import EventEmitter from './events';

export const getLocalFilePathFromFile = (localPath: string, attachment: IAttachment): string => `${localPath}${attachment.title}`;

export const fileDownload = async (url: string, attachment?: IAttachment, fileName?: string): Promise<string> => {
let path = `${FileSystem.documentDirectory}`;
if (fileName) {
path = `${path}${fileName}`;
}
if (attachment) {
path = `${path}${attachment.title}`;
}
const file = await FileSystem.downloadAsync(url, path);
return file.uri;
};

export const fileDownloadAndPreview = async (url: string, attachment: IAttachment): Promise<void> => {
try {
const file = await fileDownload(url, attachment);
FileViewer.open(file, {
showOpenWithDialog: true,
showAppsSuggestions: true
});
} catch (e) {
EventEmitter.emit(LISTENER, { message: i18n.t('Error_Download_file') });
}
};
Loading

0 comments on commit 9191d47

Please sign in to comment.