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
5 changes: 0 additions & 5 deletions front-end/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,7 @@ async function init() {
await apiService.getProfile(profileUsername);
}
}

handleRouteChange();

document.addEventListener("state-change", () => {
handleRouteChange();
});
}

// TODO Check any unhandled errors bubble up to this central handler
Expand Down
13 changes: 9 additions & 4 deletions front-end/views/hashtag.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,13 @@ import {createHeading} from "../components/heading.mjs";

// Hashtag view: show all tweets containing this tag

function hashtagView(hashtag) {
async function hashtagView(hashtag) {
destroy();

apiService.getBloomsByHashtag(hashtag);
// prevent infinite loop
if (state.currentHashtag !== `#${hashtag}`) {
await apiService.getBloomsByHashtag(hashtag);
}

renderOne(
state.isLoggedIn,
Expand All @@ -28,22 +31,24 @@ function hashtagView(hashtag) {
document
.querySelector("[data-action='logout']")
?.addEventListener("click", handleLogout);

renderOne(
state.isLoggedIn,
getLoginContainer(),
"login-template",
createLogin
);
document
.querySelector("[data-action='login']")
?.addEventListener("click", handleLogin);
.querySelector('[data-form="login"]')
?.addEventListener("submit", handleLogin); // also fix this 👀

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

renderEach(
state.hashtagBlooms || [],
getTimelineContainer(),
Expand Down