Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion front-end/views/hashtag.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,15 @@ import {createHeading} from "../components/heading.mjs";
function hashtagView(hashtag) {
destroy();

apiService.getBloomsByHashtag(hashtag);
// Normalise to the same shape the API stores in state (e.g. "do" -> "#do")
const normalisedTag = `#${hashtag.startsWith("#") ? hashtag.substring(1) : hashtag}`;

// Only fetch if this hashtag isn't already loaded. Without this guard,
// every render fetches -> updates state -> fires "state-change" -> re-renders,
// an infinite loop that flashes the page blank and hangs the browser.
if (state.currentHashtag !== normalisedTag) {
apiService.getBloomsByHashtag(hashtag);
}

renderOne(
state.isLoggedIn,
Expand Down