Share funktion

This commit is contained in:
2026-07-16 17:13:37 +02:00
parent 52c9dfb472
commit c7c1864fc6
9 changed files with 311 additions and 27 deletions

View File

@@ -42,6 +42,7 @@ const getBillingCopy = (language: 'de' | 'en' | 'es') => {
retryLabel: 'Erneut versuchen',
notAPlantTitle: 'Keine Pflanze erkannt',
notAPlantMessage: 'Das Bild zeigt keine erkennbare Pflanze. Bitte fotografiere eine Pflanze und versuche es erneut.',
notAPlantSharedMessage: 'Das geteilte Bild zeigt keine erkennbare Pflanze. Möglicherweise wurde nicht der Original-Post geladen. Mach einen Screenshot vom Post und teile den Screenshot — das funktioniert immer.',
providerErrorMessage: 'KI-Scan gerade nicht verfügbar. Bitte versuche es erneut.',
healthProviderErrorMessage: 'KI-Health-Check gerade nicht verfügbar. Bitte versuche es erneut.',
healthTitle: 'Health Check',
@@ -74,6 +75,7 @@ const getBillingCopy = (language: 'de' | 'en' | 'es') => {
retryLabel: 'Reintentar',
notAPlantTitle: 'No es una planta',
notAPlantMessage: 'La imagen no muestra una planta reconocible. Por favor fotografía una planta e inténtalo de nuevo.',
notAPlantSharedMessage: 'La imagen compartida no muestra una planta reconocible. Es posible que no se haya cargado la publicación original. Haz una captura de pantalla de la publicación y compártela — eso siempre funciona.',
providerErrorMessage: 'Escaneo IA no disponible ahora. Inténtalo de nuevo.',
healthProviderErrorMessage: 'Health-check IA no disponible ahora. Inténtalo de nuevo.',
healthTitle: 'Health Check',
@@ -105,6 +107,7 @@ const getBillingCopy = (language: 'de' | 'en' | 'es') => {
retryLabel: 'Try again',
notAPlantTitle: 'No plant detected',
notAPlantMessage: 'The image does not show a recognizable plant. Please photograph a plant and try again.',
notAPlantSharedMessage: 'The shared image does not show a recognizable plant. The original post may not have loaded. Take a screenshot of the post and share the screenshot — that always works.',
providerErrorMessage: 'AI scan is currently unavailable. Please try again.',
healthProviderErrorMessage: 'AI health check is currently unavailable. Please try again.',
healthTitle: 'Health Check',
@@ -199,6 +202,7 @@ export default function ScannerScreen() {
const lastProcessedShareToken = useRef<string | null>(null);
const sharedAnalysisInFlightToken = useRef<string | null>(null);
const analysisFromShareRef = useRef(false);
const resizeForAnalysisRef = useRef<(uri: string) => Promise<string>>(async (uri) => uri);
const analyzeImageRef = useRef<(imageUri: string, galleryImageUri?: string) => Promise<void>>(async () => {});
@@ -417,7 +421,7 @@ export default function ScannerScreen() {
} else if (isBackendApiError(error) && error.code === 'NOT_A_PLANT') {
Alert.alert(
billingCopy.notAPlantTitle,
billingCopy.notAPlantMessage,
analysisFromShareRef.current ? billingCopy.notAPlantSharedMessage : billingCopy.notAPlantMessage,
[{ text: billingCopy.dismiss, style: 'cancel' }],
);
} else if (isBackendApiError(error) && error.code === 'PROVIDER_ERROR') {
@@ -469,6 +473,7 @@ export default function ScannerScreen() {
if (cancelled || sharedAnalysisInFlightToken.current !== shareToken) return;
setDemoResultVisible(false);
setSelectedImage(analysisUri);
analysisFromShareRef.current = true;
await analyzeImageRef.current(analysisUri, nextSharedImageUri);
} finally {
if (sharedAnalysisInFlightToken.current === shareToken) {
@@ -490,6 +495,7 @@ export default function ScannerScreen() {
const analysisUri = await resizeForAnalysis(photo.uri);
setDemoResultVisible(false);
setSelectedImage(analysisUri);
analysisFromShareRef.current = false;
analyzeImage(analysisUri, photo.uri);
}
};
@@ -507,6 +513,7 @@ export default function ScannerScreen() {
const analysisUri = await resizeForAnalysis(asset.uri);
setDemoResultVisible(false);
setSelectedImage(asset.uri);
analysisFromShareRef.current = false;
analyzeImage(analysisUri, asset.uri);
}
};