~singpolyma/cheogram

09626c55ef22c9b758f1d75d9f66fd44469a3754 — Stephen Paul Weber 6 years ago d43e6e8
Merge presences into old_presences

In case rejoin attempts happen without a sucessful join in the middle.
1 files changed, 6 insertions(+), 2 deletions(-)

M Main.hs
M Main.hs => Main.hs +6 -2
@@ 1155,8 1155,12 @@ roomPresences db toRoomPresences =
		void $ TC.runTCM $ TC.out db $ tcKey tel (muc from <> "\0presence")
	go (StartRejoin tel from) = do
		-- Copy current presences to a holding space so we can clear when rejoin is over
		presences <- fmap (fromMaybe "[]") $ TC.runTCM $ TC.get db $ tcKey tel (muc from <> "\0presence")
		True <- TC.runTCM $ TC.put db (tcKey tel (muc from <> "\0old_presence")) (presences :: String)
		presences <- (fromMaybe [] . (readZ =<<)) <$>
			(TC.runTCM $ TC.get db $ tcKey tel (muc from <> "\0presence"))
		old_presences <- (fromMaybe [] . (readZ =<<)) <$>
			(TC.runTCM $ TC.get db $ tcKey tel (muc from <> "\0old_presence"))
		True <- TC.runTCM $ TC.put db (tcKey tel (muc from <> "\0old_presence"))
			(show (presences <> old_presences :: [(String, Maybe String)]))
		void $ TC.runTCM $ TC.out db $ tcKey tel (muc from <> "\0presence")
	go (GetRoomPresences tel from rtrn) = do
		presences <- (fromMaybe [] . (readZ =<<)) <$>