{
// 2. Show the featured story next
// 3. Podcast episodes out today
// 4. Rest of the stories for the feed
+ // For "saveable", "!=" is used instead of "!==" to compare user_id
+ // and currentUserId because currentUserId is a String while user_id is an Integer
return (
{timeFrame === '' && pinnedArticle && (
@@ -101,6 +107,7 @@ export const renderFeed = (timeFrame) => {
pinned={true}
feedStyle={feedStyle}
isBookmarked={bookmarkedFeedItems.has(pinnedArticle.id)}
+ saveable={pinnedArticle.user_id != currentUserId}
/>
)}
{featuredStory && (
@@ -110,6 +117,7 @@ export const renderFeed = (timeFrame) => {
isFeatured
feedStyle={feedStyle}
isBookmarked={bookmarkedFeedItems.has(featuredStory.id)}
+ saveable={featuredStory.user_id != currentUserId}
/>
)}
{podcastEpisodes.length > 0 && (
@@ -122,6 +130,7 @@ export const renderFeed = (timeFrame) => {
article={story}
feedStyle={feedStyle}
isBookmarked={bookmarkedFeedItems.has(story.id)}
+ saveable={story.user_id != currentUserId}
/>
))}
diff --git a/app/javascript/packs/searchParams.js b/app/javascript/packs/searchParams.js
index 78e955325..4a6a9b006 100644
--- a/app/javascript/packs/searchParams.js
+++ b/app/javascript/packs/searchParams.js
@@ -185,8 +185,10 @@ function search(query, filters, sortBy, sortDirection) {
.then((response) => response.json())
.then((content) => {
const resultDivs = [];
+ const currentUser = userData();
+ const currentUserId = currentUser && currentUser.id;
content.result.forEach((story) => {
- resultDivs.push(buildArticleHTML(story));
+ resultDivs.push(buildArticleHTML(story, currentUserId));
});
document.getElementById('substories').innerHTML = resultDivs.join('');
initializeReadingListIcons();
diff --git a/app/views/articles/_single_story.html.erb b/app/views/articles/_single_story.html.erb
index c69b31f8d..c90711183 100644
--- a/app/views/articles/_single_story.html.erb
+++ b/app/views/articles/_single_story.html.erb
@@ -147,7 +147,14 @@
<%= t("views.articles.reading_time", count: story.reading_time < 1 ? 1 : story.reading_time) %>
-