Refactor: Fetch documents from Firestore for cross-device visibility #1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously, your application relied heavily on localStorage for storing and retrieving document lists and details. This prevented documents uploaded by one user from being visible on other devices or by other users.
This commit refactors your application to use Firestore as the central source of truth for document metadata:
src/app/page.tsx(HomePage) now fetches the list of all documentsfrom the "articles" collection in Firestore in real-time.
useLocalStoragefor "docuview-library" has been replaced.Document deletion now also removes the entry from Firestore.
src/app/documents/[id]/page.tsxnow fetches individual documentmetadata from Firestore server-side and passes it to the
DocumentViewcomponent.src/components/document/DocumentView.tsxhas been updated toreceive document data as a prop, removing its direct localStorage-based
fetching logic.
This change ensures that all users see the same set of documents, addressing the core issue. Uploads continue to use Cloudinary for file storage (when configured) and Firestore for metadata.
A build warning regarding Cloudinary server-side environment variables was noted and should be addressed separately to ensure full functionality of Cloudinary-dependent operations like file deletion from the cloud. The
pdfjs-distpackage was downgraded to^4.0.379to resolve a build issue with the available Node.js version.