Skip to content

Conversation

tiodot
Copy link

@tiodot tiodot commented Mar 4, 2024

Touching to go next/prev page not working in the Huawei landtop, add an addEventListener of 'touchene'

Copy link

vercel bot commented Mar 4, 2024

Someone is attempting to deploy a commit to a Personal Account owned by @pacexy on Vercel.

@pacexy first needs to authorize it.

Copy link

vercel bot commented Mar 10, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
flow-reader ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 10, 2024 4:11am

return (
book ??
fetch(url)
fetch(proxyGithubUrl(url))
Copy link
Owner

Choose a reason for hiding this comment

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

why add this?

Copy link
Author

Choose a reason for hiding this comment

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

Without this, download book from Github will occur CORS error.

Copy link
Owner

Choose a reason for hiding this comment

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

It's better to move this to a new PR, but idk if we actually need this.

Copy link
Author

Choose a reason for hiding this comment

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

ok, I delete these code.

Copy link
Owner

@pacexy pacexy left a comment

Choose a reason for hiding this comment

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

I would like to merge this PR. Could you explain with comments why addEventListener is needed?

@pacexy pacexy requested a review from Copilot September 19, 2025 04:18
Copy link

@Copilot 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

Fixes touch navigation issues on Huawei devices by refactoring touch event handling into a reusable hook and adding a 'touchend' event listener. Additionally improves filename handling by URL-decoding filenames and exports a previously internal type.

  • Extracts touch event logic from Reader component into dedicated useTouchEvent hook
  • Adds dual event listener approach for 'touchend' events to address Huawei device compatibility
  • URL-decodes filenames in book fetching logic

Reviewed Changes

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

Show a summary per file
File Description
apps/reader/src/models/reader.ts Exports AsRef type for use in other modules
apps/reader/src/hooks/useTouchEvent.ts New hook implementing touch event handling with dual listener approach
apps/reader/src/hooks/index.ts Exports the new useTouchEvent hook
apps/reader/src/file.ts URL-decodes filenames when fetching books
apps/reader/src/components/Reader.tsx Replaces inline touch handling with useTouchEvent hook

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

function (e: TouchEvent) {
if (!iframe) return
iframe.ontouchend = undefined
console.log('params:', params.current)
Copy link

Copilot AI Sep 19, 2025

Choose a reason for hiding this comment

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

Remove console.log statement from production code. This debug logging should be removed or replaced with proper logging.

Suggested change
console.log('params:', params.current)

Copilot uses AI. Check for mistakes.

Comment on lines +25 to +27
// so instead of use `addEventlistener`, we should use `on*`
// to remove the previous listener.
iframe.ontouchend = handleTouchEnd
Copy link

Copilot AI Sep 19, 2025

Choose a reason for hiding this comment

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

Potential race condition: Setting iframe.ontouchend directly overwrites any existing handler. Consider checking if a handler already exists or use a more robust event management approach.

Suggested change
// so instead of use `addEventlistener`, we should use `on*`
// to remove the previous listener.
iframe.ontouchend = handleTouchEnd
// but we should not overwrite existing handlers. Use event listeners instead.

Copilot uses AI. Check for mistakes.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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