more fixes

This commit is contained in:
qvalentin 2025-01-25 18:37:03 +01:00
parent 491dc6c569
commit 64ec9972be
2 changed files with 16 additions and 10 deletions

View file

@ -49,7 +49,6 @@ 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

View file

@ -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
current <- getRoomDataState
if not $ eqIgnoreOrdering newData current
then
( do
liftIO $ putStrLn "Upating room state" liftIO $ putStrLn "Upating room state"
diff <- updateGenericTVarStateWithQuery state roomStateDiff newData diff <- updateGenericTVarStateWithQuery state roomStateDiff newData
liftIO $ putStrLn "Done Upating room state" liftIO $ putStrLn "Done Upating room state"
return diff return diff
)
else return ([], [])
getRoomState :: getRoomState ::
( HasRoomsState env, ( HasRoomsState env,