Skip to content

refactor(client): adopt copyToClipboard helper at raw Clipboard.setData sites#1119

Open
NC1107 wants to merge 1 commit into
mainfrom
refactor/clipboard-helper-adoption
Open

refactor(client): adopt copyToClipboard helper at raw Clipboard.setData sites#1119
NC1107 wants to merge 1 commit into
mainfrom
refactor/clipboard-helper-adoption

Conversation

@NC1107
Copy link
Copy Markdown
Owner

@NC1107 NC1107 commented May 22, 2026

Summary

Migrates 8 raw Clipboard.setData(...) + ToastService.show(..., type: ToastType.success) pairs to the existing copyToClipboard(context, text, successMessage: ...) helper in services/clipboard_service.dart. Toast wording is preserved verbatim; the helper API is unchanged.

Migrated sites

  • screens/settings/account_section.dart:343_copyInviteLink (invite URL).
  • screens/settings/account_section.dart:412 — QR-code dialog "Copy invite link" button (uses dialogContext).
  • screens/settings/about_section.dart:768 — bulk copy of debug-log entries.
  • screens/settings/about_section.dart:919 — copy a single debug-log entry.
  • screens/group_info_screen/parts/invite_section.dart:31 — copy freshly-minted group invite URL.
  • widgets/connection_status_badge.dart:464 — diagnostics popover copy.
  • widgets/message_item.dart:1441_copyMessageText (message body or media URL).
  • widgets/message_item.dart:1451_copyMessageId.

Skipped sites and why

  • screens/settings/data_storage_section.dart:84 — the surrounding ToastService.show omits the type: arg, so it defaults to ToastType.info. The helper hard-codes success, so migrating would change the toast type.
  • widgets/image_gallery_viewer.dart:145 — fallback path uses ToastType.info ("Save not supported here. Link copied.").
  • widgets/message_item.dart:313, 356 — both are fallback paths that surface ToastType.info ("Save not supported here yet. Link copied.", "Image copy not supported, link copied").
  • widgets/message/media_content.dart:307 — fallback path uses ToastType.info.
  • widgets/chat_input_bar/parts/keyboard_handling.dart:77 — Ctrl+C / Ctrl+X keyboard handler; intentionally has no toast and isn't a "copy" UX surface.

Behind the scenes

  • Drops now-unused flutter/services.dart and toast_service.dart imports from files that no longer reference them.
  • flutter analyze --fatal-infos is clean; dart format is a no-op on the touched files.
  • Affected widget tests pass (account_section_test, about_section_test, connection_status_badge_test, message_item_test — 51/51).

Test plan

  • Settings → Account → "Copy invite link" still shows the existing toast.
  • Settings → About → Debug logs → copy all + copy single still show their toasts.
  • Group info → generate invite link still shows the existing toast.
  • Connection status popover → diagnostics copy still shows the existing toast.
  • Message context menu → copy message + copy ID still show their toasts.

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.

1 participant