| 44 | const [copying, copyLink] = useCopyLink(() => invitation); |
| 45 | |
| 46 | const logAndCopyLink = async () => { |
| 47 | logEvent({ |
| 48 | event_name: LogEvent.ShareSquadInvitation, |
| 49 | extra: JSON.stringify({ origin, squad: squad.id }), |
| 50 | }); |
| 51 | |
| 52 | completeAction(ActionType.SquadInvite); |
| 53 | |
| 54 | if (invitation) { |
| 55 | return copyLink(); |
| 56 | } |
| 57 | |
| 58 | // Safari may refuse a clipboard write that follows a request, which is |
| 59 | // why callers load the link before the click. |
| 60 | const link = await queryClient |
| 61 | .fetchQuery(queryOptions) |
| 62 | .catch((): null => null); |
| 63 | |
| 64 | return copyLink({ link: link ?? undefined }); |
| 65 | }; |
| 66 | |
| 67 | return { |
| 68 | invitation, |