Skip to content

fix: improve image loading logic by waiting for visibility instead of…#53

Merged
Perry2004 merged 1 commit intomainfrom
fix/never-idle-network
Oct 13, 2025
Merged

fix: improve image loading logic by waiting for visibility instead of…#53
Perry2004 merged 1 commit intomainfrom
fix/never-idle-network

Conversation

@Perry2004
Copy link
Owner

… network idle

Copilot AI review requested due to automatic review settings October 13, 2025 19:24
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Improves image loading logic by replacing network idle waiting with visibility-based detection for more reliable image loading detection.

  • Replaces network idle state waiting with waiting for specific image selectors to be visible
  • Adds a fixed timeout delay after "Load More" clicks instead of waiting for network idle state
  • Updates console logging messages to reflect the new loading detection strategy

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines 102 to +103
await loadMoreButton.click();

// Wait for new content to load
await page.waitForLoadState("networkidle");
await page.waitForTimeout(5000);
Copy link

Copilot AI Oct 13, 2025

Choose a reason for hiding this comment

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

Fixed timeout delays can be inefficient and unreliable. Consider using a more robust waiting strategy like page.waitForSelector() with a specific selector for newly loaded images, or page.waitForFunction() to wait for a condition that indicates new content has loaded.

Copilot uses AI. Check for mistakes.
Comment on lines +80 to +86
await page.waitForSelector(
'img[src^="https://images.pexels.com/photos/"]',
{
state: "visible",
timeout: 60000,
},
);
Copy link

Copilot AI Oct 13, 2025

Choose a reason for hiding this comment

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

The hardcoded URL prefix 'https://images.pexels.com/photos/' creates tight coupling to a specific domain. Consider extracting this as a configuration constant or parameter to improve maintainability and reusability.

Copilot uses AI. Check for mistakes.
@Perry2004 Perry2004 merged commit ce736d7 into main Oct 13, 2025
2 checks passed
@Perry2004 Perry2004 deleted the fix/never-idle-network branch October 13, 2025 19:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants