more fixes
This commit is contained in:
parent
491dc6c569
commit
64ec9972be
|
@ -49,13 +49,12 @@ roomDataHandler ::
|
||||||
roomDataHandler = do
|
roomDataHandler = do
|
||||||
newRoomData <- parseBodyOrBadRequest
|
newRoomData <- parseBodyOrBadRequest
|
||||||
liftIO $ putStrLn "Got triggered from prosody"
|
liftIO $ putStrLn "Got triggered from prosody"
|
||||||
whenM (roomStateDiffers newRoomData) $ do
|
(openedRooms, closedRooms) <- setRoomDataState newRoomData
|
||||||
(openedRooms, closedRooms) <- setRoomDataState newRoomData
|
|
||||||
|
|
||||||
mapM_ notifyRoomOpend openedRooms
|
mapM_ notifyRoomOpend openedRooms
|
||||||
mapM_ notifyRoomClosed closedRooms
|
mapM_ notifyRoomClosed closedRooms
|
||||||
|
|
||||||
broadcastUserData
|
broadcastUserData
|
||||||
success
|
success
|
||||||
|
|
||||||
parseBodyOrBadRequest ::
|
parseBodyOrBadRequest ::
|
||||||
|
|
|
@ -26,16 +26,23 @@ class HasRoomsState a where
|
||||||
updateRoomState ::
|
updateRoomState ::
|
||||||
( HasRoomsState env,
|
( HasRoomsState env,
|
||||||
MonadIO m,
|
MonadIO m,
|
||||||
MonadReader env m
|
MonadReader env m,
|
||||||
|
MonadRoomDataStateRead m
|
||||||
) =>
|
) =>
|
||||||
RoomsData ->
|
RoomsData ->
|
||||||
m RoomsStateDiff
|
m RoomsStateDiff
|
||||||
updateRoomState newData = do
|
updateRoomState newData = do
|
||||||
state <- getRoomsState <$> ask
|
state <- getRoomsState <$> ask
|
||||||
liftIO $ putStrLn "Upating room state"
|
current <- getRoomDataState
|
||||||
diff <- updateGenericTVarStateWithQuery state roomStateDiff newData
|
if not $ eqIgnoreOrdering newData current
|
||||||
liftIO $ putStrLn "Done Upating room state"
|
then
|
||||||
return diff
|
( do
|
||||||
|
liftIO $ putStrLn "Upating room state"
|
||||||
|
diff <- updateGenericTVarStateWithQuery state roomStateDiff newData
|
||||||
|
liftIO $ putStrLn "Done Upating room state"
|
||||||
|
return diff
|
||||||
|
)
|
||||||
|
else return ([], [])
|
||||||
|
|
||||||
getRoomState ::
|
getRoomState ::
|
||||||
( HasRoomsState env,
|
( HasRoomsState env,
|
||||||
|
|
Loading…
Reference in a new issue