Fix the behavior of the follow button
There was a bug in Tera and in the User::is_following function. Fix #146
This commit is contained in:
@@ -281,7 +281,7 @@ impl User {
|
||||
users::table.filter(users::id.eq(any(follows))).load::<User>(conn).unwrap()
|
||||
}
|
||||
|
||||
pub fn is_following(&self, conn: &PgConnection, other_id: i32) -> bool {
|
||||
pub fn is_followed_by(&self, conn: &PgConnection, other_id: i32) -> bool {
|
||||
use schema::follows;
|
||||
follows::table
|
||||
.filter(follows::follower_id.eq(other_id))
|
||||
@@ -291,6 +291,16 @@ impl User {
|
||||
.len() > 0
|
||||
}
|
||||
|
||||
pub fn is_following(&self, conn: &PgConnection, other_id: i32) -> bool {
|
||||
use schema::follows;
|
||||
follows::table
|
||||
.filter(follows::follower_id.eq(self.id))
|
||||
.filter(follows::following_id.eq(other_id))
|
||||
.load::<Follow>(conn)
|
||||
.expect("Couldn't load follow relationship")
|
||||
.len() > 0
|
||||
}
|
||||
|
||||
pub fn has_liked(&self, conn: &PgConnection, post: &Post) -> bool {
|
||||
use schema::likes;
|
||||
likes::table
|
||||
|
||||
Reference in New Issue
Block a user