diff --git a/ducks/articleList.js b/ducks/articleList.js
index 365f17fe..95363bd5 100644
--- a/ducks/articleList.js
+++ b/ducks/articleList.js
@@ -23,13 +23,19 @@ let isInCooldown = false;
let lastStringifiedFilter;
export const load = ({
q,
+ searchUserByArticleId,
filter = 'unsolved',
replyRequestCount = 2,
orderBy = 'createdAt',
before,
after,
}) => dispatch => {
- const filterObject = getFilterObject(filter, q, replyRequestCount);
+ const filterObject = getFilterObject(
+ filter,
+ q,
+ replyRequestCount,
+ searchUserByArticleId
+ );
const stringifiedFilter = JSON.stringify(filterObject);
if (lastStringifiedFilter !== stringifiedFilter) {
@@ -207,7 +213,7 @@ function resetCooldown() {
isInCooldown = false;
}
-function getFilterObject(filter, q, replyRequestCount) {
+function getFilterObject(filter, q, replyRequestCount, searchUserByArticleId) {
const filterObj = {};
if (q) {
filterObj.moreLikeThis = { like: q, minimumShouldMatch: '0' };
@@ -223,6 +229,10 @@ function getFilterObject(filter, q, replyRequestCount) {
filterObj.replyCount = { EQ: 0 };
}
+ if (searchUserByArticleId) {
+ filterObj.fromUserOfArticleId = searchUserByArticleId;
+ }
+
// Return filterObj only when it is populated.
if (!Object.keys(filterObj).length) {
return undefined;
diff --git a/pages/index.js b/pages/index.js
index 8217e6ac..e197fbf9 100644
--- a/pages/index.js
+++ b/pages/index.js
@@ -94,6 +94,29 @@ class Index extends ListPage {
);
};
+ renderDescriptionOfSearchedArticle = () => {
+ const { query: { searchUserByArticleId }, articles } = this.props;
+ const searchedArticle = articles.find(
+ article => article.get('id') === searchUserByArticleId
+ );
+ return (
+
+ 與{searchedArticle ? searchedArticle.get('text') : ''}{' '}
+ 此篇文章相同回報者的列表
+
+
+ );
+ };
+
renderOrderBy = () => {
const { query: { orderBy, q } } = this.props;
if (q) {
@@ -207,7 +230,10 @@ class Index extends ListPage {
};
render() {
- const { isLoading = false, query: { replyRequestCount } } = this.props;
+ const {
+ isLoading = false,
+ query: { replyRequestCount, searchUserByArticleId },
+ } = this.props;
return (
@@ -215,6 +241,9 @@ class Index extends ListPage {
Cofacts 真的假的 - 轉傳訊息查證
文章列表
+
+ {searchUserByArticleId && this.renderDescriptionOfSearchedArticle()}
+
{this.renderSearch()}
Order By: