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
23 changes: 17 additions & 6 deletions front-end/views/hashtag.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,9 @@ import {createLogout, handleLogout} from "../components/logout.mjs";
import {createBloom} from "../components/bloom.mjs";
import {createHeading} from "../components/heading.mjs";

// Hashtag view: show all tweets containing this tag

function hashtagView(hashtag) {
destroy();

apiService.getBloomsByHashtag(hashtag);

// helper function to separate the UI from the data fetching
function renderHashtagUI() {
renderOne(
state.isLoggedIn,
getLogoutContainer(),
Expand Down Expand Up @@ -52,4 +48,19 @@ function hashtagView(hashtag) {
);
}

// Hashtag view: show all tweets containing this tag
function hashtagView(hashtag) {
destroy();

const formattedTag = hashtag.startsWith("#") ? hashtag : `#${hashtag}`;

if (state.currentHashtag === formattedTag) {
renderHashtagUI();
return;
}

apiService.getBloomsByHashtag(hashtag);
renderHashtagUI();
}

export {hashtagView};