Skip to content
Open
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
.DS_Store
venv/
.venv/
.env
node_modules/
26 changes: 17 additions & 9 deletions front-end/views/hashtag.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {renderOne, renderEach, destroy} from "../lib/render.mjs";
import { renderOne, renderEach, destroy } from "../lib/render.mjs";
import {
state,
apiService,
Expand All @@ -7,18 +7,21 @@ import {
getTimelineContainer,
getHeadingContainer,
} from "../index.mjs";
import {createLogin, handleLogin} from "../components/login.mjs";
import {createLogout, handleLogout} from "../components/logout.mjs";
import {createBloom} from "../components/bloom.mjs";
import {createHeading} from "../components/heading.mjs";
import { createLogin, handleLogin } from "../components/login.mjs";
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
// Hashtag view: show all blooms containing this tag

function hashtagView(hashtag) {
async function hashtagView(hashtag) {
// Clear any existing content first
destroy();

apiService.getBloomsByHashtag(hashtag);
// Wait for blooms related to this hashtag to be fetched before rendering
await apiService.getBloomsByHashtag(hashtag);

// Render logout section if user is logged in
renderOne(
state.isLoggedIn,
getLogoutContainer(),
Expand All @@ -28,6 +31,8 @@ function hashtagView(hashtag) {
document
.querySelector("[data-action='logout']")
?.addEventListener("click", handleLogout);

// Render login section if user is not logged in
renderOne(
state.isLoggedIn,
getLoginContainer(),
Expand All @@ -38,12 +43,15 @@ function hashtagView(hashtag) {
.querySelector("[data-action='login']")
?.addEventListener("click", handleLogin);

// Render page heading
renderOne(
state.currentHashtag,
getHeadingContainer(),
"heading-template",
createHeading
);

// Render all blooms that contain the hashtag
renderEach(
state.hashtagBlooms || [],
getTimelineContainer(),
Expand All @@ -52,4 +60,4 @@ function hashtagView(hashtag) {
);
}

export {hashtagView};
export { hashtagView };