Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Differentiate user being offline and API being offline #579

Merged
merged 2 commits into from Jun 22, 2023

Conversation

lukaw3d
Copy link
Member

@lukaw3d lukaw3d commented Jun 21, 2023

No description provided.

@lukaw3d lukaw3d requested review from buberdds and csillag June 21, 2023 22:41
@github-actions
Copy link

github-actions bot commented Jun 21, 2023

Deployed to Cloudflare Pages

Latest commit: ced5e562bbb6730b85849376f0f712383c7e7b8b
Status:✅ Deploy successful!
Preview URL: https://8249e31a.oasis-explorer.pages.dev

@@ -277,6 +277,7 @@
},
"home": {
"apiOffline": "Our {{ target }} API is offline. We’re trying to reconnect",
"userOffline": "You are offline. We’re trying to reconnect",
Copy link
Member Author

Choose a reason for hiding this comment

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

@@ -5,9 +5,11 @@ import { AppError, AppErrors } from '../../../types/errors'
import { useFormattedTimestampString } from '../../hooks/useFormattedTimestamp'
import { paraTimesConfig } from '../../../config'

export const useIsApiOffline = (network: Network): boolean => {
export const useIsApiOffline = (network: Network): false | 'userOffline' | 'apiOffline' => {
Copy link
Contributor

Choose a reason for hiding this comment

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

At this point I think we should rename this to useNetworkProblem().

Copy link
Member Author

Choose a reason for hiding this comment

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

I think that's too confusing: user's "network" && mainnet "network"?

Copy link
Member Author

Choose a reason for hiding this comment

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

isApiReachable?

Copy link
Contributor

@csillag csillag Jun 22, 2023

Choose a reason for hiding this comment

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

isApiReachable?

No, that would make the "false" return value confusing.

How about useConnectionProblem() ?

Copy link
Member Author

Choose a reason for hiding this comment

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

but it's not necessarily a connection problem if API is unresponsive :D

Copy link
Contributor

@csillag csillag Jun 22, 2023

Choose a reason for hiding this comment

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

OK, I am fine with useIsApiReachable, but then we need a different result structure. { reachable: true } when all is fine, and { reachable: false, reason: "whatever" } in case of issues.

Copy link
Contributor

@csillag csillag left a comment

Choose a reason for hiding this comment

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

Reviewed, LGTM. (See comment)

@lukaw3d lukaw3d merged commit fdbd691 into master Jun 22, 2023
7 checks passed
@lukaw3d lukaw3d deleted the lw/user-offline branch June 22, 2023 11:23
<StyledAlert severity="warning">{t('home.apiOffline', { target })}</StyledAlert>
) : null
if (!isNetworkReachable.reachable) {
if (isNetworkReachable.reason === 'userOffline') {
Copy link
Contributor

Choose a reason for hiding this comment

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

I would prefer adding the full text of reason right inside the hook (we have access to translation there, too); no need to have a layer of compilation here...

@@ -139,7 +139,7 @@ export const HomePage: FC = () => {
</LogotypeBox>
<SearchInputContainer>
<SearchInputBox>
<Search disabled={isApiOffline} variant={searchVariant} onFocusChange={onFocusChange} />
<Search disabled={!isApiReachable} variant={searchVariant} onFocusChange={onFocusChange} />
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we need to update this to get the inside from within the structure returned by the hook.

Copy link
Member Author

Choose a reason for hiding this comment

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

😱

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.

None yet

2 participants