diff options
author | Joey Hess <joey@kitenet.net> | 2013-04-04 01:48:26 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2013-04-04 01:48:26 -0400 |
commit | 0d021ce388369f3f683f9c9c8d13b5c983b12ca3 (patch) | |
tree | dab67313491f4680ef0454f6396f6007d750511a /Assistant/Threads | |
parent | 8fb369aa5667f95d46b24f26b06636559155402b (diff) |
refactor alert button creation code
Diffstat (limited to 'Assistant/Threads')
-rw-r--r-- | Assistant/Threads/PairListener.hs | 12 | ||||
-rw-r--r-- | Assistant/Threads/Transferrer.hs | 1 | ||||
-rw-r--r-- | Assistant/Threads/XMPPClient.hs | 18 |
3 files changed, 11 insertions, 20 deletions
diff --git a/Assistant/Threads/PairListener.hs b/Assistant/Threads/PairListener.hs index 4459ee13c..cb9a94eff 100644 --- a/Assistant/Threads/PairListener.hs +++ b/Assistant/Threads/PairListener.hs @@ -11,7 +11,7 @@ import Assistant.Common import Assistant.Pairing import Assistant.Pairing.Network import Assistant.Pairing.MakeRemote -import Assistant.WebApp (UrlRenderer, renderUrl) +import Assistant.WebApp (UrlRenderer) import Assistant.WebApp.Types import Assistant.Alert import Assistant.DaemonStatus @@ -101,14 +101,8 @@ pairListenerThread urlrenderer = namedThread "PairListener" $ do pairReqReceived :: Bool -> UrlRenderer -> PairMsg -> Assistant () pairReqReceived True _ _ = noop -- ignore our own PairReq pairReqReceived False urlrenderer msg = do - url <- liftIO $ renderUrl urlrenderer (FinishLocalPairR msg) [] - closealert <- asIO1 removeAlert - void $ addAlert $ pairRequestReceivedAlert repo - AlertButton - { buttonUrl = url - , buttonLabel = T.pack "Respond" - , buttonAction = Just closealert - } + button <- mkAlertButton (T.pack "Respond") urlrenderer (FinishLocalPairR msg) + void $ addAlert $ pairRequestReceivedAlert repo button where repo = pairRepo msg diff --git a/Assistant/Threads/Transferrer.hs b/Assistant/Threads/Transferrer.hs index f2da99261..acbac6437 100644 --- a/Assistant/Threads/Transferrer.hs +++ b/Assistant/Threads/Transferrer.hs @@ -12,6 +12,7 @@ import Assistant.DaemonStatus import Assistant.TransferQueue import Assistant.TransferSlots import Assistant.Alert +import Assistant.Alert.Utility import Assistant.Commits import Assistant.Drop import Assistant.TransferrerPool diff --git a/Assistant/Threads/XMPPClient.hs b/Assistant/Threads/XMPPClient.hs index 8ccb241bb..6f15505fe 100644 --- a/Assistant/Threads/XMPPClient.hs +++ b/Assistant/Threads/XMPPClient.hs @@ -18,7 +18,7 @@ import Assistant.Sync import Assistant.DaemonStatus import qualified Remote import Utility.ThreadScheduler -import Assistant.WebApp (UrlRenderer, renderUrl) +import Assistant.WebApp (UrlRenderer) import Assistant.WebApp.Types hiding (liftAssistant) import Assistant.WebApp.Configurators.XMPP (checkCloudRepos) import Assistant.Alert @@ -281,16 +281,12 @@ pairMsgReceived urlrenderer PairReq theiruuid selfjid theirjid finishXMPPPairing theirjid theiruuid -- Show an alert to let the user decide if they want to pair. showalert = do - let route = ConfirmXMPPPairFriendR $ - PairKey theiruuid $ formatJID theirjid - url <- liftIO $ renderUrl urlrenderer route [] - close <- asIO1 removeAlert - void $ addAlert $ pairRequestReceivedAlert (T.unpack $ buddyName theirjid) - AlertButton - { buttonUrl = url - , buttonLabel = T.pack "Respond" - , buttonAction = Just close - } + button <- mkAlertButton (T.pack "Respond") urlrenderer $ + ConfirmXMPPPairFriendR $ + PairKey theiruuid $ formatJID theirjid + void $ addAlert $ pairRequestReceivedAlert + (T.unpack $ buddyName theirjid) + button pairMsgReceived _ PairAck theiruuid _selfjid theirjid = {- PairAck must come from one of the buddies we are pairing with; |