From a6960f3f14758945f106ee7f3f778137318687db Mon Sep 17 00:00:00 2001 From: Mohammed Abdoon Date: Sun, 28 Jun 2026 04:41:00 +0100 Subject: [PATCH] fixed hashtag so it no longer slows the page because of rendering loop --- front-end/views/hashtag.mjs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/front-end/views/hashtag.mjs b/front-end/views/hashtag.mjs index 7b7e9969..ed348900 100644 --- a/front-end/views/hashtag.mjs +++ b/front-end/views/hashtag.mjs @@ -15,10 +15,19 @@ import {createHeading} from "../components/heading.mjs"; // Hashtag view: show all tweets containing this tag function hashtagView(hashtag) { - destroy(); + const normalizedHashtag = hashtag.startsWith("#") ? hashtag : `#${hashtag}`; + + if (state.currentHashtag === normalizedHashtag) { + renderHashtagPage(normalizedHashtag); + return; + } - apiService.getBloomsByHashtag(hashtag); + destroy(); + renderHashtagPage(normalizedHashtag); + apiService.getBloomsByHashtag(normalizedHashtag); +} +function renderHashtagPage(hashtag) { renderOne( state.isLoggedIn, getLogoutContainer(), @@ -39,7 +48,7 @@ function hashtagView(hashtag) { ?.addEventListener("click", handleLogin); renderOne( - state.currentHashtag, + hashtag, getHeadingContainer(), "heading-template", createHeading