Skip to content
This repository was archived by the owner on Sep 26, 2022. It is now read-only.

Add AJAX functions for following/unfollowing users - #9

Open
TJBANEY wants to merge 14 commits into
SriNandan33:masterfrom
TJBANEY:master
Open

Add AJAX functions for following/unfollowing users#9
TJBANEY wants to merge 14 commits into
SriNandan33:masterfrom
TJBANEY:master

Conversation

@TJBANEY

@TJBANEY TJBANEY commented Oct 2, 2019

Copy link
Copy Markdown

I added a JavaScript file with logic to asynchronously hit the follow and unfollow Flask routes. I also turned the follow/unfollow buttons into template snippets so they can be re-used throughout the application where needed, and where a context user can be provided.

@SriNandan33 SriNandan33 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

coming along nicely @TJBANEY , Thanks alot. I have requested for a few changes please take a look at them.

Comment thread app/templates/base.html Outdated
)
})

const user = "{{user.username}}"

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

user object is only available in user.html, it is not available in base.html. It will work for /user/ endpoint, but it will not work for other endpoints, you may get jinja2.exceptions.UndefinedError, please check.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I suggest moving follow, unfollow links to some reusable html template and use it everywhere, and move this javascript code to the new template created.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Hey @SriNandan33 I made those follow/unfollow buttons snippets, and migrated the inline javascript used for following/unfollowing into a static directory

Comment thread app/templates/user.html Outdated
{% elif current_user.is_following(user) %}
<p><a href="{{ url_for('core.unfollow', username=user.username)}}">Unfollow</a></p>
<div class="follow-link">
<p onclick="unFollowUser()">Unfollow</p>

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Please use button here just to denote it is clickable and add some css to it. Don't forget to add cursor:pointer to css rule.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

This one is also good to go 👍

@TJBANEY

TJBANEY commented Oct 6, 2019

Copy link
Copy Markdown
Author

@SriNandan33 Made a few more edits that maintains follow/unfollow functionality inside hover popups

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants