Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:

strategy:
matrix:
node-version: [18.20.4]
node-version: [20]
fail-fast: true

steps:
Expand Down
6 changes: 4 additions & 2 deletions src/components/modals/AddModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -543,9 +543,10 @@ function AddModal(): JSX.Element {
})
.catch((err) => {
logger.error('Error on handleUploadFromCameraRoll function:', JSON.stringify(err));
const error = errorService.castError(err, 'upload');
notificationsService.show({
type: NotificationType.Error,
text1: strings.formatString(strings.errors.uploadFile, err.message) as string,
text1: error.message,
});
})
.finally(() => {
Expand Down Expand Up @@ -638,9 +639,10 @@ function AddModal(): JSX.Element {
})
.catch((err) => {
logger.error('Error on handleUploadFromCameraRoll (Android):', JSON.stringify(err));
const error = errorService.castError(err, 'upload');
notificationsService.show({
type: NotificationType.Error,
text1: strings.formatString(strings.errors.uploadFile, err.message) as string,
text1: error.message,
});
})
.finally(() => {
Expand Down
14 changes: 14 additions & 0 deletions src/contexts/Drive/Drive.context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import React, { useEffect, useRef, useState } from 'react';

import appService from '@internxt-mobile/services/AppService';
import errorService from '@internxt-mobile/services/ErrorService';
import notificationsService from '@internxt-mobile/services/NotificationsService';
import { AppStateStatus, NativeEventSubscription } from 'react-native';
import { NotificationType } from '@internxt-mobile/types/index';

import { driveFolderService } from '@internxt-mobile/services/drive/folder';
import { mapFileWithIsFolder, mapFolderWithIsFolder } from 'src/helpers/driveItemMappers';
Expand Down Expand Up @@ -87,7 +89,13 @@ export const DriveContextProvider: React.FC<DriveContextProviderProps> = ({ chil
const handleAppStateChange = (state: AppStateStatus) => {
if (state === 'active' && currentFolderId.current) {
loadFolderContent(currentFolderId.current, { pullFrom: ['network'], resetPagination: true }).catch((error) => {
// TODO: Refactor to custom hook (useDriveWithNotifications) to separate notification concerns from context
errorService.reportError(error);
const err = errorService.castError(error, 'content');
notificationsService.show({
type: NotificationType.Error,
text1: err.message,
});
});
}
};
Expand Down Expand Up @@ -115,7 +123,13 @@ export const DriveContextProvider: React.FC<DriveContextProviderProps> = ({ chil
setDriveFoldersTree({ [rootFolderId]: ROOT_FOLDER_NODE });
loadFolderContent(rootFolderId, { pullFrom: ['network'], resetPagination: true, focusFolder: true }).catch(
(err) => {
// TODO: Refactor to custom hook (useDriveWithNotifications) to separate notification concerns from context
errorService.reportError(err);
const error = errorService.castError(err, 'content');
notificationsService.show({
type: NotificationType.Error,
text1: error.message,
});
},
);
}, [rootFolderId]);
Expand Down
48 changes: 41 additions & 7 deletions src/screens/drive/DriveFolderScreen/DriveFolderScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@ export function DriveFolderScreen({ navigation }: DriveScreenProps<'DriveFolder'
})
.catch((error) => {
logger.error('Error loading folder content in DriveFolderScreen:', error);
errorService.reportError(error);
const err = errorService.castError(error, 'content');
notificationsService.show({
type: NotificationType.Error,
text1: err.message,
});
});
}
}, [folderUuid]);
Expand All @@ -109,7 +115,14 @@ export function DriveFolderScreen({ navigation }: DriveScreenProps<'DriveFolder'
if (parentUuid) {
driveCtx
.loadFolderContent(parentUuid, { pullFrom: ['network'], resetPagination: false, focusFolder: true })
.catch(errorService.reportError);
.catch((error) => {
errorService.reportError(error);
const err = errorService.castError(error, 'content');
notificationsService.show({
type: NotificationType.Error,
text1: err.message,
});
});
}
};

Expand Down Expand Up @@ -193,7 +206,14 @@ export function DriveFolderScreen({ navigation }: DriveScreenProps<'DriveFolder'
);
handleOnFilePress(driveItem);
} else if (driveItem.data.uuid) {
driveCtx.loadFolderContent(driveItem.data.uuid, { focusFolder: true, resetPagination: true });
driveCtx.loadFolderContent(driveItem.data.uuid, { focusFolder: true, resetPagination: true }).catch((error) => {
errorService.reportError(error);
const err = errorService.castError(error, 'content');
notificationsService.show({
type: NotificationType.Error,
text1: err.message,
});
});

// Navigate to the folder, this is the minimal data
navigation.push('DriveFolder', {
Expand Down Expand Up @@ -277,6 +297,11 @@ export function DriveFolderScreen({ navigation }: DriveScreenProps<'DriveFolder'
});
} catch (error) {
errorService.reportError(error);
const err = errorService.castError(error, 'content');
notificationsService.show({
type: NotificationType.Error,
text1: err.message,
});
} finally {
setLoadingMore(false);
}
Expand All @@ -296,11 +321,20 @@ export function DriveFolderScreen({ navigation }: DriveScreenProps<'DriveFolder'
}, [driveSortedItems, searchValue]);

async function handleRefresh() {
await driveCtx.loadFolderContent(folderUuid, {
focusFolder: true,
pullFrom: ['network'],
resetPagination: true,
});
try {
await driveCtx.loadFolderContent(folderUuid, {
focusFolder: true,
pullFrom: ['network'],
resetPagination: true,
});
} catch (error) {
errorService.reportError(error);
const err = errorService.castError(error, 'content');
notificationsService.show({
type: NotificationType.Error,
text1: err.message,
});
}
}

return (
Expand Down
Loading
Loading