Skip to content

Commit

Permalink
fix: place first post not found #208
Browse files Browse the repository at this point in the history
  • Loading branch information
mastrolube committed Aug 2, 2021
1 parent baa6410 commit 55d4700
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
1 change: 1 addition & 0 deletions GramAddict/core/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ def __init__(self, APP_ID):
f"{APP_ID}:id/row_hashtag_textview_tag_name"
)
self.INFORM_BODY = f"{APP_ID}:id/inform_body"
self.RECYCLER_VIEW = f"{APP_ID}:id/recycler_view"
self.ROW_PLACE_TITLE = f"{APP_ID}:id/row_place_title"
self.ROW_LOAD_MORE_BUTTON = f"{APP_ID}:id/row_load_more_button"
self.ROW_PROFILE_HEADER_EMPTY_PROFILE_NOTICE_CONTAINER = (
Expand Down
23 changes: 15 additions & 8 deletions GramAddict/core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,7 @@ def __init__(self, device: DeviceFacade):
self.device = device

def _getRecyclerView(self):
views = f"({ClassName.RECYCLER_VIEW}|{ClassName.VIEW})"
obj = self.device.find(classNameMatches=views)
obj = self.device.find(resourceIdMatches=ResourceID.RECYCLER_VIEW)
if obj.exists(Timeout.LONG):
logger.debug("RecyclerView exists.")
else:
Expand Down Expand Up @@ -260,14 +259,22 @@ def __init__(self, device: DeviceFacade):
self.device = device

def _getRecyclerView(self):
views = f"({ClassName.RECYCLER_VIEW}|{ClassName.VIEW})"
return self.device.find(classNameMatches=views)
obj = self.device.find(resourceIdMatches=ResourceID.RECYCLER_VIEW)
if obj.exists(Timeout.LONG):
logger.debug("RecyclerView exists.")
else:
logger.debug("RecyclerView doesn't exists.")
return obj

def _getFistImageView(self, recycler):
return recycler.child(
className=ClassName.IMAGE_VIEW,
obj = recycler.child(
resourceIdMatches=ResourceID.IMAGE_BUTTON,
)
if obj.exists(Timeout.LONG):
logger.debug("First image in view exists.")
else:
logger.debug("First image in view doesn't exists.")
return obj

def _getRecentTab(self):
return self.device.find(
Expand Down Expand Up @@ -1959,7 +1966,7 @@ def _reload_page(self):
random_sleep(modulable=False)

def detect_block(device):
if args.detect_block:
if args.disable_block_detection:
logger.debug("Checking for block...")
if "blocked" in device.deviceV2.toast.get_message(1.0, 2.0, default=""):
logger.warning("Toast detected!")
Expand All @@ -1971,7 +1978,7 @@ def detect_block(device):
resourceIdMatches=ResourceID.IGDS_HEADLINE_BODY,
)
regex = r".+deleted"
popup_appears = block_dialog.exists(Timeout.SHORT)
popup_appears = block_dialog.exists()
if popup_appears:
if popup_body.exists():
is_post_deleted = re.match(
Expand Down

0 comments on commit 55d4700

Please sign in to comment.