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

Add AJAX functions for following/unfollowing users #9

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

TJBANEY
Copy link

@TJBANEY TJBANEY commented Oct 2, 2019

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.

Copy link
Owner

@SriNandan33 SriNandan33 left a comment

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.

@@ -95,6 +100,48 @@
}
)
})

const user = "{{user.username}}"
Copy link
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
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
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

{% 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
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
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
Copy link
Author

TJBANEY commented Oct 6, 2019

@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