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
Connection status handling #1150
Conversation
6945a0d
to
5994439
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right on! I like the code. I'm glad we talked and thought about it for a minute. Thanks for deleting all that old login stuff too.
In addition to the suggestions below, here are a few thoughts.
Yellow Notice
Now that we have this connection error view, the yellow notice that says "Failed to fetch" is unnecessary. I think it should not appear in this case (when we're testing out a connection).
This might be more difficult than it seems. We pop up that "Notice" if any request in the whole app throws. You'll have to see if there is a way to remove the error handler only here, or if we need to remove it from where it is now and place it only where it's needed.
Wording of notice
As Al suggested, I think the wording of this error message needs to be updated to:
The service at {host}:{port} could not be reached.
flex-direction: column; | ||
` | ||
|
||
const StyledHeader = styled.h1` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This text style is called "heading/page" in sketch. Will you add it to the styled components theme then include it here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure thing
margin: 110px 0 0 0; | ||
font-size: 24px; | ||
font-weight: 700; | ||
color: ${(p) => p.theme.colors.aqua}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any objection to using color: var(--aqua)
?
const onClick = async () => { | ||
setIsFetching(true) | ||
await retry() | ||
console.log("done") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
console.log("done") |
font-size: 13px; | ||
font-weight: 400; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
font-size: 13px; | |
font-weight: 400; | |
${(p) => p.theme.typography.labelNormal} |
|
||
const onClick = async () => { | ||
setIsFetching(true) | ||
await retry() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might sound backward, but would you add a slight delay before actually retrying. Just long enough so that we're guaranteed to see the spinner. This will make it feel more responsive. If the spinner never appears, the user will wonder... did I click it?
I suggest here 300ms but play with value to see what feels good.
await retry() | |
await new Promise((r) => setTimeout(r, 300) | |
await retry() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah interesting! I had put in a wait just to test that it worked properly but then took it back out. I noticed the missing feedback then and that's why I added the Notice to the retry method, but if we end up removing that then I def agree that some sort of feedback is important
@@ -13,13 +13,15 @@ export const setConnection = (cluster: Cluster) => ( | |||
return zealot |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this file needs to be renamed to initConnection, similar to how we have initSpace and initTab
|
||
const setupConnection = (host, port) => (dispatch, _, {globalDispatch}) => { | ||
const cluster = { | ||
console.log("setup connection running") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
console.log("setup connection running") |
} | ||
dispatch(Clusters.add(cluster)) | ||
globalDispatch(Clusters.add(cluster)) | ||
dispatch(Current.setConnectionId(cluster.id)) | ||
} | ||
|
||
export default async function(store: Store) { | ||
const {space, host, port, id} = getUrlSearchParams() | ||
export default function(store: Store) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 to simpler code here
import Viewer from "../Viewer" | ||
import {getZealot} from "../../flows/getZealot" | ||
|
||
export function connectCluster(cluster: Cluster): Thunk<Promise<void>> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️ that this all is gone
src/js/state/Clusters/types.ts
Outdated
} | ||
|
||
export type Status = "initial" | "connected" | "disconnected" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be better to call this ConnectionStatus since we have other places we use the word Status. (SearchStatus, ViewerStatus, ChartStatus, UidStatus...etc)
21897c4
to
7ce03e3
Compare
0a8afc2
to
1a81b6c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks awesome. I like the delay, works very well.
dispatch(setConnection(c)).catch((e) => { | ||
dispatch(Notice.set(e)) | ||
dispatch(initConnection(c)).catch(() => { | ||
dispatch(Current.setConnectionId(c.id)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh nice! Easy
1a81b6c
to
94cd1c3
Compare
Signed-off-by: Mason Fish <mason@looky.cloud>
94cd1c3
to
ccf1347
Compare
fixes #1099
Changes
Every time the app loads we reset all statuses to "initial", indicating that we are unsure if the connection will succeed yet, and also indicating that we need to sync with server data. While syncing, if the connection fails we set the status to "disconnected" and display as much in a new tab content page where the user my attempt to retry.
Signed-off-by: Mason Fish mason@looky.cloud