Skip to content

Commit

Permalink
Bug 1766040 - Clickable save for STP refresh r=thecount
Browse files Browse the repository at this point in the history
  • Loading branch information
gvn committed May 2, 2022
1 parent a2bc68d commit ab81ffd
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,15 @@ function Article(props) {
: null;
}

const { article, savedArticle, position, source, model, utmParams } = props;
const {
article,
savedArticle,
position,
source,
model,
utmParams,
openInPocketReader,
} = props;
const url = new URL(article.url || article.resolved_url || "");
const urlSearchParams = new URLSearchParams(utmParams);
for (let [key, val] of urlSearchParams.entries()) {
Expand All @@ -51,10 +59,21 @@ function Article(props) {
article.publisher ||
article.domain_metadata?.name ||
article.resolved_domain;

let constructedURL = url.href;

if (
openInPocketReader &&
article.item_id &&
!url.href.match(/getpocket\.com\/read/)
) {
constructedURL = `https://getpocket.com/read/${article.item_id}`;
}

return (
<li className="stp_article_list_item">
<ArticleUrl
url={url.href}
url={constructedURL}
savedArticle={savedArticle}
position={position}
source={source}
Expand Down Expand Up @@ -94,6 +113,7 @@ function ArticleList(props) {
source={props.source}
model={props.model}
utmParams={props.utmParams}
openInPocketReader={props.openInPocketReader}
/>
))}
</ul>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ function Home(props) {
articles={articles.slice(0, 3)}
source="home_recent_save"
utmParams={utmParams}
openInPocketReader={true}
/>
<span className="stp_button_wide">
<Button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ function Saved(props) {
</Button>
</h3>
{savedStory && (
<ArticleList articles={[savedStory]} savedArticle={true} />
<ArticleList articles={[savedStory]} openInPocketReader={true} />
)}
<TagPicker tags={[]} itemUrl={itemUrl} />
{similarRecs?.length && locale?.startsWith("en") && (
Expand Down
19 changes: 14 additions & 5 deletions browser/components/pocket/content/panels/js/main.bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ function Article(props) {
position,
source,
model,
utmParams
utmParams,
openInPocketReader
} = props;
const url = new URL(article.url || article.resolved_url || "");
const urlSearchParams = new URLSearchParams(utmParams);
Expand All @@ -183,10 +184,16 @@ function Article(props) {
const title = article.title || article.resolved_title; // Sometimes domain_metadata is not there, depending on the source.

const publisher = article.publisher || article.domain_metadata?.name || article.resolved_domain;
let constructedURL = url.href;

if (openInPocketReader && article.item_id && !url.href.match(/getpocket\.com\/read/)) {
constructedURL = `https://getpocket.com/read/${article.item_id}`;
}

return /*#__PURE__*/react.createElement("li", {
className: "stp_article_list_item"
}, /*#__PURE__*/react.createElement(ArticleUrl, {
url: url.href,
url: constructedURL,
savedArticle: savedArticle,
position: position,
source: source,
Expand Down Expand Up @@ -218,7 +225,8 @@ function ArticleList(props) {
position: position,
source: props.source,
model: props.model,
utmParams: props.utmParams
utmParams: props.utmParams,
openInPocketReader: props.openInPocketReader
})));
}

Expand Down Expand Up @@ -344,7 +352,8 @@ function Home(props) {
}), articles.length > 3 ? /*#__PURE__*/react.createElement(react.Fragment, null, /*#__PURE__*/react.createElement(ArticleList_ArticleList, {
articles: articles.slice(0, 3),
source: "home_recent_save",
utmParams: utmParams
utmParams: utmParams,
openInPocketReader: true
}), /*#__PURE__*/react.createElement("span", {
className: "stp_button_wide"
}, /*#__PURE__*/react.createElement(Button_Button, {
Expand Down Expand Up @@ -999,7 +1008,7 @@ function Saved(props) {
"data-l10n-id": "pocket-panel-button-remove"
}))), savedStory && /*#__PURE__*/react.createElement(ArticleList_ArticleList, {
articles: [savedStory],
savedArticle: true
openInPocketReader: true
}), /*#__PURE__*/react.createElement(TagPicker_TagPicker, {
tags: [],
itemUrl: itemUrl
Expand Down

0 comments on commit ab81ffd

Please sign in to comment.