feat: implement offline connection detection#154
feat: implement offline connection detection#154sameeraherath wants to merge 2 commits intoLDFLK:mainfrom
Conversation
sameeraherath
commented
Mar 21, 2026
- Created useNetworkStatus hook and network utility for status tracking
- Added OfflineBanner component with light yellow/dark yellow theme
- Integrated offline checks in Axios interceptors and Fetch services
- Implemented automatic data reload on reconnect for the splash screen.
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces robust offline connection detection capabilities to the application. By implementing a dedicated network status hook and utility, the system can now proactively inform users of their connectivity state via a new banner component. Furthermore, network requests are intelligently managed, preventing calls when offline and automatically retrying data fetches on reconnection, significantly enhancing the application's user experience and stability in varying network conditions. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request effectively implements offline connection detection across the application. You've introduced a useNetworkStatus hook for React components and a network utility for other services, which is a good separation. The OfflineBanner provides clear feedback to the user. The integration into Axios interceptors and Fetch services to prevent requests while offline is well-executed. I have a few suggestions to improve consistency and theming.
src/components/OfflineBanner.jsx
Outdated
| animate={{ height: "auto", opacity: 1 }} | ||
| exit={{ height: 0, opacity: 0 }} | ||
| transition={{ duration: 0.3, ease: "easeInOut" }} | ||
| className="fixed top-0 left-0 w-full z-[9999] bg-[#FEF08A] text-[#713f12] overflow-hidden shadow-sm border-b border-[#713f12]/10 backdrop-blur-md" |
There was a problem hiding this comment.
The banner's colors are hardcoded and won't adapt to the application's dark theme. To ensure a consistent user experience, please add dark mode variants for the background, text, and border colors using Tailwind's dark: prefix.
| className="fixed top-0 left-0 w-full z-[9999] bg-[#FEF08A] text-[#713f12] overflow-hidden shadow-sm border-b border-[#713f12]/10 backdrop-blur-md" | |
| className="fixed top-0 left-0 w-full z-[9999] bg-[#FEF08A] text-[#713f12] dark:bg-[#92400E] dark:text-[#FEF3C7] overflow-hidden shadow-sm border-b border-[#713f12]/10 dark:border-[#FEF3C7]/10 backdrop-blur-md" |
src/hooks/useNetworkStatus.js
Outdated
| // Initial check just in case it changed between mounting and effect | ||
| setIsOnline(navigator.onLine); |
| // Request interceptor to block calls when offline | ||
| axiosInstance.interceptors.request.use( | ||
| (config) => { | ||
| if (!navigator.onLine) { |
There was a problem hiding this comment.
For consistency with services.jsx, it's better to use the network.isOnline() utility here instead of accessing navigator.onLine directly. This centralizes the network status checking logic.
You'll need to add import network from '../utils/network'; at the top of the file.
| if (!navigator.onLine) { | |
| if (!network.isOnline()) { |
884568f to
e68fb3b
Compare
- Created useNetworkStatus hook and network utility for status tracking - Added OfflineBanner component with light yellow/dark yellow theme - Integrated offline checks in Axios interceptors and Fetch services - Implemented automatic data reload on reconnect for the splash screen.
- Added dark: variants for OfflineBanner background, text, and border. - Refactored useNetworkStatus.js hook to use centralized network.isOnline() utility for project-wide consistency.
e68fb3b to
298cd47
Compare