Skip to content

feat: implement offline connection detection#154

Open
sameeraherath wants to merge 2 commits intoLDFLK:mainfrom
sameeraherath:feature/offline-connection-detection
Open

feat: implement offline connection detection#154
sameeraherath wants to merge 2 commits intoLDFLK:mainfrom
sameeraherath:feature/offline-connection-detection

Conversation

@sameeraherath
Copy link
Contributor

  • 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.

@CLAassistant
Copy link

CLAassistant commented Mar 21, 2026

CLA assistant check
All committers have signed the CLA.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, 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

  • Network Status Hook and Utility: A new useNetworkStatus hook and a network utility have been created to track the user's online/offline status.
  • Offline Banner Component: An OfflineBanner component has been added, which displays a visual indicator when the application detects that the user is offline, using a light yellow/dark yellow theme.
  • Integrated Offline Checks: Offline checks have been integrated into Axios interceptors and a new wrappedFetch function, preventing network requests when the user is offline.
  • Automatic Data Reload on Reconnect: The splash screen's data loading mechanism now automatically reloads data when the network connection is re-established, improving resilience to transient network issues.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Suggested change
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"

Comment on lines +19 to +20
// Initial check just in case it changed between mounting and effect
setIsOnline(navigator.onLine);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This check is redundant. The isOnline state is already initialized with navigator.onLine when the component first renders. The online and offline event listeners will handle any changes after that. You can safely remove these lines to simplify the hook.

// Request interceptor to block calls when offline
axiosInstance.interceptors.request.use(
(config) => {
if (!navigator.onLine) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Suggested change
if (!navigator.onLine) {
if (!network.isOnline()) {

@sameeraherath sameeraherath force-pushed the feature/offline-connection-detection branch from 884568f to e68fb3b Compare March 21, 2026 07:12
- 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.
@sameeraherath sameeraherath force-pushed the feature/offline-connection-detection branch from e68fb3b to 298cd47 Compare March 21, 2026 07:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants