Files
Folo/apps/renderer/src/modules/app/NetworkStatusIndicator.tsx
T
3a85febb6e refactor(monorepo): migrate to monorepo (#1059)
* init

Signed-off-by: Innei <i@innei.in>

* chore: utils import

Signed-off-by: Innei <tukon479@gmail.com>

* remove stable router

Signed-off-by: Innei <tukon479@gmail.com>

* refactor: components import

Signed-off-by: Innei <tukon479@gmail.com>

* chore: auto-fix linting and formatting issues

* minify

Signed-off-by: Innei <tukon479@gmail.com>

* update

Signed-off-by: Innei <tukon479@gmail.com>

* fix: test

Signed-off-by: Innei <tukon479@gmail.com>

* chore: ui component extract

Signed-off-by: Innei <tukon479@gmail.com>

* fix: import

Signed-off-by: Innei <tukon479@gmail.com>

* re-render

Signed-off-by: Innei <tukon479@gmail.com>

* refactor: remove hooks

Signed-off-by: Innei <tukon479@gmail.com>

* fix

Signed-off-by: Innei <tukon479@gmail.com>

* update

Signed-off-by: Innei <tukon479@gmail.com>

* setting

Signed-off-by: Innei <tukon479@gmail.com>

* update

Signed-off-by: Innei <tukon479@gmail.com>

* refactor: remove icons

Signed-off-by: Innei <i@innei.in>

* typings

Signed-off-by: Innei <i@innei.in>

* feat: add horizontal scroll functionality to TimelineTabs (#1081)

Co-authored-by: xhuajin <xhuajin@users.noreply.github.com>
Co-authored-by: Stephen Zhou <38493346+hyoban@users.noreply.github.com>

* fix: Wrong initial position of tab animation (#1087)

Co-authored-by: hamster1963 <hamster1963@users.noreply.github.com>

* fix: disable auto toggle readability in web

* fix: margin condition in EntryListHeader (#1103)

* chore(i18n): add daily reward system translation (#1102)

Co-authored-by: lc4t <lc4t@users.noreply.github.com>

* fix: deps

Signed-off-by: Innei <i@innei.in>

* fix: type

Signed-off-by: Innei <i@innei.in>

* update

Signed-off-by: Innei <i@innei.in>

* fix

Signed-off-by: Innei <i@innei.in>

---------

Signed-off-by: Innei <i@innei.in>
Signed-off-by: Innei <tukon479@gmail.com>
Co-authored-by: Innei <Innei@users.noreply.github.com>
Co-authored-by: Huajin <114134574+xhuajin@users.noreply.github.com>
Co-authored-by: xhuajin <xhuajin@users.noreply.github.com>
Co-authored-by: Stephen Zhou <38493346+hyoban@users.noreply.github.com>
Co-authored-by: 仓鼠 <71394853+hamster1963@users.noreply.github.com>
Co-authored-by: hamster1963 <hamster1963@users.noreply.github.com>
Co-authored-by: Konv Suu <2583695112@qq.com>
Co-authored-by: lc4t <11334449+lc4t@users.noreply.github.com>
Co-authored-by: lc4t <lc4t@users.noreply.github.com>
2024-10-24 14:37:43 +08:00

53 lines
2.1 KiB
TypeScript

import { Tooltip, TooltipContent, TooltipTrigger } from "@follow/components/ui/tooltip/index.jsx"
import { cn } from "@follow/utils/utils"
import { NetworkStatus, useApiStatus, useNetworkStatus } from "~/atoms/network"
import { useGeneralSettingKey } from "~/atoms/settings/general"
export const NetworkStatusIndicator = () => {
const networkStatus = useNetworkStatus()
const apiStatus = useApiStatus()
const canUseLocalData = useGeneralSettingKey("dataPersist")
if (networkStatus === NetworkStatus.ONLINE && apiStatus === NetworkStatus.ONLINE) {
return null
}
const canAccessAnyData =
canUseLocalData ||
(networkStatus === NetworkStatus.ONLINE && apiStatus === NetworkStatus.ONLINE)
return (
<Tooltip>
<TooltipTrigger asChild>
<div
className={cn(
"fixed bottom-2 left-2 flex items-center gap-1 rounded-full border bg-background px-1.5 py-1",
!canAccessAnyData &&
"border-current bg-red-50 text-red-400 dark:bg-red-800 dark:text-red-500",
)}
>
<i className="i-mgc-wifi-off-cute-re shrink-0 text-base" />
<span className="shrink-0 text-xs font-semibold opacity-50">
{networkStatus === NetworkStatus.OFFLINE
? canUseLocalData
? "Local Mode (alpha)"
: "Offline"
: apiStatus === NetworkStatus.OFFLINE
? "API Error"
: ""}
</span>
</div>
</TooltipTrigger>
<TooltipContent className="max-w-[35ch]" align="start" side="top">
{networkStatus === NetworkStatus.OFFLINE
? canUseLocalData
? "Currently in Local data mode due to current network connection failure."
: "Your network environment is abnormal and you are unable to request a remote server."
: apiStatus === NetworkStatus.OFFLINE
? "Your network connection is normal, there may be an error on the remote server and the API interface is temporarily unreachable."
: ""}
</TooltipContent>
</Tooltip>
)
}