A platform for community discussion. Free, open, simple.
FEATURE: Show topic visited state on search page (#15994)
Bianca Nenciu82a9109ae309
diff --git a/app/assets/javascripts/discourse/app/templates/components/search-result-entry.hbs b/app/assets/javascripts/discourse/app/templates/components/search-result-entry.hbsindex 3b23861cdb5..860cee9c3b2 100644--- a/app/assets/javascripts/discourse/app/templates/components/search-result-entry.hbs+++ b/app/assets/javascripts/discourse/app/templates/components/search-result-entry.hbs@@ -10,7 +10,7 @@{{track-selected selectedList=selected selectedId=post.topic class="bulk-select"}}{{/if}}- <a href={{post.url}} {{action "logClick" post.topic_id}} class="search-link" role="heading" aria-level="2">+ <a href={{post.url}} {{action "logClick" post.topic_id}} class="search-link{{if post.topic.visited " visited"}}" role="heading" aria-level="2">{{raw "topic-status" topic=post.topic showPrivateMessageIcon=true}}<span class="topic-title">{{#if post.useTopicTitleHeadline}}diff --git a/app/assets/javascripts/discourse/tests/acceptance/search-full-test.js b/app/assets/javascripts/discourse/tests/acceptance/search-full-test.jsindex 8efa99a8e50..8331ebec021 100644--- a/app/assets/javascripts/discourse/tests/acceptance/search-full-test.js+++ b/app/assets/javascripts/discourse/tests/acceptance/search-full-test.js@@ -558,4 +558,16 @@ acceptance("Search - Full Page", function (needs) {await click(".topic-bulk-actions-modal .btn:nth-child(2)"); // close topicsassert.equal(lastBody["topic_ids[]"], 7);});++ test("adds visited class to visited topics", async function (assert) {+ await visit("/search");++ await fillIn(".search-query", "discourse");+ await click(".search-cta");+ assert.equal(queryAll(".visited").length, 0);++ await fillIn(".search-query", "discourse visited");+ await click(".search-cta");+ assert.equal(queryAll(".visited").length, 1);+ });});diff --git a/app/assets/javascripts/discourse/tests/helpers/create-pretender.js b/app/assets/javascripts/discourse/tests/helpers/create-pretender.jsindex 288fcb787dd..00beaebec5d 100644--- a/app/assets/javascripts/discourse/tests/helpers/create-pretender.js+++ b/app/assets/javascripts/discourse/tests/helpers/create-pretender.js@@ -254,10 +254,14 @@ export function applyDefaultHandlers(pretender) {pretender.get("/search", (request) => {if (request.queryParams.q === "discourse") {return response(fixturesByUrl["/search.json"]);+ } else if (request.queryParams.q === "discourse visited") {+ const obj = JSON.parse(JSON.stringify(fixturesByUrl["/search.json"]));+ obj.topics.firstObject.visited = true;+ return response(obj);} else if (request.queryParams.q === "discourse in:personal") {- const fixtures = fixturesByUrl["/search.json"];- fixtures.topics.firstObject.archetype = "private_message";- return response(fixtures);+ const obj = JSON.parse(JSON.stringify(fixturesByUrl["/search.json"]));+ obj.topics.firstObject.archetype = "private_message";+ return response(obj);} else {return response({});}diff --git a/app/assets/stylesheets/common/base/search.scss b/app/assets/stylesheets/common/base/search.scssindex 6edced0927f..ccf4cc6805f 100644--- a/app/assets/stylesheets/common/base/search.scss+++ b/app/assets/stylesheets/common/base/search.scss@@ -329,7 +329,7 @@}}- a.search-link:visited .topic-title {+ a.search-link.visited .topic-title {color: var(--primary-medium);}.search-link {