瀏覽代碼

Remove all direct calls to query method

jherve 1 年之前
父節點
當前提交
3910cce089
共有 1 個文件被更改,包括 7 次插入14 次删除
  1. 7 14
      src/LinkedIn/UI/Components/JobsUnifiedTopCard.purs

+ 7 - 14
src/LinkedIn/UI/Components/JobsUnifiedTopCard.purs

@@ -11,9 +11,9 @@ import Data.Lens.Record (prop)
 import Data.List.Types (NonEmptyList)
 import Data.List.Types (NonEmptyList)
 import Data.Maybe (Maybe(..))
 import Data.Maybe (Maybe(..))
 import Data.Show.Generic (genericShow)
 import Data.Show.Generic (genericShow)
-import Data.Traversable (class Traversable, sequence, traverse, traverseDefault)
+import Data.Traversable (class Traversable, sequence, traverseDefault)
 import Data.Tuple (Tuple(..))
 import Data.Tuple (Tuple(..))
-import LinkedIn.CanBeQueried (class CanBeQueried, query)
+import LinkedIn.CanBeQueried (class CanBeQueried, subQueryMany, subQueryOne)
 import LinkedIn.QueryRunner (QueryError(..), ignoreNotFound, queryAll, queryOne, querySelf, queryText)
 import LinkedIn.QueryRunner (QueryError(..), ignoreNotFound, queryAll, queryOne, querySelf, queryText)
 import LinkedIn.Queryable (class Queryable, toNode)
 import LinkedIn.Queryable (class Queryable, toNode)
 import Type.Proxy (Proxy(..))
 import Type.Proxy (Proxy(..))
@@ -83,12 +83,9 @@ traverseMayNel Nothing = pure Nothing
 instance Queryable q => CanBeQueried q JobsUnifiedTopCardElement where
 instance Queryable q => CanBeQueried q JobsUnifiedTopCardElement where
   query n = do
   query n = do
     header <- queryOne "h1.job-details-jobs-unified-top-card__job-title" n
     header <- queryOne "h1.job-details-jobs-unified-top-card__job-title" n
-    primaryDescription <- query
-                            =<< queryOne "div.job-details-jobs-unified-top-card__primary-description-container > div" n
-    insights <- ignoreNotFound
-                  <<< traverse query
-                  =<< queryAll "li.job-details-jobs-unified-top-card__job-insight" n
-    actions <- ignoreNotFound <<< traverse query =<< queryAll ".mt5 button" n
+    primaryDescription <- subQueryOne "div.job-details-jobs-unified-top-card__primary-description-container > div" n
+    insights <- ignoreNotFound $ subQueryMany "li.job-details-jobs-unified-top-card__job-insight" n
+    actions <- ignoreNotFound $ subQueryMany ".mt5 button" n
 
 
     pure $ JobsUnifiedTopCardElement {
     pure $ JobsUnifiedTopCardElement {
       header,
       header,
@@ -149,13 +146,10 @@ instance Traversable TopCardInsight where
 instance Queryable q => CanBeQueried q TopCardInsight where
 instance Queryable q => CanBeQueried q TopCardInsight where
   query n = do
   query n = do
     icon <- queryOne ":scope li-icon" n <|> queryOne ":scope svg" n
     icon <- queryOne ":scope li-icon" n <|> queryOne ":scope svg" n
-    content <- query =<< getContentNode n
+    content <- subQueryOne ":scope > span" n <|> subQueryOne ":scope > button" n
 
 
     pure $ TopCardInsight {icon, content}
     pure $ TopCardInsight {icon, content}
 
 
-    where
-      getContentNode n' = queryOne ":scope > span" n' <|> queryOne ":scope > button" n'
-
 derive instance Generic (TopCardInsightContent a) _
 derive instance Generic (TopCardInsightContent a) _
 derive instance Eq a => Eq (TopCardInsightContent a)
 derive instance Eq a => Eq (TopCardInsightContent a)
 instance Show a => Show (TopCardInsightContent a) where
 instance Show a => Show (TopCardInsightContent a) where
@@ -202,8 +196,7 @@ instance Queryable q => CanBeQueried q TopCardInsightContent where
 
 
       queryTopCardInsightContentSecondary n = do
       queryTopCardInsightContentSecondary n = do
         primary <- queryOne ":scope > span:first-child span[aria-hidden=true]" n
         primary <- queryOne ":scope > span:first-child span[aria-hidden=true]" n
-        secondary <- traverse query
-                      =<< queryAll ":scope > span.job-details-jobs-unified-top-card__job-insight-view-model-secondary" n
+        secondary <- subQueryMany ":scope > span.job-details-jobs-unified-top-card__job-insight-view-model-secondary" n
         pure $ TopCardInsightContentSecondary {primary, secondary}
         pure $ TopCardInsightContentSecondary {primary, secondary}
 
 
 derive instance Generic (TopCardSecondaryInsight a) _
 derive instance Generic (TopCardSecondaryInsight a) _