From dc212edb77fa4025c2760c9ce2dd9f41f02fdd10 Mon Sep 17 00:00:00 2001 From: TheOnlyWayUp Date: Fri, 2 Feb 2024 01:13:11 +0000 Subject: [PATCH] fix(wattpad): Include self in follower's and following's follower and following lists in fetch functions --- src/wattpad/wattpad.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/wattpad/wattpad.py b/src/wattpad/wattpad.py index 6804fc0..55a89da 100644 --- a/src/wattpad/wattpad.py +++ b/src/wattpad/wattpad.py @@ -196,6 +196,9 @@ async def fetch_followers( user_cls = User( username=username ) # ! This code is an artefact of the singleton design model. If a user already exists, their data will not be updated otherwise. + user_cls.following.append( + self + ) # ! The current user is followed by this fetched user user_cls._update_data(**user) followers.append(user_cls) @@ -245,10 +248,15 @@ async def fetch_following( following: list[User] = [] for user in data["users"]: username = user.pop("username") + user_cls = User( username=username ) # ! This code is an artefact of the singleton design model. If a user already exists, their data will not be updated otherwise. + user_cls.followers.append( + self + ) # ! The current user follows this fetched user user_cls._update_data(**user) + following.append(user_cls) self.followers = following