Skip to content

Commit

Permalink
fix(messaging-size): fix message when choosing an oversized file
Browse files Browse the repository at this point in the history
  • Loading branch information
FabrizioCostaMedich authored and Bri74 committed Apr 15, 2024
1 parent 323ebd1 commit 3408799
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
5 changes: 3 additions & 2 deletions assets/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,8 @@
"virtualClassroom_plural": "Virtual classrooms",
"visualization": "Visualization",
"year": "year",
"yesterday": "Yesterday"
"yesterday": "Yesterday",
"sizeExc": "Excessive file size, maximum 32 MB"
},
"contactsScreen": {
"cancelRecentSearch": "Remove",
Expand Down Expand Up @@ -505,7 +506,7 @@
"youHaveUnreadMessages": "You have {{total}} unread messages"
},
"messagingView": {
"pickFile": "Pick file",
"pickFile": "Pick file max 32MB",
"pickFileHint": "From your device or from the cloud",
"pickPhoto": "Pick image",
"pickPhotoHint": "From your library",
Expand Down
5 changes: 3 additions & 2 deletions assets/translations/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,8 @@
"virtualClassroom_plural": "Virtual classroom",
"visualization": "Visualizzazione",
"year": "anno",
"yesterday": "Ieri"
"yesterday": "Ieri",
"sizeExc": "File di dimensioni eccessive, massimo 32 MB"
},
"contactsScreen": {
"cancelRecentSearch": "Rimuovi",
Expand Down Expand Up @@ -505,7 +506,7 @@
"youHaveUnreadMessages": "Hai {{total}} messaggi non letti"
},
"messagingView": {
"pickFile": "Scegli un file",
"pickFile": "Scegli un file max 32MB",
"pickFileHint": "Dal tuo dispositivo o dal cloud",
"pickPhoto": "Scegli un'immagine",
"pickPhotoHint": "Dalla tua galleria",
Expand Down
22 changes: 20 additions & 2 deletions src/features/tickets/components/MessagingView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { MenuView } from '@react-native-menu/menu';

import { TranslucentView } from '../../../core/components/TranslucentView';
import { IS_IOS } from '../../../core/constants';
import { useFeedbackContext } from '../../../core/contexts/FeedbackContext';
import { pdfSizes } from '../../courses/constants';
import { Attachment } from '../../services/types/Attachment';
import { AttachmentChip } from './AttachmentChip';
Expand Down Expand Up @@ -49,10 +50,27 @@ export const MessagingView = ({
}: Props) => {
const { t } = useTranslation();
const styles = useStylesheet(createStyles);

const types = [
DocumentPicker.types.pdf,
DocumentPicker.types.images,
DocumentPicker.types.zip,
DocumentPicker.types.doc,
DocumentPicker.types.docx,
DocumentPicker.types.xlsx,
DocumentPicker.types.xls,
];
const { setFeedback } = useFeedbackContext();
const pickFile = async () => {
DocumentPicker.pickSingle().then(res => {
DocumentPicker.pickSingle({ type: types }).then(res => {
if (!res.name || !res.size || !res.type) return;
if (res.size > 32 * 1000000) {
setFeedback({
text: t('common.sizeExc'),
isError: true,
isPersistent: false,
});
return;
}

onAttachmentChange({
uri: res.uri,
Expand Down

0 comments on commit 3408799

Please sign in to comment.