From 7efe542dd19a5f1609ed92fa41e55e3e2cf421ba Mon Sep 17 00:00:00 2001 From: Till JS Date: Fri, 3 Apr 2026 16:45:49 +0200 Subject: [PATCH] chore: remove legacy migration and compat code (no users yet) - traces: remove migrateLegacyLocationData() and legacy timestamp field - context: remove legacy @[Title](ID) mention format support No live users exist, so backwards compatibility is unnecessary. Co-Authored-By: Claude Opus 4.6 (1M context) --- .../apps/mobile/utils/mentionProcessor.ts | 20 +--- .../apps/mobile/utils/locationService.ts | 103 +----------------- 2 files changed, 4 insertions(+), 119 deletions(-) diff --git a/apps/context/apps/mobile/utils/mentionProcessor.ts b/apps/context/apps/mobile/utils/mentionProcessor.ts index 907733dd1..308d06a72 100644 --- a/apps/context/apps/mobile/utils/mentionProcessor.ts +++ b/apps/context/apps/mobile/utils/mentionProcessor.ts @@ -11,9 +11,6 @@ export const MENTION_REGEX = /\[\[(.*?)\]\]/g; // Standard Markdown-Link-Format: [Titel](ID) export const MARKDOWN_LINK_REGEX = /\[(.*?)\]\((.*?)\)/g; -// Legacy format for backward compatibility -export const LEGACY_MENTION_REGEX = /@\[(.*?)\]\((.*?)\)/g; - /** * Extract all document mentions from markdown content */ @@ -38,15 +35,6 @@ export const extractMentions = (content: string): Array<{ title: string; id?: st }); } - // Legacy Format: @[Dokumenttitel](dokumentId) - const legacyRegex = new RegExp(LEGACY_MENTION_REGEX); - while ((match = legacyRegex.exec(content)) !== null) { - mentions.push({ - title: match[1], - id: match[2], - }); - } - return mentions; }; @@ -75,12 +63,6 @@ export const processMentionsInMarkdown = (content: string): string => { return match; }); - // Verarbeite das Legacy-Format @[Dokumenttitel](dokumentId) für Abwärtskompatibilität - processedContent = processedContent.replace(LEGACY_MENTION_REGEX, (match, title, id) => { - // Verwende einen speziellen Markdown-Link mit einem data-Attribut - return `${title}`; - }); - return processedContent; }; @@ -110,5 +92,5 @@ export const cleanMentionTags = (content: string): string => { * Check if text contains a potential mention */ export const containsPotentialMention = (text: string): boolean => { - return text.includes('[[') || text.includes('@') || (text.includes('[') && text.includes('](')); + return text.includes('[[') || (text.includes('[') && text.includes('](')); }; diff --git a/apps/traces/apps/mobile/utils/locationService.ts b/apps/traces/apps/mobile/utils/locationService.ts index 78e0419e9..88934830f 100644 --- a/apps/traces/apps/mobile/utils/locationService.ts +++ b/apps/traces/apps/mobile/utils/locationService.ts @@ -81,8 +81,6 @@ export interface LocationData { importedAt: number; // Wann importiert exifData?: any; // EXIF-Daten }; - // Legacy support - will be removed in future versions - timestamp?: number; } const LOCATION_HISTORY_KEY = 'location_history'; @@ -176,8 +174,6 @@ export const getCurrentLocation = async (): Promise => { verticalAccuracy: location.coords.altitudeAccuracy ?? undefined, isSignificantLocation: true, }, - // Legacy support - timestamp: location.timestamp, }; } catch (error) { console.error('Error getting location:', error); @@ -340,7 +336,6 @@ export const startLocationTracking = async ( verticalAccuracy: currentPos.coords.altitudeAccuracy ?? undefined, isSignificantLocation: true, }, - timestamp: currentPos.timestamp, }; // UI sofort aktualisieren @@ -406,7 +401,6 @@ export const startLocationTracking = async ( verticalAccuracy: location.coords.altitudeAccuracy ?? undefined, isSignificantLocation: true, }, - timestamp: location.timestamp, }; // UI immer aktualisieren @@ -596,7 +590,7 @@ export const getAddressFromCoordinates = async (latitude: number, longitude: num // Save location to history export const saveLocationToHistory = async (location: LocationData): Promise => { try { - const timestamp = location.timestamps?.recordedMs || location.timestamp || Date.now(); + const timestamp = location.timestamps?.recordedMs || Date.now(); logInfo('Speichere Standort in Verlauf', { coords: { lat: location.latitude, lng: location.longitude }, timestamp: new Date(timestamp).toISOString(), @@ -631,103 +625,12 @@ export const saveLocationToHistory = async (location: LocationData): Promise { - // If already migrated, return as is - if (data.id && data.timestamps) { - return data as LocationData; - } - - // Legacy data migration - const timestamp = data.timestamp || Date.now(); - const migrated: LocationData = { - id: generateUUID(), - latitude: data.latitude, - longitude: data.longitude, - timestamps: { - recorded: new Date(timestamp).toISOString(), - recordedMs: timestamp, - }, - accuracy: data.accuracy, - altitude: data.altitude, - speed: data.speed, - metadata: { - source: 'foreground', // Default assumption for legacy data - batteryLevel: undefined, - connectionType: 'cellular', - deviceMotion: getDeviceMotion(data.speed), - }, - quality: { - accuracyLevel: AccuracyLevel.Balanced, // Default assumption - horizontalAccuracy: data.accuracy || 0, - verticalAccuracy: undefined, - isSignificantLocation: true, - }, - // Legacy support - timestamp, - }; - - // Migrate address if exists - if (data.address) { - if (data.address.components) { - // Already new format - migrated.address = data.address; - } else { - // Legacy address format - convert to new format - const components = { - street: data.address.street, - houseNumber: data.address.streetNumber, - city: data.address.city, - postalCode: data.address.postalCode, - country: data.address.country, - countryCode: undefined, - }; - - // Build formatted address - const addressParts = [ - components.street && components.houseNumber - ? `${components.street} ${components.houseNumber}` - : components.street, - components.postalCode && components.city - ? `${components.postalCode} ${components.city}` - : components.city, - components.country, - ].filter(Boolean); - - migrated.address = { - formatted: addressParts.join(', '), - components, - confidence: 0.8, // Lower confidence for migrated data - }; - } - } - - return migrated; -}; - -// Get location history with automatic migration +// Get location history export const getLocationHistory = async (): Promise => { try { const historyString = await AsyncStorage.getItem(LOCATION_HISTORY_KEY); if (!historyString) return []; - - const rawHistory = JSON.parse(historyString); - - // Check if migration is needed - const needsMigration = rawHistory.some((item: any) => !item.id || !item.timestamps); - - if (needsMigration) { - logInfo('Migriere Standortdaten zu neuem Format', { count: rawHistory.length }); - const migratedHistory = rawHistory.map(migrateLegacyLocationData); - - // Save migrated data back - await AsyncStorage.setItem(LOCATION_HISTORY_KEY, JSON.stringify(migratedHistory)); - logInfo('Standortdaten-Migration abgeschlossen'); - - return migratedHistory; - } - - return rawHistory as LocationData[]; + return JSON.parse(historyString) as LocationData[]; } catch (error) { logError('Fehler beim Laden des Standortverlaufs', error); return [];