global webapp redirects, to finish upgrades
When an automatic upgrade completes, or when the user clicks on the upgrade button in one webapp, but also has it open in another browser window/tab, we have a problem: The current web server is going to stop running in minutes, but there is no way to send a redirect to the web browser to the new url. To solve this, used long polling, so the webapp is always listening for urls it should redirect to. This allows globally redirecting every open webapp. Works great! Tested with 2 web browsers with 2 tabs each. May be useful for other purposes later too, dunno. The overhead is 2 http requests per page load in the webapp. Due to yesod's speed, this does not seem to noticibly delay it. Only 1 of the requests could possibly block the page load, the other is async.
This commit is contained in:
parent
d24f7f94fe
commit
183f7355cd
11 changed files with 148 additions and 82 deletions
|
@ -14,6 +14,7 @@ import Logs.Transfer
|
|||
import Assistant.Types.ThreadName
|
||||
import Assistant.Types.NetMessager
|
||||
import Assistant.Types.Alert
|
||||
import Utility.Url
|
||||
|
||||
import Control.Concurrent.STM
|
||||
import Control.Concurrent.MVar
|
||||
|
@ -55,20 +56,23 @@ data DaemonStatus = DaemonStatus
|
|||
, desynced :: S.Set UUID
|
||||
-- Pairing request that is in progress.
|
||||
, pairingInProgress :: Maybe PairingInProgress
|
||||
-- Broadcasts notifications about all changes to the DaemonStatus
|
||||
-- Broadcasts notifications about all changes to the DaemonStatus.
|
||||
, changeNotifier :: NotificationBroadcaster
|
||||
-- Broadcasts notifications when queued or current transfers change.
|
||||
, transferNotifier :: NotificationBroadcaster
|
||||
-- Broadcasts notifications when there's a change to the alerts
|
||||
-- Broadcasts notifications when there's a change to the alerts.
|
||||
, alertNotifier :: NotificationBroadcaster
|
||||
-- Broadcasts notifications when the syncRemotes change
|
||||
-- Broadcasts notifications when the syncRemotes change.
|
||||
, syncRemotesNotifier :: NotificationBroadcaster
|
||||
-- Broadcasts notifications when the scheduleLog changes
|
||||
-- Broadcasts notifications when the scheduleLog changes.
|
||||
, scheduleLogNotifier :: NotificationBroadcaster
|
||||
-- Broadcasts a notification once the startup sanity check has run.
|
||||
, startupSanityCheckNotifier :: NotificationBroadcaster
|
||||
-- Broadcasts notifications when the network is connected
|
||||
-- Broadcasts notifications when the network is connected.
|
||||
, networkConnectedNotifier :: NotificationBroadcaster
|
||||
-- Broadcasts notifications when a global redirect is needed.
|
||||
, globalRedirNotifier :: NotificationBroadcaster
|
||||
, globalRedirUrl :: Maybe URLString
|
||||
-- When the XMPP client is connected, this will contain the XMPP
|
||||
-- address.
|
||||
, xmppClientID :: Maybe ClientID
|
||||
|
@ -106,5 +110,7 @@ newDaemonStatus = DaemonStatus
|
|||
<*> newNotificationBroadcaster
|
||||
<*> newNotificationBroadcaster
|
||||
<*> newNotificationBroadcaster
|
||||
<*> newNotificationBroadcaster
|
||||
<*> pure Nothing
|
||||
<*> pure Nothing
|
||||
<*> pure M.empty
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue