-
-
Notifications
You must be signed in to change notification settings - Fork 141
[Mobile] - Add view document features #651
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
[Mobile] - Add view document features #651
Conversation
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds document viewing features to the mobile app, focusing on authentication persistence, document interaction, and file sharing capabilities.
Key Changes
- Added authentication session persistence to keep users logged in
- Implemented document action sheet for user interaction (tap on document to view actions)
- Added document download and share functionality using expo-sharing
Reviewed changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
pnpm-lock.yaml |
Updated dependencies including expo-sharing and @react-native-community/cli |
apps/mobile/package.json |
Added expo-sharing dependency and React Native CLI dev dependency |
apps/mobile/tsconfig.json |
Added JSX configuration for React Native |
apps/mobile/app/index.tsx |
Changed default redirect to documents list (potential authentication issue) |
apps/mobile/src/modules/api/api.models.ts |
Exported CoerceDate type for use in other modules |
apps/mobile/src/modules/organizations/organizations.provider.tsx |
Added authentication check to keep users logged in |
apps/mobile/src/modules/documents/screens/documents-list.screen.tsx |
Added tap interaction to show document action sheet |
apps/mobile/src/modules/documents/documents.services.ts |
Implemented file download function with authentication |
apps/mobile/src/modules/documents-actions/components/document-action-sheet.tsx |
New modal component for document actions (view/share) |
Comments suppressed due to low confidence (1)
apps/mobile/src/modules/documents-actions/components/document-action-sheet.tsx:38
- Unused variable apiClient.
const apiClient = useApiClient();
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
apps/mobile/src/modules/documents-actions/components/document-action-sheet.tsx
Outdated
Show resolved
Hide resolved
apps/mobile/src/modules/documents-actions/components/document-action-sheet.tsx
Outdated
Show resolved
Hide resolved
apps/mobile/src/modules/documents-actions/components/document-action-sheet.tsx
Outdated
Show resolved
Hide resolved
|
|
||
| // Load current organization ID from storage on mount | ||
| useEffect(() => { | ||
|
|
Copilot
AI
Nov 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Remove the blank line for better code consistency.
apps/mobile/src/modules/documents/screens/documents-list.screen.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thanks! 🙏
Made some comments, let me know
- Regarding the ui, love the drawer, maybe it'll be more scaleable to have a vertical list of action instead of a horizontal button stacks
- A
pnpm lint:fixmay also be needed
apps/mobile/package.json
Outdated
| }, | ||
| "devDependencies": { | ||
| "@antfu/eslint-config": "catalog:", | ||
| "@react-native-community/cli": "latest", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[question]
What is it used for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was trying to fix development build, i had some error, let me check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed.
| if(!authClient.getCookie()) { | ||
| router.replace('/auth/login'); | ||
| return; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure that's the responsibility of the organization provider to manage authentication redirection 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
| try { | ||
| const fileUri = await fetchDocumentFile({ | ||
| document: document, | ||
| organizationId: document.organizationId, | ||
| baseUrl, | ||
| authClient, | ||
| }); | ||
|
|
||
| const canShare = await Sharing.isAvailableAsync(); | ||
| if (canShare) { | ||
| await Sharing.shareAsync(fileUri); | ||
| } else { | ||
| showAlert({ | ||
| title: 'Sharing Failed', | ||
| message: 'Sharing is not available on this device. Please share the document manually.', | ||
| }); | ||
| } | ||
|
|
||
| } catch (error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check for the availability of the sharing api before fetching the file to avoid unnecessary transfer
apps/mobile/src/modules/documents/screens/documents-list.screen.tsx
Outdated
Show resolved
Hide resolved
| 'Content-Type': 'application/json', | ||
| }; | ||
| // Use documentDirectory for better app compatibility | ||
| const fileUri = `${FileSystem.documentDirectory}${document.name}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[question]
It looks like there will be collisions as the file isn't cleaned-up?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no it basically overrides it everytime. but let's change file system to cacheDirectory
apps/mobile/src/modules/documents-actions/components/document-action-sheet.tsx
Outdated
Show resolved
Hide resolved
apps/mobile/app/index.tsx
Outdated
| } | ||
|
|
||
| return <Redirect href="/auth/login" />; | ||
| return <Redirect href="/(app)/(with-organizations)/(tabs)/list" />; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not really sure about the change of the redirection here, I'd prefer to have all authentication/state redirection at the same place
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you run the master app, you will see that on app killed and reload even the app is logged in, it's still goes to login page, even though it should go to document.
so i implemented to check
- we go directly to home
- user not logged in
- go to login
- other wise be at home page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rewrote logic again.
Co-authored-by: Corentin Thomasset <[email protected]>
Co-authored-by: Copilot <[email protected]>
We will make it list when it exhausted. :), my idea is no future proofing, should be easy to fix later as well. |
CorentinTh
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // Use documentDirectory for better app compatibility | ||
| const fileUri = `${FileSystem.cacheDirectory}${document.name}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, seems better with cache directory
[Nit] Comment
| // Use documentDirectory for better app compatibility | |
| const fileUri = `${FileSystem.cacheDirectory}${document.name}`; | |
| // Use cacheDirectory for better app compatibility | |
| const fileUri = `${FileSystem.cacheDirectory}${document.name}`; |

screen-20251125-021818-1764019066497.mp4