mirror of
https://github.com/neynarxyz/create-farcaster-mini-app.git
synced 2025-12-13 21:02:51 -05:00
Revert "Merge pull request #15 from neynarxyz/shreyas-formatting"
This reverts commitb1fdfc19a9, reversing changes made tob9e2087bd8.
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
'use client';
|
||||
|
||||
import { useCallback, useState, useEffect } from 'react';
|
||||
import { type ComposeCast } from '@farcaster/miniapp-sdk';
|
||||
import { useMiniApp } from '@neynar/react';
|
||||
import { APP_URL } from '~/lib/constants';
|
||||
import { Button } from './Button';
|
||||
import { useMiniApp } from '@neynar/react';
|
||||
import { type ComposeCast } from "@farcaster/miniapp-sdk";
|
||||
import { APP_URL } from '~/lib/constants';
|
||||
|
||||
interface EmbedConfig {
|
||||
path?: string;
|
||||
@@ -24,16 +24,9 @@ interface ShareButtonProps {
|
||||
isLoading?: boolean;
|
||||
}
|
||||
|
||||
export function ShareButton({
|
||||
buttonText,
|
||||
cast,
|
||||
className = '',
|
||||
isLoading = false,
|
||||
}: ShareButtonProps) {
|
||||
export function ShareButton({ buttonText, cast, className = '', isLoading = false }: ShareButtonProps) {
|
||||
const [isProcessing, setIsProcessing] = useState(false);
|
||||
const [bestFriends, setBestFriends] = useState<
|
||||
{ fid: number; username: string }[] | null
|
||||
>(null);
|
||||
const [bestFriends, setBestFriends] = useState<{ fid: number; username: string; }[] | null>(null);
|
||||
const [isLoadingBestFriends, setIsLoadingBestFriends] = useState(false);
|
||||
const { context, actions } = useMiniApp();
|
||||
|
||||
@@ -59,7 +52,7 @@ export function ShareButton({
|
||||
if (cast.bestFriends) {
|
||||
if (bestFriends) {
|
||||
// Replace @N with usernames, or remove if no matching friend
|
||||
finalText = finalText.replace(/@\d+/g, match => {
|
||||
finalText = finalText.replace(/@\d+/g, (match) => {
|
||||
const friendIndex = parseInt(match.slice(1)) - 1;
|
||||
const friend = bestFriends[friendIndex];
|
||||
if (friend) {
|
||||
@@ -75,7 +68,7 @@ export function ShareButton({
|
||||
|
||||
// Process embeds
|
||||
const processedEmbeds = await Promise.all(
|
||||
(cast.embeds || []).map(async embed => {
|
||||
(cast.embeds || []).map(async (embed) => {
|
||||
if (typeof embed === 'string') {
|
||||
return embed;
|
||||
}
|
||||
@@ -84,10 +77,7 @@ export function ShareButton({
|
||||
const url = new URL(`${baseUrl}${embed.path}`);
|
||||
|
||||
// Add UTM parameters
|
||||
url.searchParams.set(
|
||||
'utm_source',
|
||||
`share-cast-${context?.user?.fid || 'unknown'}`,
|
||||
);
|
||||
url.searchParams.set('utm_source', `share-cast-${context?.user?.fid || 'unknown'}`);
|
||||
|
||||
// If custom image generator is provided, use it
|
||||
if (embed.imageUrl) {
|
||||
@@ -98,7 +88,7 @@ export function ShareButton({
|
||||
return url.toString();
|
||||
}
|
||||
return embed.url || '';
|
||||
}),
|
||||
})
|
||||
);
|
||||
|
||||
// Open cast composer with all supported intents
|
||||
|
||||
Reference in New Issue
Block a user