-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fixed that idling on the homepage would cause a "websocket disconne…
…cted" notification to show up. (caused by the websocket having no subscriptions active; now, a "link preserver" subscription is created -- also moved the "request page refresh" functionality from the "ping" endpoint to this new one) * Renamed "env_ENV" in dockerfiles to "ENVIRONMENT". (less confusing, and standardizes with env-var-name chosen for Tiltfile)
- Loading branch information
Showing
17 changed files
with
124 additions
and
159 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import {BaseComponent} from "react-vextensions"; | ||
import {gql, useSubscription} from "web-vcore/nm/@apollo/client"; | ||
|
||
export const LINK_PRESERVER_SUBSCRIPTION = gql` | ||
subscription($input: LinkPreserverInput!) { | ||
linkPreserver(input: $input) { | ||
alive | ||
pageRefreshRequested | ||
} | ||
} | ||
`; | ||
type LinkPreserverResult = {alive: boolean, pageRefreshRequested: boolean}; | ||
|
||
export class LinkPreserver extends BaseComponent<{}, {}> { | ||
render() { | ||
let {} = this.props; | ||
|
||
// Choose 45s as our update-interval; this avoids Cloudflare's "100 seconds of dormancy" timeout. (https://community.cloudflare.com/t/cloudflare-websocket-timeout/5865) | ||
// (we use a <60s interval, so that it will reliably hit each 60s timer-interval that Chrome 88+ allows for hidden pages: https://developer.chrome.com/blog/timer-throttling-in-chrome-88/#intensive-throttling) | ||
const updateInterval = 45000; | ||
|
||
const {data, loading} = useSubscription(LINK_PRESERVER_SUBSCRIPTION, { | ||
variables: {input: {updateInterval}}, | ||
onSubscriptionData: info=>{ | ||
const {alive, pageRefreshRequested} = info.subscriptionData.data.linkPreserver as LinkPreserverResult; | ||
if (pageRefreshRequested) { | ||
console.log("Refreshing page due to server request."); | ||
window.location.reload(); | ||
} | ||
}, | ||
}); | ||
|
||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.