Merge branch 'develop' into chore/migration-ts-redux-users-typing

This commit is contained in:
Gleidson Daniel Silva 2022-01-26 09:52:14 -03:00 committed by GitHub
commit 8305d3dd6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 30 additions and 13 deletions

View File

@ -2,7 +2,7 @@ import React, { Component } from 'react';
import { Alert, Keyboard, NativeModules, Text, View } from 'react-native'; import { Alert, Keyboard, NativeModules, Text, View } from 'react-native';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { KeyboardAccessoryView } from 'react-native-ui-lib/keyboard'; import { KeyboardAccessoryView } from 'react-native-ui-lib/keyboard';
import ImagePicker from 'react-native-image-crop-picker'; import ImagePicker, { Image, ImageOrVideo } from 'react-native-image-crop-picker';
import { dequal } from 'dequal'; import { dequal } from 'dequal';
import DocumentPicker from 'react-native-document-picker'; import DocumentPicker from 'react-native-document-picker';
import { Q } from '@nozbe/watermelondb'; import { Q } from '@nozbe/watermelondb';
@ -27,7 +27,7 @@ import LeftButtons from './LeftButtons';
// @ts-ignore // @ts-ignore
// eslint-disable-next-line import/extensions,import/no-unresolved // eslint-disable-next-line import/extensions,import/no-unresolved
import RightButtons from './RightButtons'; import RightButtons from './RightButtons';
import { isAndroid, isTablet } from '../../utils/deviceInfo'; import { isAndroid, isIOS, isTablet } from '../../utils/deviceInfo';
import { canUploadFile } from '../../utils/media'; import { canUploadFile } from '../../utils/media';
import EventEmiter from '../../utils/events'; import EventEmiter from '../../utils/events';
import { KEY_COMMAND, handleCommandShowUpload, handleCommandSubmit, handleCommandTyping } from '../../commands'; import { KEY_COMMAND, handleCommandShowUpload, handleCommandSubmit, handleCommandTyping } from '../../commands';
@ -54,15 +54,16 @@ if (isAndroid) {
const imagePickerConfig = { const imagePickerConfig = {
cropping: true, cropping: true,
compressImageQuality: 0.8,
avoidEmptySpaceAroundImage: false, avoidEmptySpaceAroundImage: false,
freeStyleCropEnabled: true freeStyleCropEnabled: true,
forceJpg: true
}; };
const libraryPickerConfig = { const libraryPickerConfig = {
multiple: true, multiple: true,
compressVideoPreset: 'Passthrough', compressVideoPreset: 'Passthrough',
mediaType: 'any' mediaType: 'any',
forceJpg: true
}; };
const videoPickerConfig = { const videoPickerConfig = {
@ -129,6 +130,18 @@ interface IMessageBoxState {
permissionToUpload: boolean; permissionToUpload: boolean;
} }
const forceJpgExtension = (attachment: ImageOrVideo) => {
if (isIOS && attachment.mime === 'image/jpeg' && attachment.filename) {
const regex = new RegExp(/.heic$/i);
if (attachment.filename.match(regex)) {
attachment.filename = attachment.filename.replace(regex, '.jpg');
} else {
attachment.filename += '.jpg';
}
}
return attachment;
};
class MessageBox extends Component<IMessageBoxProps, IMessageBoxState> { class MessageBox extends Component<IMessageBoxProps, IMessageBoxState> {
private text: string; private text: string;
@ -692,7 +705,8 @@ class MessageBox extends Component<IMessageBoxProps, IMessageBoxState> {
takePhoto = async () => { takePhoto = async () => {
logEvent(events.ROOM_BOX_ACTION_PHOTO); logEvent(events.ROOM_BOX_ACTION_PHOTO);
try { try {
const image = await ImagePicker.openCamera(this.imagePickerConfig); let image = (await ImagePicker.openCamera(this.imagePickerConfig)) as Image;
image = forceJpgExtension(image);
if (this.canUploadFile(image)) { if (this.canUploadFile(image)) {
this.openShareView([image]); this.openShareView([image]);
} }
@ -716,7 +730,8 @@ class MessageBox extends Component<IMessageBoxProps, IMessageBoxState> {
chooseFromLibrary = async () => { chooseFromLibrary = async () => {
logEvent(events.ROOM_BOX_ACTION_LIBRARY); logEvent(events.ROOM_BOX_ACTION_LIBRARY);
try { try {
const attachments = await ImagePicker.openPicker(this.libraryPickerConfig); let attachments = (await ImagePicker.openPicker(this.libraryPickerConfig)) as ImageOrVideo[];
attachments = attachments.map(att => forceJpgExtension(att));
this.openShareView(attachments); this.openShareView(attachments);
} catch (e) { } catch (e) {
logEvent(events.ROOM_BOX_ACTION_LIBRARY_F); logEvent(events.ROOM_BOX_ACTION_LIBRARY_F);

View File

@ -9,4 +9,5 @@ export interface INotification {
from: string; from: string;
image: string; image: string;
soundname: string; soundname: string;
getData: () => INotification;
} }

View File

@ -16,9 +16,10 @@ interface IEjson {
messageId: string; messageId: string;
} }
export const onNotification = (notification: INotification): void => { export const onNotification = (push: INotification): void => {
if (notification) { if (push) {
try { try {
const notification = push?.getData();
const { rid, name, sender, type, host, messageType, messageId }: IEjson = EJSON.parse(notification.ejson); const { rid, name, sender, type, host, messageType, messageId }: IEjson = EJSON.parse(notification.ejson);
const types: Record<string, string> = { const types: Record<string, string> = {

View File

@ -22,7 +22,7 @@ class PushNotification {
// TODO REDUX MIGRATION TO TS // TODO REDUX MIGRATION TO TS
const { background } = reduxStore.getState().app; const { background } = reduxStore.getState().app;
if (background) { if (background) {
this.onNotification(notification?.getData()); this.onNotification(notification);
} }
completion(); completion();
}); });

View File

@ -16,7 +16,7 @@ class PushNotification {
}); });
NotificationsAndroid.setNotificationOpenedListener((notification: Notification) => { NotificationsAndroid.setNotificationOpenedListener((notification: Notification) => {
this.onNotification(notification?.getData()); this.onNotification(notification);
}); });
} }

View File

@ -60,6 +60,6 @@ export const getBadgeColor = ({
}; };
export const makeThreadName = (messageRecord: { id?: string; msg?: string; attachments?: IAttachment[] }): string | undefined => export const makeThreadName = (messageRecord: { id?: string; msg?: string; attachments?: IAttachment[] }): string | undefined =>
messageRecord.msg || messageRecord.attachments![0].title; messageRecord.msg || messageRecord?.attachments?.[0]?.title;
export const isTeamRoom = ({ teamId, joined }: { teamId: string; joined: boolean }): boolean => !!teamId && joined; export const isTeamRoom = ({ teamId, joined }: { teamId: string; joined: boolean }): boolean => !!teamId && joined;

View File

@ -284,7 +284,7 @@ class ThreadMessagesView extends React.Component<IThreadMessagesViewProps, IThre
if (update && update.length) { if (update && update.length) {
update = update.map(m => buildMessage(m)); update = update.map(m => buildMessage(m));
// filter threads // filter threads
threadsToCreate = update.filter(i1 => allThreadsRecords.find((i2: { id: string }) => i1._id === i2.id)); threadsToCreate = update.filter(i1 => !allThreadsRecords.find((i2: { id: string }) => i1._id === i2.id));
threadsToUpdate = allThreadsRecords.filter((i1: { id: string }) => update.find(i2 => i1.id === i2._id)); threadsToUpdate = allThreadsRecords.filter((i1: { id: string }) => update.find(i2 => i1.id === i2._id));
threadsToCreate = threadsToCreate.map(thread => threadsToCreate = threadsToCreate.map(thread =>
threadsCollection.prepareCreate( threadsCollection.prepareCreate(