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
24 changes: 13 additions & 11 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,23 +7,25 @@ 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

function hashtagView(hashtag) {
destroy();

apiService.getBloomsByHashtag(hashtag);
if (hashtag !== state.currentHashtag) {
apiService.getBloomsByHashtag(hashtag);
}
Comment on lines +20 to +22

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You identified what could be done to stop the "loop" from happening, but have you tested your code to see if it has actually stopped the "fetch-render" loop?


renderOne(
state.isLoggedIn,
getLogoutContainer(),
"logout-template",
createLogout
createLogout,
);
document
.querySelector("[data-action='logout']")
Expand All @@ -32,7 +34,7 @@ function hashtagView(hashtag) {
state.isLoggedIn,
getLoginContainer(),
"login-template",
createLogin
createLogin,
);
document
.querySelector("[data-action='login']")
Expand All @@ -42,14 +44,14 @@ function hashtagView(hashtag) {
state.currentHashtag,
getHeadingContainer(),
"heading-template",
createHeading
createHeading,
);
renderEach(
state.hashtagBlooms || [],
getTimelineContainer(),
"bloom-template",
createBloom
createBloom,
);
}

export {hashtagView};
export { hashtagView };