From 1585c5035e69a7b6377ffcc9249588296706265b Mon Sep 17 00:00:00 2001 From: Kai Vandivier Date: Thu, 16 Feb 2023 18:23:37 +0100 Subject: [PATCH] docs: clarify importance of useDhis2ConnectionStatus --- docs/advanced/offline/README.md | 2 +- docs/advanced/offline/useDhis2ConnectionStatus.md | 2 ++ docs/advanced/offline/useOnlineStatus.md | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/advanced/offline/README.md b/docs/advanced/offline/README.md index 6737f1c6..15afd54c 100644 --- a/docs/advanced/offline/README.md +++ b/docs/advanced/offline/README.md @@ -4,7 +4,7 @@ The app platform provides some support for PWA features, including a `manifest.json` file for installability and service worker which can provide offline caching. In addition to those features, the app runtime provides support for ["cacheable sections"](advanced/offline/CacheableSections), which are sections of an app that can be individually cached on-demand. The [`useCacheableSection` hook](advanced/offline/CacheableSections#usecacheablesection-api) and the [`CacheableSection` component](advanced/offline/CacheableSections#cacheablesection-api) provide the controls for the section and the wrapper for the section, respectively. The [`useCachedSections` hook](advanced/offline/CacheableSections#usecachedsections-api) returns a list of sections that are stored in the cache and a function that can delete them. -An important tool for offline-capable apps is the [`useDhis2ConnectionStatus` hook](advanced/offline/useDhis2ConnectionStatus.md), which can be used to determine whether or not the app can connect to the DHIS2 server. There is also a [`useOnlineStatus` hook](advanced/offline/useOnlineStatus.md) which returns the whether or not the client is connected to the internet, but `useDhis2ConnectionStatus` is probably the one you want to use. +An important tool for offline-capable apps is the [`useDhis2ConnectionStatus` hook](advanced/offline/useDhis2ConnectionStatus.md), which can be used to determine whether or not the app can connect to the DHIS2 server. There is also a [`useOnlineStatus` hook](advanced/offline/useOnlineStatus.md) which returns whether or not the client is connected to the internet, but `useDhis2ConnectionStatus` is probably the one you want to use. On instances where DHIS2 is deployed locally in an environment without internet, `useOnlineStatus` can cause problems, because it will always return `false` even though the app can communicate with the DHIS2 server and therefore function just fine. `useDhis2ConnectionStatus` was created to address this problem. ## Examples diff --git a/docs/advanced/offline/useDhis2ConnectionStatus.md b/docs/advanced/offline/useDhis2ConnectionStatus.md index d989f11d..18a527e0 100644 --- a/docs/advanced/offline/useDhis2ConnectionStatus.md +++ b/docs/advanced/offline/useDhis2ConnectionStatus.md @@ -4,6 +4,8 @@ This hook is used to detect whether or not the app can connect to the DHIS2 server. This can be useful, for example, to make changes in the UI to prevent the user from taking actions that would cause errors while unable to reach the server. +It's designed to detect server connection because checking just the internet connection can lead to problems on DHIS2 instances that are implemented offline, where features or actions might be blocked because the device is offline, even though the app can connect to the DHIS2 server just fine. In these cases, what matters is whether or not the app can connect to the DHIS2 server. + ```ts import { useDhis2ConnectionStatus } from '@dhis2/app-runtime' diff --git a/docs/advanced/offline/useOnlineStatus.md b/docs/advanced/offline/useOnlineStatus.md index 0784b648..366a797f 100644 --- a/docs/advanced/offline/useOnlineStatus.md +++ b/docs/advanced/offline/useOnlineStatus.md @@ -1,6 +1,6 @@ # useOnlineStatus -!> This hook only detects whether or not you're connected to the internet, which could be problematic for DHIS2 instances that are hosted locally or offline. The [`useDhis2ConnectionStatus` hook](advanced/offline/useDhis2ConnectionStatus) is usually better for that reason, and is therefore recommended. +!> This hook only detects whether or not you're connected to the internet, which could be problematic for DHIS2 instances that are hosted locally or offline, where what really matters is whether or not you can communicate with the DHIS2 server. The [`useDhis2ConnectionStatus` hook](advanced/offline/useDhis2ConnectionStatus) is usually better for that reason, and is therefore recommended. The `useOnlineStatus` returns whether the client is online or offline. It debounces the returned values by default to prevent rapid changes of any UI elements that depend on the online status.