Skip to content

Commit 9c9b123

Browse files
committed
Restore sections
1 parent f8c3ba4 commit 9c9b123

File tree

4 files changed

+27
-19
lines changed

4 files changed

+27
-19
lines changed

src/Client/Experiments/Update.purs

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ update model =
2727
model
2828
{ current = Just code
2929
} /\ dispatchEvent (Just code)
30-
-- ToggleSection section → F.noMessages $ model { section = section }
30+
ToggleSection section → F.noMessages $ model { section = section }
3131
-- ConfirmImpersonation profile → F.noMessages model { impersonation = profile }
3232
RedirectKarma → model /\
3333
[ do

src/Server/Experiments/Template.purs

+1
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@ template payload = F.preMount (QuerySelector ".chat-experiments")
1414
{ experiments: payload.experiments
1515
, current: Nothing
1616
, user: payload.user
17+
, section: HideSections
1718
}
1819
}

src/Shared/Experiments/Impersonation.purs

+4-17
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ module Shared.Experiments.Impersonation where
22

33
import Prelude
44
import Shared.Availability
5-
import Shared.Experiments.Types
65
import Shared.User
6+
import Shared.Experiments.Types
77

88
import Client.Common.Privilege as CCP
99
import Data.Argonaut (class DecodeJson, class EncodeJson)
@@ -40,29 +40,16 @@ data ExperimentPayload = ImpersonationPayload
4040
, sender Boolean
4141
}
4242

43-
data ImpersonationSection
44-
= HideSections
45-
| Characters
46-
| HistoricalFigures
47-
| Celebrities
4843

49-
derive instance Generic ImpersonationSection _
5044

5145
derive instance Generic ExperimentPayload _
5246

53-
derive instance Eq ImpersonationSection
54-
5547
instance EncodeJson ExperimentPayload where
5648
encodeJson = DAEGR.genericEncodeJson
5749

58-
instance EncodeJson ImpersonationSection where
59-
encodeJson = DAEGR.genericEncodeJson
60-
6150
instance DecodeJson ExperimentPayload where
6251
decodeJson = DADGR.genericDecodeJson
6352

64-
instance DecodeJson ImpersonationSection where
65-
decodeJson = DADGR.genericDecodeJson
6653

6754
instance Show ExperimentPayload where
6855
show = DGRS.genericShow
@@ -102,12 +89,12 @@ view model = HE.div (HA.class' "impersonation")
10289
]
10390
]
10491
where
105-
header s name = HE.div [ HA.class' "impersonation-header" ] --, HA.onClick $ ToggleSection s ]
92+
header s name = HE.div [ HA.class' "impersonation-header", HA.onClick $ ToggleSection s ]
10693
[ HE.text name
107-
, HE.span (HA.class' "header-plus") "+" -- $ if section == s then "-" else "+"
94+
, HE.span (HA.class' "header-plus") if model.section == s then "-" else "+"
10895
]
10996

110-
profiles s = HE.div (HA.class' { hidden: s /= s }) <<< DA.mapWithIndex toProfile -- (HA.class' { hidden: section /= s }) <<< DA.mapWithIndex toProfile
97+
profiles s = HE.div (HA.class' { hidden: model.section /= s }) <<< DA.mapWithIndex toProfile
11198
toProfile index p = HE.div [ HA.class' "contact" ] --, HA.onClick <<< ConfirmImpersonation $ Just p ]
11299
[ HE.div (HA.class' "avatar-contact-list-div")
113100
[ HE.img [ HA.title $ SU.fromJust p.avatar, HA.class' $ "avatar-contact-list" <> SA.avatarColorClass (Just index), HA.src $ SU.fromJust p.avatar ]

src/Shared/Experiments/Types.purs

+21-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import Data.Maybe (Maybe(..))
1313
import Droplet.Language (class FromValue, class ToValue)
1414
import Droplet.Language as DL
1515
import Foreign as F
16+
1617
import Shared.Privilege (Privilege)
1718
import Shared.Unsafe as SU
1819
import Simple.JSON (class ReadForeign, class WriteForeign)
@@ -30,18 +31,29 @@ data ChatExperimentMessage
3031
= QuitExperiment
3132
| JoinExperiment ChatExperiment
3233
| RedirectKarma
34+
| ToggleSection ImpersonationSection
3335
| UpdatePrivileges { karma Int, privileges Array Privilege }
3436

3537
type ChatExperimentModel =
3638
{ experiments Array ChatExperiment
3739
, current Maybe ChatExperiment
3840
, user ChatExperimentUser
41+
--impersonation
42+
, section ImpersonationSection
3943
}
4044

4145
data Experiment = Impersonation | WordChain
4246

47+
data ImpersonationSection
48+
= HideSections
49+
| Characters
50+
| HistoricalFigures
51+
| Celebrities
52+
4353
derive instance Eq Experiment
4454

55+
derive instance Eq ImpersonationSection
56+
4557
derive instance Ord Experiment
4658

4759
instance Bounded Experiment where
@@ -84,4 +96,12 @@ instance ToValue Experiment where
8496
toValue = F.unsafeToForeign <<< DE.fromEnum
8597

8698
instance FromValue Experiment where
87-
fromValue v = map (SU.fromJust <<< DE.toEnum) (DL.fromValue v Either String Int)
99+
fromValue v = map (SU.fromJust <<< DE.toEnum) (DL.fromValue v Either String Int)
100+
101+
derive instance Generic ImpersonationSection _
102+
103+
instance EncodeJson ImpersonationSection where
104+
encodeJson = DAEGR.genericEncodeJson
105+
106+
instance DecodeJson ImpersonationSection where
107+
decodeJson = DADGR.genericDecodeJson

0 commit comments

Comments
 (0)