make improvements
Android Release Build / build-android (push) Failing after 7m18s

This commit is contained in:
2026-10-19 19:45:02 +02:00
parent caeb2d2cba
commit 2806c2ec51
6 changed files with 114 additions and 11 deletions
+3 -1
View File
@@ -25,6 +25,7 @@ export default function ProductCard({ product, rating, onPress }) {
{rating ? <ProductScoreBadge status={rating.overallStatus} score={rating.overallScore} /> : null}
<Text style={styles.openLabel}>Details ansehen ›</Text>
</View>
{rating?.allergenReviewRequired ? <Text style={styles.allergenWarning}>Allergenangaben fehlen – Verpackung prüfen.</Text> : null}
</Pressable>
);
}
@@ -95,5 +96,6 @@ const styles = StyleSheet.create({
marginTop: 8,
paddingHorizontal: 8,
paddingVertical: 4
}
},
allergenWarning: { color: colors.danger, fontSize: 14, fontWeight: '800' }
});
+5 -1
View File
@@ -72,7 +72,11 @@ export default function ProductDetailScreen({
</View>
<View style={[styles.recommendation, styles[`${rating.overallStatus}Recommendation`]]}>
<Text style={[styles.recommendationTitle, styles[`${rating.overallStatus}Text`]]}>{recommendation}</Text>
<Text style={styles.recommendationCopy}>Tippe unten auf ein Kriterium, um die Bewertung nachzuvollziehen.</Text>
<Text style={styles.recommendationCopy}>
{rating.allergenReviewRequired
? 'Allergenangaben fehlen oder sind nicht bestätigt. Prüfe vor dem Kauf die Verpackung.'
: 'Tippe unten auf ein Kriterium, um die Bewertung nachzuvollziehen.'}
</Text>
</View>
</View>
+48 -3
View File
@@ -1,4 +1,5 @@
import { Pressable, StyleSheet, Text, View } from 'react-native';
import { useState } from 'react';
import { Alert, Platform, Pressable, StyleSheet, Text, View } from 'react-native';
import BudgetInput from '../components/form/BudgetInput';
import SettingsSwitchRow from '../components/form/SettingsSwitchRow';
@@ -12,7 +13,32 @@ const allergenOptions = ['Erdnüsse', 'Milch', 'Hafer', 'Gluten'];
const priorityOptions = ['low', 'medium', 'high'];
const priorityLabels = { low: 'Niedrig', medium: 'Mittel', high: 'Hoch' };
export default function ProfileScreen({ preferences, onChangePreferences }) {
export default function ProfileScreen({ preferences, onChangePreferences, onOpenPrivacy, onClearProductData, isClearingProductData }) {
const [dataMessage, setDataMessage] = useState('');
async function clearProductData() {
const success = await onClearProductData();
setDataMessage(success
? 'Verlauf und Produktcache wurden gelöscht.'
: 'Die Daten konnten nicht gelöscht werden. Bitte versuche es erneut.');
}
function confirmClearProductData() {
const message = 'Gespeicherte Produkte und letzte Scans werden entfernt. Einkaufsliste, Einstellungen und manuelle Preise bleiben erhalten.';
if (Platform.OS === 'web') {
if (window.confirm(`Verlauf und Produktcache löschen?\n\n${message}`)) clearProductData();
return;
}
Alert.alert(
'Verlauf und Produktcache löschen?',
message,
[
{ text: 'Abbrechen', style: 'cancel' },
{ text: 'Löschen', style: 'destructive', onPress: clearProductData }
]
);
}
function updatePreference(key, value) {
onChangePreferences({ ...preferences, [key]: value });
}
@@ -116,6 +142,22 @@ export default function ProfileScreen({ preferences, onChangePreferences }) {
onValueChange={(value) => updatePreference('offlineModeEnabled', value)}
value={preferences.offlineModeEnabled}
/>
<View style={styles.divider} />
<Pressable accessibilityRole="link" onPress={onOpenPrivacy} style={styles.dataAction}>
<Text style={styles.dataActionText}>Datenschutzerklärung ansehen ›</Text>
</Pressable>
<View style={styles.divider} />
<Pressable
accessibilityRole="button"
accessibilityState={{ disabled: isClearingProductData }}
disabled={isClearingProductData}
onPress={confirmClearProductData}
style={styles.dataAction}
>
<Text style={styles.deleteActionText}>{isClearingProductData ? 'Daten werden gelöscht...' : 'Verlauf und Produktcache löschen'}</Text>
</Pressable>
<Text style={styles.fieldHint}>Einkaufsliste, Einstellungen und manuelle Preise bleiben erhalten.</Text>
{dataMessage ? <Text accessibilityRole="alert" style={styles.fieldHint}>{dataMessage}</Text> : null}
</SettingsSection>
</ScreenContainer>
);
@@ -263,5 +305,8 @@ const styles = StyleSheet.create({
justifyContent: 'center',
minHeight: 44,
paddingHorizontal: 4
}
},
dataAction: { justifyContent: 'center', minHeight: 44 },
dataActionText: { color: colors.primary, fontSize: 15, fontWeight: '800' },
deleteActionText: { color: colors.danger, fontSize: 15, fontWeight: '800' }
});
+13 -3
View File
@@ -122,10 +122,14 @@ export function calculateProductRating(product, preferences) {
const weights = ratingWeights(preferences);
const hasBlockedAllergen = categoryScores.allergies.score === 0;
const allergenReviewRequired = categoryScores.allergies.needsReview === true;
const criticalAdditiveCount = categoryScores.ingredients.criticalAdditiveCount || 0;
const overallScore = hasBlockedAllergen
? 0
: capOverallScoreForCriticalAdditives(weightedCategoryScore(categoryScores, weights), criticalAdditiveCount);
: Math.min(
capOverallScoreForCriticalAdditives(weightedCategoryScore(categoryScores, weights), criticalAdditiveCount),
allergenReviewRequired ? 77 : 100
);
const overallStatus = statusFromScore(overallScore);
const reasons = Object.entries(categoryScores).map(([category, value]) => ({
@@ -138,6 +142,7 @@ export function calculateProductRating(product, preferences) {
productId: product.id,
overallStatus,
overallScore,
allergenReviewRequired,
reasons,
categoryScores
};
@@ -190,15 +195,20 @@ function rateAllergies(product, preferences) {
avoidAllergens.some((blockedAllergen) => blockedAllergen.toLowerCase() === allergen.toLowerCase())
);
const completeness = product.dataCompleteness || {};
const allergenDataMissing = completeness.allergens !== true || !Array.isArray(product.allergens) || product.allergens.length === 0;
const missingData = missingMessages([
[completeness.allergens === false, 'Allergenangaben fehlen in Open Food Facts.']
[avoidAllergens.length > 0 && allergenDataMissing, 'Allergenangaben fehlen oder sind nicht bestätigt. Verpackung prüfen.']
]);
if (matchingAllergens.length > 0) {
return withScore(0, `Enthält: ${matchingAllergens.join(', ')}.`, missingData);
}
return withScore(completeness.allergens === false ? 70 : 100, 'Keine hinterlegten Allergene gefunden.', missingData);
if (avoidAllergens.length > 0 && allergenDataMissing) {
return withScore(50, 'Allergenangaben fehlen – Verpackung prüfen.', missingData, { needsReview: true });
}
return withScore(100, 'Keine hinterlegten Allergene gefunden.', missingData);
}
function rateIngredients(product, preferences) {
+15 -2
View File
@@ -9,6 +9,13 @@ const keys = {
};
const legacyPrefix = 'shoppy.';
let pendingWrite = Promise.resolve();
function enqueueWrite(operation) {
const result = pendingWrite.then(operation);
pendingWrite = result.catch(() => {});
return result;
}
async function readJson(key, fallbackValue) {
try {
@@ -31,7 +38,7 @@ async function readJson(key, fallbackValue) {
async function writeJson(key, value) {
try {
await AsyncStorage.setItem(key, JSON.stringify(value));
await enqueueWrite(() => AsyncStorage.setItem(key, JSON.stringify(value)));
} catch (error) {
// Storage is best-effort; the in-memory state remains usable.
console.warn(`Shoppinguin konnte ${key} nicht speichern.`, error);
@@ -48,5 +55,11 @@ export const storageService = {
loadManualPrices: () => readJson(keys.manualPrices, {}),
saveManualPrices: (prices) => writeJson(keys.manualPrices, prices),
loadRecentProducts: () => readJson(keys.recentProducts, []),
saveRecentProducts: (products) => writeJson(keys.recentProducts, products)
saveRecentProducts: (products) => writeJson(keys.recentProducts, products),
clearProductHistoryAndCache: () => enqueueWrite(() => AsyncStorage.multiRemove([
keys.productCache,
keys.recentProducts,
keys.productCache.replace(/^shoppinguin\./, legacyPrefix),
keys.recentProducts.replace(/^shoppinguin\./, legacyPrefix)
]))
};