Explorar o código

ArtdecoHeader "light" is now a list

jherve hai 1 ano
pai
achega
bd3e49b071

+ 2 - 2
src/LinkedIn/Profile/WorkExperience.purs

@@ -39,8 +39,8 @@ fromUI card = ado
     position,
     company: extractCompany =<< normal,
     contractType: extractContractType =<< normal,
-    timeSpan: findMap extractTimeSpan =<< light,
-    duration: findMap extractDuration =<< light,
+    timeSpan: findMap extractTimeSpan light,
+    duration: findMap extractDuration light,
     description: extractDescription =<< L.index content 0
   }
   where

+ 9 - 9
src/LinkedIn/UI/Components/ArtDeco.purs

@@ -6,13 +6,14 @@ import Data.Foldable (class Foldable, foldMap, foldlDefault, foldrDefault)
 import Data.Generic.Rep (class Generic)
 import Data.Lens (Lens', Traversal', lens', traversed)
 import Data.Lens.Record (prop)
+import Data.List (List)
 import Data.List.NonEmpty (NonEmptyList)
 import Data.Maybe (Maybe)
 import Data.Show.Generic (genericShow)
 import Data.Traversable (class Traversable, sequence, traverseDefault)
 import Data.Tuple (Tuple(..))
 import LinkedIn.CanBeQueried (class CanBeQueried, subQueryMany, subQueryOne)
-import LinkedIn.QueryRunner (ignoreNotFound, queryAll, queryOne)
+import LinkedIn.QueryRunner (ignoreNotFound, queryAll', queryOne)
 import LinkedIn.Queryable (class Queryable)
 import Type.Proxy (Proxy(..))
 
@@ -30,7 +31,7 @@ data ArtDecoCenter a = ArtDecoCenter {
 data ArtDecoCenterHeader a = ArtDecoCenterHeader {
   bold :: a,
   normal :: Maybe a,
-  light :: Maybe (NonEmptyList a)
+  light :: List a
 }
 
 data ArtDecoCenterContent a = ArtDecoCenterContent (NonEmptyList (ArtDecoPvsEntitySubComponent a))
@@ -93,7 +94,7 @@ instance Show a => Show(ArtDecoCenterHeader a) where
 derive instance Functor ArtDecoCenterHeader
 
 instance Foldable ArtDecoCenterHeader where
-  foldMap f (ArtDecoCenterHeader {bold, normal, light}) = f bold <> foldMap f normal <> foldMap (foldMap f) light
+  foldMap f (ArtDecoCenterHeader {bold, normal, light}) = f bold <> foldMap f normal <> foldMap f light
 
   foldl = \x -> foldlDefault x
   foldr = \x -> foldrDefault x
@@ -102,7 +103,7 @@ instance Traversable ArtDecoCenterHeader where
   sequence (ArtDecoCenterHeader {bold, normal, light}) = ado
     b <- bold
     n <- sequence normal
-    l <- sequence (map sequence light)
+    l <- sequence light
   in ArtDecoCenterHeader {bold: b, normal: n, light: l}
 
   traverse = \x -> traverseDefault x
@@ -114,8 +115,7 @@ instance Queryable q => CanBeQueried q ArtDecoCenterHeader where
       ignoreNotFound $
       queryOne ":scope span.t-normal:not(t-black--light) > span[aria-hidden=true]" n
     light <-
-      ignoreNotFound $
-      queryAll ":scope span.t-black--light > span[aria-hidden=true]" n
+      queryAll' ":scope span.t-black--light > span[aria-hidden=true]" n
 
     pure $ ArtDecoCenterHeader {bold, normal, light}
 
@@ -179,7 +179,7 @@ _center :: forall a. Lens' (ArtDecoCenter a) { content ∷ ArtDecoCenterContent
 _center = lens'
   \(ArtDecoCenter center) -> Tuple center \center' -> ArtDecoCenter center'
 
-_header :: forall a. Lens' (ArtDecoCenterHeader a) { bold ∷ a , light ∷ Maybe (NonEmptyList a) , normal ∷ Maybe a }
+_header :: forall a. Lens' (ArtDecoCenterHeader a) { bold ∷ a , light ∷ List a , normal ∷ Maybe a }
 _header = lens' \(ArtDecoCenterHeader h) -> Tuple h \h' -> ArtDecoCenterHeader h'
 
 _content :: forall a. Lens' (ArtDecoCenterContent a) (NonEmptyList (ArtDecoPvsEntitySubComponent a))
@@ -188,7 +188,7 @@ _content = lens' \(ArtDecoCenterContent cs) -> Tuple cs \cs' -> ArtDecoCenterCon
 _sub_component :: forall a. Lens' (ArtDecoPvsEntitySubComponent a) a
 _sub_component = lens' \(ArtDecoPvsEntitySubComponent s) -> Tuple s \s' -> ArtDecoPvsEntitySubComponent s'
 
-_pvs_to_header :: forall a. Lens' (ArtDecoPvsEntity a) { bold ∷ a , light ∷ Maybe (NonEmptyList a) , normal ∷ Maybe a }
+_pvs_to_header :: forall a. Lens' (ArtDecoPvsEntity a) { bold ∷ a , light ∷ List a , normal ∷ Maybe a }
 _pvs_to_header = _pvs_entity
   <<< prop (Proxy :: Proxy "center")
   <<< _center
@@ -210,5 +210,5 @@ _pvs_to_header_bold = _pvs_to_header <<< prop (Proxy :: Proxy "bold")
 _pvs_to_header_normal :: forall a. Lens' (ArtDecoPvsEntity a) (Maybe a)
 _pvs_to_header_normal = _pvs_to_header <<< prop (Proxy :: Proxy "normal")
 
-_pvs_to_header_light :: forall a. Lens' (ArtDecoPvsEntity a) (Maybe (NonEmptyList a))
+_pvs_to_header_light :: forall a. Lens' (ArtDecoPvsEntity a) (List a)
 _pvs_to_header_light = _pvs_to_header <<< prop (Proxy :: Proxy "light")

+ 1 - 2
src/LinkedIn/UI/Components/ArtDecoCard.purs

@@ -7,7 +7,6 @@ import Data.Generic.Rep (class Generic)
 import Data.Lens (Lens', lens', toListOf, view)
 import Data.Lens.Record (prop)
 import Data.List (List)
-import Data.List.Types (NonEmptyList)
 import Data.Maybe (Maybe)
 import Data.Show.Generic (genericShow)
 import Data.Traversable (class Traversable, sequence, traverseDefault)
@@ -52,7 +51,7 @@ toHeaderBold = view $ _card_to_pvs_entity <<< _pvs_to_header_bold
 toHeaderNormal ∷ ∀ a. ArtDecoCardElement a → Maybe a
 toHeaderNormal = view $ _card_to_pvs_entity <<< _pvs_to_header_normal
 
-toHeaderLight ∷ ∀ a. ArtDecoCardElement a → Maybe (NonEmptyList a)
+toHeaderLight ∷ ∀ a. ArtDecoCardElement a → List a
 toHeaderLight = view $ _card_to_pvs_entity <<< _pvs_to_header_light
 
 toCenterContent ∷ ∀ a. ArtDecoCardElement a → List a

+ 1 - 2
src/LinkedIn/UI/Components/ArtDecoTab.purs

@@ -7,7 +7,6 @@ import Data.Generic.Rep (class Generic)
 import Data.Lens (Lens', lens', toListOf, view)
 import Data.Lens.Record (prop)
 import Data.List (List)
-import Data.List.Types (NonEmptyList)
 import Data.Maybe (Maybe)
 import Data.Show.Generic (genericShow)
 import Data.Traversable (class Traversable, sequence, traverseDefault)
@@ -52,7 +51,7 @@ toHeaderBold = view $ _tab_to_pvs_entity <<< _pvs_to_header_bold
 toHeaderNormal ∷ ∀ a. ArtDecoTabElement a → Maybe a
 toHeaderNormal = view $ _tab_to_pvs_entity <<< _pvs_to_header_normal
 
-toHeaderLight ∷ ∀ a. ArtDecoTabElement a → Maybe (NonEmptyList a)
+toHeaderLight ∷ ∀ a. ArtDecoTabElement a → List a
 toHeaderLight = view $ _tab_to_pvs_entity <<< _pvs_to_header_light
 
 toCenterContent ∷ ∀ a. ArtDecoTabElement a → List a

+ 4 - 4
test/ArtDecoCard.purs

@@ -36,10 +36,10 @@ andrewNgWorkExperience = {
         ))),
         header: (ArtDecoCenterHeader {
           bold: (DetachedElement {classes: Nil, content: "Founder", id: Nothing, tag: "SPAN" }),
-          light: (Just (NonEmptyList (NonEmpty (
-            DetachedElement {classes: ("pvs-entity__caption-wrapper" : Nil), content: "juin 2017 - aujourd’hui · 6 ans 9 mois", id: Nothing,tag: "SPAN"})
-            ((DetachedElement {classes: Nil, content: "Palo Alto, California, United States", id: Nothing,tag: "SPAN"}) : Nil)
-          ))),
+          light:
+            DetachedElement {classes: ("pvs-entity__caption-wrapper" : Nil), content: "juin 2017 - aujourd’hui · 6 ans 9 mois", id: Nothing,tag: "SPAN"}
+            : DetachedElement {classes: Nil, content: "Palo Alto, California, United States", id: Nothing,tag: "SPAN"}
+            : Nil,
           normal: (Just (DetachedElement {classes: Nil, content: "DeepLearning.AI", id: Nothing, tag: "SPAN" }))
         })
       }),