From 9d25636cf4918fd4fc68bfab8d38983823fb8068 Mon Sep 17 00:00:00 2001 From: Gleidson Daniel Silva Date: Wed, 19 Jan 2022 17:37:06 -0300 Subject: [PATCH 1/4] [FIX] App crashes when opening a notification while app is closed (#3629) --- app/definitions/INotification.ts | 1 + app/notifications/push/index.ts | 5 +++-- app/notifications/push/push.ios.ts | 2 +- app/notifications/push/push.ts | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/definitions/INotification.ts b/app/definitions/INotification.ts index 77467d9d..4974b0c9 100644 --- a/app/definitions/INotification.ts +++ b/app/definitions/INotification.ts @@ -9,4 +9,5 @@ export interface INotification { from: string; image: string; soundname: string; + getData: () => INotification; } diff --git a/app/notifications/push/index.ts b/app/notifications/push/index.ts index af25c9ee..09fa8602 100644 --- a/app/notifications/push/index.ts +++ b/app/notifications/push/index.ts @@ -16,9 +16,10 @@ interface IEjson { messageId: string; } -export const onNotification = (notification: INotification): void => { - if (notification) { +export const onNotification = (push: INotification): void => { + if (push) { try { + const notification = push?.getData(); const { rid, name, sender, type, host, messageType, messageId }: IEjson = EJSON.parse(notification.ejson); const types: Record = { diff --git a/app/notifications/push/push.ios.ts b/app/notifications/push/push.ios.ts index 92c2d3a6..a6b1118c 100644 --- a/app/notifications/push/push.ios.ts +++ b/app/notifications/push/push.ios.ts @@ -22,7 +22,7 @@ class PushNotification { // TODO REDUX MIGRATION TO TS const { background } = reduxStore.getState().app; if (background) { - this.onNotification(notification?.getData()); + this.onNotification(notification); } completion(); }); diff --git a/app/notifications/push/push.ts b/app/notifications/push/push.ts index 16aa8cf5..11eccbcb 100644 --- a/app/notifications/push/push.ts +++ b/app/notifications/push/push.ts @@ -16,7 +16,7 @@ class PushNotification { }); NotificationsAndroid.setNotificationOpenedListener((notification: Notification) => { - this.onNotification(notification?.getData()); + this.onNotification(notification); }); } From 44d2b4b0e1433a9c9d982e8506c3a82a4c8d65c0 Mon Sep 17 00:00:00 2001 From: Reinaldo Neto <47038980+reinaldonetof@users.noreply.github.com> Date: Wed, 19 Jan 2022 17:41:21 -0300 Subject: [PATCH 2/4] [FIX] makeThreadName asserting undefined as non-null (#3628) --- app/utils/room.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/utils/room.ts b/app/utils/room.ts index 3e4e0ef4..d39e4049 100644 --- a/app/utils/room.ts +++ b/app/utils/room.ts @@ -60,6 +60,6 @@ export const getBadgeColor = ({ }; 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; From e91bb905435744239732d5bdd88d9d351891b20c Mon Sep 17 00:00:00 2001 From: Reinaldo Neto <47038980+reinaldonetof@users.noreply.github.com> Date: Wed, 19 Jan 2022 17:54:12 -0300 Subject: [PATCH 3/4] [FIX] Threads' pagination not working (#3631) --- app/views/ThreadMessagesView/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/ThreadMessagesView/index.tsx b/app/views/ThreadMessagesView/index.tsx index 230a6778..2b53159b 100644 --- a/app/views/ThreadMessagesView/index.tsx +++ b/app/views/ThreadMessagesView/index.tsx @@ -284,7 +284,7 @@ class ThreadMessagesView extends React.Component buildMessage(m)); // 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)); threadsToCreate = threadsToCreate.map(thread => threadsCollection.prepareCreate( From 782bdda2c7d8bc77d390d9549fb24302f4cc9804 Mon Sep 17 00:00:00 2001 From: Diego Mello Date: Thu, 20 Jan 2022 15:24:27 -0300 Subject: [PATCH 4/4] [IMPROVE] Convert HEIC images to JPG and remove compression (#3633) --- app/containers/MessageBox/index.tsx | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/app/containers/MessageBox/index.tsx b/app/containers/MessageBox/index.tsx index 9fe3d11a..fbcf24cd 100644 --- a/app/containers/MessageBox/index.tsx +++ b/app/containers/MessageBox/index.tsx @@ -2,7 +2,7 @@ import React, { Component } from 'react'; import { Alert, Keyboard, NativeModules, Text, View } from 'react-native'; import { connect } from 'react-redux'; 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 DocumentPicker from 'react-native-document-picker'; import { Q } from '@nozbe/watermelondb'; @@ -27,7 +27,7 @@ import LeftButtons from './LeftButtons'; // @ts-ignore // eslint-disable-next-line import/extensions,import/no-unresolved import RightButtons from './RightButtons'; -import { isAndroid, isTablet } from '../../utils/deviceInfo'; +import { isAndroid, isIOS, isTablet } from '../../utils/deviceInfo'; import { canUploadFile } from '../../utils/media'; import EventEmiter from '../../utils/events'; import { KEY_COMMAND, handleCommandShowUpload, handleCommandSubmit, handleCommandTyping } from '../../commands'; @@ -54,15 +54,16 @@ if (isAndroid) { const imagePickerConfig = { cropping: true, - compressImageQuality: 0.8, avoidEmptySpaceAroundImage: false, - freeStyleCropEnabled: true + freeStyleCropEnabled: true, + forceJpg: true }; const libraryPickerConfig = { multiple: true, compressVideoPreset: 'Passthrough', - mediaType: 'any' + mediaType: 'any', + forceJpg: true }; const videoPickerConfig = { @@ -129,6 +130,18 @@ interface IMessageBoxState { 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 { private text: string; @@ -692,7 +705,8 @@ class MessageBox extends Component { takePhoto = async () => { logEvent(events.ROOM_BOX_ACTION_PHOTO); try { - const image = await ImagePicker.openCamera(this.imagePickerConfig); + let image = (await ImagePicker.openCamera(this.imagePickerConfig)) as Image; + image = forceJpgExtension(image); if (this.canUploadFile(image)) { this.openShareView([image]); } @@ -716,7 +730,8 @@ class MessageBox extends Component { chooseFromLibrary = async () => { logEvent(events.ROOM_BOX_ACTION_LIBRARY); 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); } catch (e) { logEvent(events.ROOM_BOX_ACTION_LIBRARY_F);