Skip to content

Conversation

@graycreate
Copy link
Member

Summary

  • Add 800ms minimum delay in UpdatableView to prevent pull-to-refresh from snapping back immediately
  • Fetch online stats on first load so subsequent refreshes show the data smoothly
  • When online stats exist, delay is 1000ms to allow users to see the updated count

Problem

The pull-to-refresh on the home feed would immediately retract without showing the refresh animation when:

  1. User was not logged in (no online stats to fetch)
  2. First refresh after app launch (online stats not yet loaded)

Solution

Changed the delay logic in UpdatableView.swift from 0ms to 800ms as the minimum delay, ensuring users always see the refresh animation feedback.

Test plan

  • Pull-to-refresh shows animation for at least 800ms
  • Online user count displays after logging in
  • Refresh animation is smooth with proper feedback

🤖 Generated with Claude Code

- Add 800ms minimum delay in UpdatableView to prevent immediate retraction
- Fetch online stats on first load for smoother subsequent refreshes
- Fixes issue where pull-to-refresh would snap back immediately

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Copilot AI review requested due to automatic review settings December 1, 2025 14:23
Copilot finished reviewing on behalf of graycreate December 1, 2025 14:25
@graycreate graycreate merged commit bd6bab6 into main Dec 1, 2025
12 checks passed
@graycreate graycreate deleted the bugfix/pulltorefresh-immediate-retract branch December 1, 2025 14:25
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

This PR fixes an issue where the pull-to-refresh animation would snap back immediately without providing visual feedback. The fix introduces a minimum 800ms delay for the refresh animation and ensures online stats are fetched on first load.

Key changes:

  • Added minimum 800ms delay for pull-to-refresh animation (1000ms when online stats exist)
  • Fetch online stats during initial app load for logged-in users

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
V2er/View/Widget/Updatable/UpdatableView.swift Changed minimum delay from 0ms to 800ms for refresh animation
V2er/View/Feed/FeedPage.swift Added online stats fetch on first load when user is signed in

// Minimum 800ms delay for refresh animation, 1000ms if online stats exist
let hasOnlineStatsNow = onlineStats != nil
let delayMs = (hadOnlineStatsBefore || hasOnlineStatsNow) ? 1000 : 0
let delayMs = (hadOnlineStatsBefore || hasOnlineStatsNow) ? 1000 : 800
Copy link

Copilot AI Dec 1, 2025

Choose a reason for hiding this comment

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

The delay values 1000 and 800 are magic numbers. Consider extracting them as named constants at the struct level (e.g., private let refreshDelayWithStats = 1000, private let minimumRefreshDelay = 800) to improve code maintainability and make the intent clearer.

Copilot uses AI. Check for mistakes.
Task {
await onRefresh?()
// Decide delay (ms): 1200 if we had/now have online stats so users can notice updates; otherwise 0.
// Minimum 800ms delay for refresh animation, 1000ms if online stats exist
Copy link

Copilot AI Dec 1, 2025

Choose a reason for hiding this comment

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

The comment should explain why these specific delay values were chosen (e.g., 'to ensure users see the refresh animation feedback' or 'to allow users to notice online stats updates'), not just state what the values are.

Suggested change
// Minimum 800ms delay for refresh animation, 1000ms if online stats exist
// Use a minimum 800ms delay to ensure users see the refresh animation feedback.
// If online stats are present before or after refresh, use 1000ms to give users time to notice updated online stats.

Copilot uses AI. Check for mistakes.
@github-actions
Copy link

github-actions bot commented Dec 1, 2025

Code Coverage Report ❌

Current coverage: 27.73%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants