Skip to content

Commit

Permalink
chore: Merge 4.54.1 into master (#5970)
Browse files Browse the repository at this point in the history
  • Loading branch information
diegolmello authored Nov 11, 2024
2 parents 006ecf1 + bab3de5 commit ae9875d
Show file tree
Hide file tree
Showing 38 changed files with 472 additions and 369 deletions.
2 changes: 1 addition & 1 deletion .storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { mockedStore as store } from '../app/reducers/mockedStore';
import { setUser } from '../app/actions/login';

const baseUrl = 'https://open.rocket.chat';
store.dispatch(selectServerRequest(baseUrl));
store.dispatch(selectServerRequest(baseUrl, '7.0.0'));
store.dispatch(setUser({ id: 'abc', username: 'rocket.cat', name: 'Rocket Cat' }));

const preview: Preview = {
Expand Down
2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ android {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode VERSIONCODE as Integer
versionName "4.54.0"
versionName "4.54.1"
vectorDrawables.useSupportLibrary = true
if (!isFoss) {
manifestPlaceholders = [BugsnagAPIKey: BugsnagAPIKey as String]
Expand Down
4 changes: 2 additions & 2 deletions app/actions/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { SERVER } from './actionsTypes';

export interface ISelectServerAction extends Action {
server: string;
version?: string;
version: string;
fetchVersion: boolean;
changeServer: boolean;
}
Expand All @@ -29,7 +29,7 @@ export type TActionServer = ISelectServerAction & ISelectServerSuccess & IServer

export function selectServerRequest(
server: string,
version?: string,
version: string,
fetchVersion = true,
changeServer = false
): ISelectServerAction {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const SupportedVersionsExpired = () => {
r.supportedVersionsWarningAt = null;
});
});
dispatch(selectServerRequest(server));
dispatch(selectServerRequest(server, serverRecord.version));
// forces loading state a little longer until redux is finished
await new Promise(res => setTimeout(res, checkAgainTimeout));
}
Expand Down
119 changes: 40 additions & 79 deletions app/containers/message/Components/Attachments/Video.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import React, { useContext, useEffect, useState } from 'react';
import { StyleProp, StyleSheet, TextStyle, View } from 'react-native';
import FastImage from 'react-native-fast-image';
import { getThumbnailAsync } from 'expo-video-thumbnails';
import React, { useContext } from 'react';
import { StyleProp, StyleSheet, Text, TextStyle, View } from 'react-native';

import { IUserMessage } from '../../../../definitions';
import { IAttachment } from '../../../../definitions/IAttachment';
Expand All @@ -10,107 +8,70 @@ import I18n from '../../../../i18n';
import { fileDownload, isIOS } from '../../../../lib/methods/helpers';
import EventEmitter from '../../../../lib/methods/helpers/events';
import { useTheme } from '../../../../theme';
import sharedStyles from '../../../../views/Styles';
import { TIconsName } from '../../../CustomIcon';
import { LISTENER } from '../../../Toast';
import Markdown from '../../../markdown';
import MessageContext from '../../Context';
import Touchable from '../../Touchable';
import { useMediaAutoDownload } from '../../hooks/useMediaAutoDownload';
import messageStyles from '../../styles';
import OverlayComponent from '../OverlayComponent';
import { CustomIcon, TIconsName } from '../../../CustomIcon';
import { themes } from '../../../../lib/constants';
import BlurComponent from '../OverlayComponent';
import { TDownloadState } from '../../../../lib/methods/handleMediaDownload';
import messageStyles from '../../styles';

const SUPPORTED_TYPES = ['video/quicktime', 'video/mp4', ...(isIOS ? [] : ['video/3gp', 'video/mkv'])];
const isTypeSupported = (type: string) => SUPPORTED_TYPES.indexOf(type) !== -1;

const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center'
},
overlay: {
flex: 1
},
image: {
width: '100%',
height: '100%'
},
playerIcon: {
cancelContainer: {
position: 'absolute',
textShadowRadius: 3,
textShadowOffset: {
width: 0.5,
height: 0.5
}
top: 8,
right: 8
},
text: {
...sharedStyles.textRegular,
fontSize: 12
}
});

type TThumbnailImage = string | null;
interface IMessageVideo {
file: IAttachment;
showAttachment?: (file: IAttachment) => void;
getCustomEmoji: TGetCustomEmoji;
author?: IUserMessage;
style?: StyleProp<TextStyle>[];
isReply?: boolean;
msg?: string;
}

