-
-
Couldn't load subscription status.
- Fork 17
Glasgow | Sheetal kharab | Module Legacy Code | WEEK 1| Hashtag slowing down my browser #28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
15fb667
0e95faf
f9b3e0f
7e8ce68
59760e8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| import {apiService} from "../index.mjs"; | ||
| import { apiService } from "../index.mjs"; | ||
|
|
||
| /** | ||
| * Create a bloom form component | ||
|
|
@@ -26,6 +26,11 @@ async function handleBloomSubmit(event) { | |
| const originalText = submitButton.textContent; | ||
| const textarea = form.querySelector("textarea"); | ||
| const content = textarea.value.trim(); | ||
| const charMaxLength = 280; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these changes should not be in this PR! |
||
| if (content.length > charMaxLength) { | ||
| alert(`Bloom content must be 280 characters or less.`); | ||
| return; | ||
| } | ||
|
|
||
| try { | ||
| // Make form inert while we call the back end | ||
|
|
@@ -55,4 +60,4 @@ function handleTyping(event) { | |
| counter.textContent = `${textarea.value.length} / ${maxLength}`; | ||
| } | ||
|
|
||
| export {createBloomForm, handleBloomSubmit, handleTyping}; | ||
| export { createBloomForm, handleBloomSubmit, handleTyping }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,9 +36,10 @@ const createBloom = (template, bloom) => { | |
|
|
||
| function _formatHashtags(text) { | ||
| if (!text) return text; | ||
| // special character in hashtag convert into url friendly format | ||
| return text.replace( | ||
| /\B#[^#]+/g, | ||
| (match) => `<a href="/hashtag/${match.slice(1)}">${match}</a>` | ||
| /\B#(\w+)/g, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these changes should not be in this PR! |
||
| (match, tag) => `<a href="/hashtag/${encodeURIComponent(tag)}">${match}</a>` | ||
| ); | ||
| } | ||
|
|
||
|
|
@@ -84,4 +85,4 @@ function _formatTimestamp(timestamp) { | |
| } | ||
| } | ||
|
|
||
| export {createBloom}; | ||
| export { createBloom }; | ||
| 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, | ||
|
|
@@ -7,17 +7,19 @@ 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) { | ||
| const formattedHashtag = hashtag.startsWith("#") ? hashtag : `#${hashtag}`; | ||
| destroy(); | ||
|
|
||
| apiService.getBloomsByHashtag(hashtag); | ||
| if (formattedHashtag !== state.currentHashtag) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. great work introducing a condition on when to check the api! |
||
| apiService.getBloomsByHashtag(hashtag); | ||
| } | ||
|
|
||
| renderOne( | ||
| state.isLoggedIn, | ||
|
|
@@ -52,4 +54,4 @@ function hashtagView(hashtag) { | |
| ); | ||
| } | ||
|
|
||
| export {hashtagView}; | ||
| export { hashtagView }; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this change should not be in this PR