From dd2de93701cc2ee9350cac0e3751435425f7d98e Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 17 Apr 2017 16:30:22 -0400 Subject: minor cleanupd --- debug-me.hs | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'debug-me.hs') diff --git a/debug-me.hs b/debug-me.hs index 2625ecc..53ee545 100644 --- a/debug-me.hs +++ b/debug-me.hs @@ -87,9 +87,14 @@ sendTtyInput ichan devstate = go send b = do atomically $ do ds <- readTVar devstate + let ed = if lastActivity ds == lastSeen ds + then B.concat $ sentSince ds + else case reverse (sentSince ds) of + [] -> mempty + (lb:_) -> lb let entered = Entered { enteredData = Val b - , echoData = Val $ B.concat $ sentSince ds + , echoData = Val ed } let act = Activity (Proto entered) (Just $ lastActivity ds) dummySignature writeTChan ichan act @@ -153,10 +158,10 @@ isLegalSeen act@(Activity p (Just hp) sig) ds then (drop n ss, drop n es) else (mempty, mempty) in yes $ DeveloperState - { lastSeen = h + { lastSeen = acth , sentSince = ss' , enteredSince = es' - , lastActivity = h + , lastActivity = acth } -- Does it chain to something we've entered since the last Seen -- value? Eg, user sent A, we replied B C, and the user has @@ -173,19 +178,19 @@ isLegalSeen act@(Activity p (Just hp) sig) ds ss' = drop (i+1) ss es' = drop (i+1) es in yes $ DeveloperState - { lastSeen = h + { lastSeen = acth , sentSince = ss' , enteredSince = es' - , lastActivity = h + , lastActivity = acth } where - h = hash act + acth = hash act yes ds' = (True, ds') -- When they rejected a message we sent, anything we sent -- subsequently will also be rejected, so forget about it. yesrej = yes $ ds - { lastSeen = h - , lastActivity = h + { lastSeen = acth + , lastActivity = acth } isLegalSeen (Activity _ Nothing _) ds = (False, ds) @@ -288,7 +293,7 @@ truncateBacklog (Backlog (b :| l)) (Activity _ hp _) -- the current state of the system before manipulating it. -- -- To support typeahead on slow links, some echoData may be provided --- in the Entered activity. If the prevActivity points +-- in the Entered activity. If the Entered activity points -- to an older Seen activity, then the echoData must match the -- concatenation of all Seen activities after that one, up to the -- most recent Seen activity. -- cgit v1.2.3