-
-
Notifications
You must be signed in to change notification settings - Fork 212
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
Fix(#87): Add Some Basic Validations For Better UX #89
Conversation
Someone is attempting to deploy a commit to a Personal Account owned by @Mayank0255 on Vercel. @Mayank0255 first needs to authorize it. |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
The censorship is applied when a new post, comment or answer is submitted. Please try adding a new post and test for yourself if it works. |
@ozair-dev |
@Mayank0255 sure, |
@Mayank0255 Tags are not censored. Instead, they are detected at post submission and an error is shown |
@ozair-dev cool, As the current text seems like that only tags cannot be Inappropriate 😅, though they can write inappropriate words for title and body but why tell them that |
Can do, but
If the title or body contain inappropriate words, it won't terminate the dispatching of the formData, so user is actually allowed to write inappropriate words there, but If the tags contain the inappropriate words then dispatching is stopped, so I specifically mentioned tags cannot contains inappropriate words. |
@Mayank0255 Just a quick heads-up before you merge the changes! |
By how much is the page loading time increasing? |
On my machine, it's taking about 43 seconds. |
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.
Pls look into this and then see that whats the difference between the response time
src/redux/answers/answers.actions.js
Outdated
export const getAnswers = (id) => async (dispatch) => { | ||
try { | ||
const res = await axios.get(config.BASE_URL + `/api/posts/answers/${id}`); | ||
|
||
dispatch({ | ||
type: GET_ANSWERS, | ||
payload: res.data.data, | ||
payload: res.data.data.map(({body, ...rest})=>({...censorBadWords({body}), ...rest})), |
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.
Here we are looping on the complete response and then changing the text, and then while rendering we are anyways looping through the result.
The better approach would be to convert the text while rending so that we can avoid an extra loop, and avoid a delete and an insert operation
export const getComments = (id) => async (dispatch) => { | ||
try { | ||
const res = await axios.get(config.BASE_URL + `/api/posts/comments/${id}`); | ||
|
||
dispatch({ | ||
type: GET_COMMENTS, | ||
payload: res.data.data, | ||
payload: res.data.data.map(({body, ...rest})=>({...censorBadWords({body}), ...rest})), |
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.
Same can be done here
src/redux/posts/posts.actions.js
Outdated
// Get posts | ||
export const getPosts = () => async (dispatch) => { | ||
try { | ||
const res = await axios.get(config.BASE_URL + '/api/posts'); | ||
|
||
dispatch({ | ||
type: GET_POSTS, | ||
payload: res.data.data, | ||
payload: res.data.data.map(({title, body, ...rest})=>({...censorBadWords({title, body}), ...rest})), |
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.
Over here there's no loop, but to remain consistency and to avoid insert and delete operation we can just convert the text while rendering
I'm busy these couple of days. Will try when I am free In sha'Allah. |
Sure, no problem |
I have removed censoring for posts on data retrieval and instead, I am censoring title and body of each PostItem.compoent component on render. It stills takes about 43 seconds for HomePage to load. And additional 43 seconds (more or less depending on amount of text and machine's speed etc) on each pagination. Here in the screenshot, you can see in console how much time each text is taking to be censored. Even the amount of time taken to censor even a small string is not negligible Long story short, censoring text on rendering also does not reduce the loading time. Deploy the changes and see the time time taken to censor each text in console to get a better idea. |
questions page is breaking |
fixed |
@ozair-dev looks good enough, just remove the logs and I will merge |
Done |
@ozair-dev |
Max length limit for Tag Name while creation: 25 Characters
All Tag Names Should Be In English, So Translate it or don't allow it
Users Per Page Should Be 15, not 16
Validate the language users are inputting, dont allow any abuses or curses
I have added a function
censorBadWords
(which can take string, object or array of strings as arguments and convert the bad words to censored words) to the services directory and it is being used in the formSubmit before dispatching.Please review the PR and let me know if you want more changes.