Skip to content

Commit

Permalink
Merge pull request #1777 from digitallyinduced/s0kil/fix-issue-1776
Browse files Browse the repository at this point in the history
SSC do not encode nullary constructors to string
  • Loading branch information
mpscholten authored Jul 27, 2023
2 parents 217c1aa + df56843 commit 05f52bb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion IHP/ServerSideComponent/Controller/ComponentsController.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import IHP.ServerSideComponent.Types as SSC
import IHP.ServerSideComponent.ControllerFunctions as SSC

import qualified Data.Aeson as Aeson
import qualified IHP.Log as Log

instance (Component component controller, FromJSON controller) => WSApp (ComponentsController component) where
initialState = ComponentsController
Expand All @@ -29,4 +30,7 @@ instance (Component component controller, FromJSON controller) => WSApp (Compone

nextState <- SSC.action currentState theAction
SSC.setState nextState
Left error -> putStrLn (cs error)
Left error -> do
Log.error ("Failed Parsing Server Side Component Message As JSON" :: Text)
Log.error actionPayload
Log.error error
2 changes: 1 addition & 1 deletion IHP/ServerSideComponent/ControllerFunctions.hs
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ setState state = do
getState :: _ => _
getState = (.state) <$> readIORef ?instanceRef

deriveSSC = Aeson.deriveJSON Aeson.defaultOptions { sumEncoding = defaultTaggedObject { tagFieldName = "action", contentsFieldName = "payload" }}
deriveSSC = Aeson.deriveJSON Aeson.defaultOptions { allNullaryToStringTag = False, sumEncoding = defaultTaggedObject { tagFieldName = "action", contentsFieldName = "payload" }}

0 comments on commit 05f52bb

Please sign in to comment.