aboutsummaryrefslogtreecommitdiff
path: root/Assistant/Alert.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-03-18 16:19:42 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-03-18 17:23:47 -0400
commitaa26294c303846f4022a8750a148863646c9fdde (patch)
tree44d3a64c1c3c964f0bca5b56b03df53269f8fed0 /Assistant/Alert.hs
parent4d035de8f4618e1c31c837b151b7ffeced20cd3d (diff)
webapp: Improved alerts displayed when syncing with remotes, and when syncing with a remote fails.
Diffstat (limited to 'Assistant/Alert.hs')
-rw-r--r--Assistant/Alert.hs31
1 files changed, 17 insertions, 14 deletions
diff --git a/Assistant/Alert.hs b/Assistant/Alert.hs
index 4e733428a..54ac750e9 100644
--- a/Assistant/Alert.hs
+++ b/Assistant/Alert.hs
@@ -35,6 +35,7 @@ data AlertName
| PairAlert String
| XMPPNeededAlert
| CloudRepoNeededAlert
+ | SyncAlert
deriving (Eq)
{- The first alert is the new alert, the second is an old alert.
@@ -239,26 +240,28 @@ commitAlert = activityAlert Nothing
showRemotes :: [Remote] -> TenseChunk
showRemotes = UnTensed . T.unwords . map (T.pack . Remote.name)
-pushRetryAlert :: [Remote] -> Alert
-pushRetryAlert rs = activityAlert
- (Just $ tenseWords [Tensed "Retrying" "Retried", "sync"])
- ["with", showRemotes rs]
-
syncAlert :: [Remote] -> Alert
syncAlert rs = baseActivityAlert
- { alertHeader = Just $ tenseWords
+ { alertName = Just SyncAlert
+ , alertHeader = Just $ tenseWords
[Tensed "Syncing" "Synced", "with", showRemotes rs]
- , alertData = []
, alertPriority = Low
}
-scanAlert :: [Remote] -> Alert
-scanAlert rs = baseActivityAlert
- { alertHeader = Just $ tenseWords
- [Tensed "Scanning" "Scanned", showRemotes rs]
- , alertBlockDisplay = True
- , alertPriority = Low
- }
+syncResultAlert :: [Remote] -> [Remote] -> Alert
+syncResultAlert succeeded failed = makeAlertFiller (not $ null succeeded) $
+ baseActivityAlert
+ { alertName = Just SyncAlert
+ , alertHeader = Just $ tenseWords msg
+ }
+ where
+ msg
+ | null succeeded = ["Failed to sync with", showRemotes failed]
+ | null failed = ["Synced with", showRemotes succeeded]
+ | otherwise =
+ [ "Synced with", showRemotes succeeded
+ , "but not with", showRemotes failed
+ ]
sanityCheckAlert :: Alert
sanityCheckAlert = activityAlert