Skip to content

Conversation

@gerardopar
Copy link
Collaborator

@gerardopar gerardopar commented Dec 16, 2025

Overview

🎟 Relevant Jira Issues

📚 What is the context and goal of this PR?

Summary

This PR fixes an issue with saving QR codes to Photos on Android and improves the visual fidelity of the downloaded QR code so it more closely matches the user’s QR Code Profile card.

Issues Addressed

  1. On Android, the “Save to Photos” action did not reliably save the QR code image.
  2. The downloaded QR code did not match the appearance of the QR code shown on the user’s profile (logo, user info, layout).

What Changed

  1. Improved QR Code Rendering for Downloads
    • Added html2canvas to capture a snapshot of the full QR Code UI instead of exporting only the raw SVG.
    • The snapshot approach allows us to include:
    • QR code
    • User name / username
    • Supporting UI elements
    • The snapshot is converted into PNG or PDF, which users can then download or save.

Note: Embedding the LearnCard logo directly into the SVG snapshot proved unreliable, but additional user metadata is now included to better match the profile card.

  1. Fixed Android “Save to Photos” Behavior
    • Resolved an issue where the QR code image was not being saved on Android devices.
    • The root cause was a missing target album.

    • The save flow now:
    • Ensures the target album exists (creates it if needed)

🥴 TL; RL:

💡 Feature Breakdown (screenshots & videos encouraged!)

ANDROID

https://www.loom.com/share/c878cc2415d841bfb35ed1ad9ffa0d64

IOS

https://www.loom.com/share/f8b1eb020e92489a8e67eb22ef118aeb

🛠 Important tradeoffs made:

🔍 Types of Changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Chore (refactor, documentation update, etc)

💳 Does This Create Any New Technical Debt? ( If yes, please describe and add JIRA TODOs )

  • No
  • Yes

Testing

🔬 How Can Someone QA This?

Testing Instructions

  1. Navigate to the User's QRCode Profile Card
  2. Web -> (download)
    • Click “Save as Photo” → verify PNG downloads correctly
    • Click “Save as File” → verify PDF downloads correctly
  3. Android / IOS -> (download)
    • Click “Save to Photos” → verify QR code is saved to photos as a png
    • Click “Save to Files” → verify QR code is saved to files as a pdf

📱 🖥 Which devices would you like help testing on?

🧪 Code Coverage

Documentation

📜 Gitbook

📊 Storybook

✅ PR Checklist

  • Related to a Jira issue (create one if not)
  • My code follows style guidelines (eslint / prettier)
  • I have manually tested common end-2-end cases
  • I have reviewed my code
  • I have commented my code, particularly where ambiguous
  • New and existing unit tests pass locally with my changes
  • I have made corresponding changes to gitbook documentation

🚀 Ready to squash-and-merge?:

  • Code is backwards compatible
  • There is not a "Do Not Merge" label on this PR
  • I have thoughtfully considered the security implications of this change.
  • This change does not expose new public facing endpoints that do not have authentication

✨ PR Description

Purpose: Fix QR code download functionality to support full card screenshots with improved cross-platform compatibility for web and native mobile apps.

Main changes:

  • Replaced SVG-based QR generation with html2canvas to capture entire QR card as PNG/PDF
  • Added loading states and disabled buttons during save operations to prevent duplicate downloads
  • Implemented Android-specific album creation logic to save images to dedicated LearnCard album
  • Restructured DOM to wrap downloadable content in screenshot-ready container with proper styling
  • Updated dependency stack from pdf-lib to jsPDF and added html2canvas for rendering

Generated by LinearB AI and added by gitStream.
AI-generated content may contain inaccuracies. Please verify before using.
💡 Tip: You can customize your AI Description using Guidelines Learn how

@changeset-bot
Copy link

changeset-bot bot commented Dec 16, 2025

🦋 Changeset detected

Latest commit: ae382bd

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
learn-card-app Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Improved QRCode download support for the learn-card-app.
@netlify
Copy link

netlify bot commented Dec 16, 2025

Deploy Preview for staging-learncardapp ready!

Name Link
🔨 Latest commit ae382bd
🔍 Latest deploy log https://app.netlify.com/projects/staging-learncardapp/deploys/6941b7058e83810008682ae5
😎 Deploy Preview https://deploy-preview-886--staging-learncardapp.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Contributor

@gitstream-cm gitstream-cm bot left a comment

Choose a reason for hiding this comment

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

✨ PR Review

The PR successfully refactors QR code download functionality from SVG-based to HTML screenshot-based approach using html2canvas. The implementation includes proper loading states and platform-specific handling, but has some error handling gaps.

1 issues detected:

🐞 Bug - Unhandled async operations can cause unexpected crashes and poor user experience

Details: The ensureAlbumExists function makes multiple async Media API calls without proper error handling. If Media.getAlbums() or Media.createAlbum() fails, it could crash the entire save process and leave the user in an unclear state.
File: apps/learn-card-app/src/components/qrcode-user-card/QrCodeUserCardShareOptions/QrCodeDownloadOptions.tsx

