Skip to content

Commit

Permalink
Merge branch 'develop' into chore.upgrade-wmdb
Browse files Browse the repository at this point in the history
  • Loading branch information
diegolmello authored Nov 5, 2024
2 parents d47a1ca + 84a6510 commit dd44f13
Show file tree
Hide file tree
Showing 24 changed files with 393 additions and 162 deletions.
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.55.0"
vectorDrawables.useSupportLibrary = true
if (!isFoss) {
manifestPlaceholders = [BugsnagAPIKey: BugsnagAPIKey as String]
Expand Down
4 changes: 3 additions & 1 deletion app/containers/MessageComposer/components/ComposerInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { RouteProp, useFocusEffect, useRoute } from '@react-navigation/native';

import I18n from '../../../i18n';
import { IAutocompleteItemProps, IComposerInput, IComposerInputProps, IInputSelection, TSetInput } from '../interfaces';
import { useAutocompleteParams, useFocused, useMessageComposerApi } from '../context';
import { useAutocompleteParams, useFocused, useMessageComposerApi, useMicOrSend } from '../context';
import { fetchIsAllOrHere, getMentionRegexp } from '../helpers';
import { useSubscription, useAutoSaveDraft } from '../hooks';
import sharedStyles from '../../../views/Styles';
Expand Down Expand Up @@ -58,6 +58,8 @@ export const ComposerInput = memo(
const usedCannedResponse = route.params?.usedCannedResponse;
const prevAction = usePrevious(action);

// subscribe to changes on mic state to update draft after a message is sent
useMicOrSend();
const { saveMessageDraft } = useAutoSaveDraft(textRef.current);

// Draft/Canned Responses
Expand Down
5 changes: 4 additions & 1 deletion app/containers/markdown/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,13 @@ class Markdown extends PureComponent<IMarkdownProps, any> {
};

renderParagraph = ({ children }: any) => {
const { numberOfLines, style = [], theme } = this.props;
const { numberOfLines, style = [], theme, msg } = this.props;
if (!children || children.length === 0) {
return null;
}
if (msg && this.isMessageContainsOnlyEmoji) {
return <Text>{children}</Text>;
}
return (
<Text style={[styles.text, { color: themes[theme!].fontDefault }, ...style]} numberOfLines={numberOfLines}>
{children}
Expand Down
1 change: 1 addition & 0 deletions app/containers/markdown/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export default StyleSheet.create({
...sharedStyles.textRegular
},
textBig: {
lineHeight: 43,
fontSize: 30,
...sharedStyles.textRegular
},
Expand Down
58 changes: 33 additions & 25 deletions app/containers/message/Components/Attachments/Reply.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const styles = StyleSheet.create({
attachmentContainer: {
flex: 1,
borderRadius: 4,
flexDirection: 'column',
flexDirection: 'row',
paddingVertical: 4,
paddingLeft: 8
},
Expand All @@ -43,6 +43,11 @@ const styles = StyleSheet.create({
alignItems: 'center',
marginBottom: 8
},
titleAndDescriptionContainer: {
flexDirection: 'column',
flex: 1,
width: 200
},
author: {
fontSize: 16,
...sharedStyles.textMedium,
Expand Down Expand Up @@ -72,11 +77,12 @@ const styles = StyleSheet.create({
marginBottom: 4
},
image: {
height: 200,
flex: 1,
height: 80,
width: 80,
borderTopLeftRadius: 4,
borderTopRightRadius: 4,
marginBottom: 1
marginBottom: 1,
marginLeft: 20
},
title: {
flex: 1,
Expand Down Expand Up @@ -245,28 +251,30 @@ const Reply = React.memo(
background={Touchable.Ripple(themes[theme].surfaceNeutral)}
disabled={!!(loading || attachment.message_link)}>
<View style={styles.attachmentContainer}>
<Title attachment={attachment} timeFormat={timeFormat} theme={theme} />
<Description attachment={attachment} getCustomEmoji={getCustomEmoji} theme={theme} />
<View style={styles.titleAndDescriptionContainer}>
<Title attachment={attachment} timeFormat={timeFormat} theme={theme} />
<Description attachment={attachment} getCustomEmoji={getCustomEmoji} theme={theme} />
<Attachments
attachments={attachment.attachments}
getCustomEmoji={getCustomEmoji}
timeFormat={timeFormat}
style={[{ color: themes[theme].fontHint, fontSize: 14, marginBottom: 8 }]}
isReply
showAttachment={showAttachment}
/>
<Fields attachment={attachment} getCustomEmoji={getCustomEmoji} theme={theme} />
{loading ? (
<View style={[styles.backdrop]}>
<View
style={[
styles.backdrop,
{ backgroundColor: themes[theme].surfaceNeutral, opacity: themes[theme].attachmentLoadingOpacity }
]}></View>
<RCActivityIndicator />
</View>
) : null}
</View>
<UrlImage image={attachment.thumb_url} />
<Attachments
attachments={attachment.attachments}
getCustomEmoji={getCustomEmoji}
timeFormat={timeFormat}
style={[{ color: themes[theme].fontHint, fontSize: 14, marginBottom: 8 }]}
isReply
showAttachment={showAttachment}
/>
<Fields attachment={attachment} getCustomEmoji={getCustomEmoji} theme={theme} />
{loading ? (
<View style={[styles.backdrop]}>
<View
style={[
styles.backdrop,
{ backgroundColor: themes[theme].surfaceNeutral, opacity: themes[theme].attachmentLoadingOpacity }
]}></View>
<RCActivityIndicator />
</View>
) : null}
</View>
</Touchable>
<Markdown msg={msg} username={user.username} getCustomEmoji={getCustomEmoji} theme={theme} />
Expand Down
119 changes: 79 additions & 40 deletions app/containers/message/Components/Attachments/Video.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import React, { useContext } from 'react';
import { StyleProp, StyleSheet, Text, TextStyle, View } from 'react-native';
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 { IUserMessage } from '../../../../definitions';
import { IAttachment } from '../../../../definitions/IAttachment';
Expand All @@ -8,70 +10,107 @@ 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 BlurComponent from '../OverlayComponent';
import { TDownloadState } from '../../../../lib/methods/handleMediaDownload';
import messageStyles from '../../styles';
import OverlayComponent from '../OverlayComponent';
import { CustomIcon, TIconsName } from '../../../CustomIcon';
import { themes } from '../../../../lib/constants';
import { TDownloadState } from '../../../../lib/methods/handleMediaDownload';

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({
cancelContainer: {
position: 'absolute',
top: 8,
right: 8
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center'
},
overlay: {
flex: 1
},
image: {
width: '100%',
height: '100%'
},
text: {
...sharedStyles.textRegular,
fontSize: 12
playerIcon: {
position: 'absolute',
textShadowRadius: 3,
textShadowOffset: {
width: 0.5,
height: 0.5
}
}
});

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

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

const Thumbnail = ({ status, encrypted = false }: { status: TDownloadState; encrypted: boolean }) => {
const { colors } = useTheme();
const Thumbnail = ({ url, status, encrypted = false }: ThumbnailProps) => {
const { theme } = 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 (
<>
<BlurComponent
iconName={icon}
loading={status === 'loading'}
style={[messageStyles.image, { borderColor: colors.strokeLight, borderWidth: 1 }]}
/>
{status === 'loading' ? <CancelIndicator /> : null}
</>
<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>
);
};

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 @@ -112,7 +151,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} encrypted={isEncrypted} />
<Thumbnail status={status} url={url} encrypted={isEncrypted} />
</Touchable>
</>
);
Expand Down
10 changes: 8 additions & 2 deletions app/containers/message/Urls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,14 @@ type TImageLoadedState = 'loading' | 'done' | 'error';
const Url = ({ url }: { url: IUrl }) => {
const { colors, theme } = useTheme();
const { baseUrl, user } = useContext(MessageContext);
let image = url.image || url.url;
image = image.includes('http') ? image : `${baseUrl}/${image}?rc_uid=${user.id}&rc_token=${user.token}`;
const getImageUrl = () => {
const imageUrl = url.image || url.url;

if (!imageUrl) return null;
if (imageUrl.includes('http')) return imageUrl;
return `${baseUrl}/${imageUrl}?rc_uid=${user.id}&rc_token=${user.token}`;
};
const image = getImageUrl();

const onPress = () => openLink(url.url, theme);

Expand Down
2 changes: 1 addition & 1 deletion app/i18n/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,7 @@
"you": "Sie",
"You_are_converting_the_team": "Sie wandeln dieses Team in einen Room um",
"You_are_deleting_the_team": "Sie sind dabei dieses Team zu löschen.",
"You_are_in_preview_mode": "Sie befinden dich im Vorschaumodus",
"You_are_in_preview_mode": "Sie befinden sich im Vorschaumodus",
"You_are_leaving_the_team": "Sie verlassen das Team '{{team}}'",
"You_can_search_using_RegExp_eg": "Sie können mit RegExp suchen. z.B. `/ ^ text $ / i`",
"You_colon": "Sie: ",
Expand Down
7 changes: 6 additions & 1 deletion app/lib/methods/getPermissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,12 @@ export const SUPPORTED_PERMISSIONS = [
'mobile-upload-file',
'delete-own-message',
'call-management',
'test-push-notifications'
'test-push-notifications',
'move-room-to-team',
'create-team-channel',
'create-team-group',
'delete-team-channel',
'delete-team-group'
] as const;

export async function setPermissions(): Promise<void> {
Expand Down
7 changes: 6 additions & 1 deletion app/lib/methods/getServerInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { store } from '../store/auxStore';
import I18n from '../../i18n';
import { SIGNED_SUPPORTED_VERSIONS_PUBLIC_KEY } from '../constants';
import { getServerById } from '../database/services/Server';
import { compareServerVersion } from './helpers';
import log from './helpers/log';

interface IServerInfoFailure {
Expand Down Expand Up @@ -121,7 +122,11 @@ export async function getServerInfo(server: string): Promise<TServerInfoResult>
}

const getUniqueId = async (server: string): Promise<string> => {
const response = await fetch(`${server}/api/v1/settings.public?query={"_id": "uniqueID"}`);
const serverVersion = store.getState().server.version;
const url = compareServerVersion(serverVersion, 'greaterThanOrEqualTo', '7.0.0')
? `${server}/api/v1/settings.public?_id=uniqueID`
: `${server}/api/v1/settings.public?query={"_id": "uniqueID"}`;
const response = await fetch(url);
const result = await response.json();
return result?.settings?.[0]?.value;
};
Expand Down
Loading

0 comments on commit dd44f13

Please sign in to comment.