type ThumbnailProps = {
url: string;
status: TDownloadState;
encrypted?: boolean;
const CancelIndicator = () => {
const { colors } = useTheme();
return (
<View style={styles.cancelContainer}>
<Text style={[styles.text, { color: colors.fontSecondaryInfo }]}>{I18n.t('Cancel')}</Text>
</View>
);
};

const Thumbnail = ({ url, status, encrypted = false }: ThumbnailProps) => {
const { theme } = useTheme();

const Thumbnail = ({ status, encrypted = false }: { status: TDownloadState; encrypted: boolean }) => {
const { colors } = useTheme();
let icon: TIconsName = status === 'downloaded' ? 'play-filled' : 'arrow-down-circle';
if (encrypted && status === 'downloaded') {
icon = 'encrypted';
}

const [image, setImage] = useState<TThumbnailImage>(null);

const generateThumbnail = async () => {
try {
if (!url) return;

const { uri } = await getThumbnailAsync(url, {
time: 1
});
setImage(uri);
} catch (e) {
console.warn(e);
}
};

useEffect(() => {
generateThumbnail();
}, [url]);

return (
<View style={styles.container}>
{status === 'loading' || !image || encrypted ? (
<OverlayComponent style={styles.overlay} loading={status === 'loading'} iconName={icon} />
) : (
<>
<FastImage style={styles.image} resizeMode='cover' source={{ uri: image }} />
<CustomIcon
name={icon}
size={54}
color={themes[theme].fontPureWhite}
style={[styles.playerIcon, { textShadowColor: themes[theme].backdropColor }]}
/>
</>
)}
</View>
<>
<BlurComponent
iconName={icon}
loading={status === 'loading'}
style={[messageStyles.image, { borderColor: colors.strokeLight, borderWidth: 1 }]}
/>
{status === 'loading' ? <CancelIndicator /> : null}
</>
);
};

interface IMessageVideo {
file: IAttachment;
showAttachment?: (file: IAttachment) => void;
getCustomEmoji: TGetCustomEmoji;
author?: IUserMessage;
style?: StyleProp<TextStyle>[];
isReply?: boolean;
msg?: string;
}

const Video = ({
file,
showAttachment,
Expand Down Expand Up @@ -151,7 +112,7 @@ const Video = ({
<>
<Markdown msg={msg} username={user.username} getCustomEmoji={getCustomEmoji} style={[isReply && style]} theme={theme} />
<Touchable onPress={_onPress} style={messageStyles.image} background={Touchable.Ripple(colors.surfaceNeutral)}>
<Thumbnail status={status} url={url} encrypted={isEncrypted} />
<Thumbnail status={status} encrypted={isEncrypted} />
</Touchable>
</>
);
Expand Down
13 changes: 13 additions & 0 deletions app/definitions/rest/v1/omnichannel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,19 @@ export type OmnichannelEndpoints = {
];
}>;
};

'livechat/inquiries.queued': {
GET: () => PaginatedResult<{
inquiries: IOmnichannelRoom[];
}>;
};

'livechat/inquiries.queuedForUser': {
GET: () => PaginatedResult<{
inquiries: IOmnichannelRoom[];
}>;
};

'livechat/rooms': {
GET: (params: {
guest: string;
Expand Down
8 changes: 7 additions & 1 deletion app/ee/omnichannel/lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import sdk from '../../../lib/services/sdk';
import { IUser } from '../../../definitions';
import { compareServerVersion } from '../../../lib/methods/helpers';
import EventEmitter from '../../../lib/methods/helpers/events';
import subscribeInquiry from './subscriptions/inquiry';

Expand All @@ -10,7 +11,12 @@ export const changeLivechatStatus = () => sdk.methodCallWrapper('livechat:change

// RC 2.4.0
// @ts-ignore
export const getInquiriesQueued = () => sdk.get('livechat/inquiries.queued');
export const getInquiriesQueued = (serverVersion: string) => {
const url = compareServerVersion(serverVersion, 'greaterThanOrEqualTo', '7.0.0')
? 'livechat/inquiries.queuedForUser'
: 'livechat/inquiries.queued';
return sdk.get(url);
};

// this inquiry is added to the db by the subscriptions stream
// and will be removed by the queue stream
Expand Down
4 changes: 3 additions & 1 deletion app/ee/omnichannel/sagas/inquiry.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ const handleRequest = function* handleRequest() {
const showQueue = routingConfig.showQueue && isOmnichannelStatusAvailable(user);

if (showQueue) {
const serverVersion = yield select(state => state.server.version);

// get all the current chats on the queue
const result = yield getInquiriesQueued();
const result = yield getInquiriesQueued(serverVersion);
if (result.success) {
const { inquiries } = result;

Expand Down
6 changes: 5 additions & 1 deletion app/lib/encryption/room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,11 @@ export default class EncryptionRoom {
// this will be called again and run once in 5 seconds
requestRoomKey = debounce(
async (e2eKeyId: string) => {
await Services.e2eRequestRoomKey(this.roomId, e2eKeyId);
try {
await Services.e2eRequestRoomKey(this.roomId, e2eKeyId);
} catch {
// do nothing
}
},
5000,
true
Expand Down
3 changes: 1 addition & 2 deletions app/lib/methods/loadThreadMessages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ async function load({ tmid }: { tmid: string }) {
return [];
}
return EJSON.fromJSONValue(result);
} catch (error) {
console.log(error);
} catch {
return [];
}
}
Expand Down
6 changes: 4 additions & 2 deletions app/lib/methods/logout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Model from '@nozbe/watermelondb/Model';
import * as Keychain from 'react-native-keychain';

import { getDeviceToken } from '../notifications';
import { extractHostname, isSsl } from './helpers';
import { extractHostname, isIOS, isSsl } from './helpers';
import { BASIC_AUTH_KEY } from './helpers/fetch';
import database, { getDatabase } from '../database';
import log from './helpers/log';
Expand All @@ -25,7 +25,9 @@ async function removeServerKeys({ server, userId }: { server: string; userId?: s
UserPreferences.removeItem(`${server}-${E2E_PUBLIC_KEY}`);
UserPreferences.removeItem(`${server}-${E2E_PRIVATE_KEY}`);
UserPreferences.removeItem(`${server}-${E2E_RANDOM_PASSWORD_KEY}`);
await Keychain.resetInternetCredentials(server);
if (isIOS) {
await Keychain.resetInternetCredentials(server);
}
}

async function removeSharedCredentials({ server }: { server: string }) {
Expand Down
16 changes: 11 additions & 5 deletions app/lib/methods/parseSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,15 @@ export function parseSettings(settings: any) {
}

export function _prepareSettings(settings: any) {
return settings.map((setting: any) => {
// @ts-ignore
setting[defaultSettings[setting._id].type] = setting.value;
return setting;
});
return settings
.map((setting: any) => {
// @ts-ignore
if (!defaultSettings[setting._id]) {
return undefined;
}
// @ts-ignore
setting[defaultSettings[setting._id].type] = setting.value;
return setting;
})
.filter(Boolean);
}
2 changes: 1 addition & 1 deletion app/lib/methods/subscriptions/rooms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ export default function subscribeRooms() {
const [, ev] = ddpMessage.fields.eventName.split('/');
if (/userData/.test(ev)) {
const [{ diff, unset }] = ddpMessage.fields.args;
if (diff.emails?.length > 0) {
if (diff?.emails?.length > 0) {
store.dispatch(setUser({ emails: diff.emails }));
}
if (diff?.statusLivechat) {
Expand Down
26 changes: 19 additions & 7 deletions app/lib/services/restApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -823,23 +823,35 @@ export const executeCommandPreview = (
});

export const getDirectory = ({
query,
text,
type,
workspace,
count,
offset,
sort
}: {
query: { [key: string]: string };
text: string;
type: string;
workspace: string;
count: number;
offset: number;
sort: { [key: string]: number };
}) =>
// RC 1.0
sdk.get('directory', {
query,
}) => {
const serverVersion = reduxStore.getState().server.version;
const params: any = {
count,
offset,
sort
});
};
if (compareServerVersion(serverVersion, 'greaterThanOrEqualTo', '7.0.0')) {
params.text = text;
params.type = type;
params.workspace = workspace;
} else {
params.query = { text, type, workspace };
}
return sdk.get('directory', params);
};

export const saveAutoTranslate = ({
rid,
Expand Down
2 changes: 1 addition & 1 deletion app/reducers/server.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('test server reducer', () => {

it('should return modified store after selectServer', () => {
const server = 'https://open.rocket.chat/';
mockedStore.dispatch(selectServerRequest(server));
mockedStore.dispatch(selectServerRequest(server, '4.1.0'));
const state = mockedStore.getState().server.server;
expect(state).toEqual(server);
});
Expand Down
Loading

0 comments on commit ae9875d

Please sign in to comment.