Generated by LinearB AI and added by gitStream.
AI-generated content may contain inaccuracies. Please verify before using.
💡 Tip: You can customize your AI Review using Guidelines Learn how

@netlify
Copy link

netlify bot commented Dec 16, 2025

Deploy Preview for learncarddocs canceled.

Name Link
🔨 Latest commit ae382bd
🔍 Latest deploy log https://app.netlify.com/projects/learncarddocs/deploys/6941b705d8aceb0008a2a86b

@gitstream-cm
Copy link
Contributor

gitstream-cm bot commented Dec 16, 2025

🥷 Code experts: TaylorBeeston, Custard7

TaylorBeeston has most 👩‍💻 activity in the files.
Custard7, TaylorBeeston have most 🧠 knowledge in the files.

See details

apps/learn-card-app/package.json

Activity based on git-commit:

TaylorBeeston
DEC 8 additions & 3 deletions
NOV 165 additions & 2 deletions
OCT
SEP
AUG
JUL

Knowledge based on git-blame:
TaylorBeeston: 93%
Custard7: 6%

apps/learn-card-app/src/components/qrcode-user-card/QRCodeUserCard.tsx

Activity based on git-commit:

TaylorBeeston
DEC 33 additions & 373 deletions
NOV 399 additions & 0 deletions
OCT
SEP
AUG
JUL

Knowledge based on git-blame:
TaylorBeeston: 100%

apps/learn-card-app/src/components/qrcode-user-card/QrCodeUserCardBasicInfo/QrCodeUserCardBasicInfo.tsx

Activity based on git-commit:

TaylorBeeston
DEC 54 additions & 0 deletions
NOV
OCT
SEP
AUG
JUL

Knowledge based on git-blame:
TaylorBeeston: 100%

apps/learn-card-app/src/components/qrcode-user-card/QrCodeUserCardShareOptions/QrCodeDownloadOptions.tsx

Activity based on git-commit:

TaylorBeeston
DEC 255 additions & 0 deletions
NOV
OCT
SEP
AUG
JUL

Knowledge based on git-blame:
TaylorBeeston: 100%

apps/learn-card-app/src/components/qrcode-user-card/QrCodeUserCardShareOptions/user-share-options.helpers.ts

Activity based on git-commit:

TaylorBeeston
DEC 66 additions & 0 deletions
NOV
OCT
SEP
AUG
JUL

Knowledge based on git-blame:
TaylorBeeston: 100%

apps/learn-card-app/src/components/qrcode-user-card/UserQRCode/UserQRCode.tsx

Activity based on git-commit:

TaylorBeeston
DEC 38 additions & 0 deletions
NOV
OCT
SEP
AUG
JUL

Knowledge based on git-blame:
TaylorBeeston: 100%

pnpm-lock.yaml

Activity based on git-commit:

TaylorBeeston
DEC 346 additions & 341 deletions
NOV 20593 additions & 9364 deletions
OCT
SEP
AUG
JUL 6 additions & 0 deletions

Knowledge based on git-blame:
Custard7: 81%
TaylorBeeston: 18%

✨ Comment /gs review for LinearB AI review. Learn how to automate it here.

gitstream-cm[bot]

This comment was marked as resolved.

Copy link
Contributor

@gitstream-cm gitstream-cm bot left a comment

Choose a reason for hiding this comment

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

✨ PR Review

The PR successfully refactors QR code download functionality with improved visual fidelity using html2canvas. The implementation includes proper loading states and platform-specific behavior, though some error handling concerns remain.

2 issues detected:

🐞 Bug - Concurrent execution of album creation logic without synchronization

Details: The ensureAlbumExists function could create race conditions if multiple users trigger simultaneous PNG saves. Both calls might attempt to create the same album, potentially causing one to fail or creating duplicate operations on the Media API.
File: apps/learn-card-app/src/components/qrcode-user-card/QrCodeUserCardShareOptions/QrCodeDownloadOptions.tsx

🐞 Bug - Array access without bounds checking on string split operation

Details: The code assumes data URL format when splitting on comma to extract base64 data. If html2canvas returns an unexpected format or the toDataURL call fails, this could throw an error.
File: apps/learn-card-app/src/components/qrcode-user-card/QrCodeUserCardShareOptions/QrCodeDownloadOptions.tsx

Generated by LinearB AI and added by gitStream.
AI-generated content may contain inaccuracies. Please verify before using.
💡 Tip: You can customize your AI Review using Guidelines Learn how

Copy link
Collaborator

@goblincore goblincore left a comment

Choose a reason for hiding this comment

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

LGTM!

@gerardopar gerardopar merged commit fc62b1b into main Dec 17, 2025
23 of 24 checks passed
@gerardopar gerardopar deleted the lc-1481 branch December 17, 2025 20:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants