mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-28 14:57:42 +02:00
refactor: restructure
monorepo with apps/ and services/ directories
This commit is contained in:
parent
25824ed0ac
commit
ff80aeec1f
4062 changed files with 2592 additions and 1278 deletions
|
|
@ -1,196 +0,0 @@
|
|||
# Refactoring Summary - High Priority Items
|
||||
|
||||
Dieses Dokument fasst die durchgeführten Refactorings zusammen (Datum: 2025-10-06).
|
||||
|
||||
## ✅ Abgeschlossene High Priority Tasks
|
||||
|
||||
### 1. Fix missing `createBatch` import in generate.tsx
|
||||
|
||||
**Problem**: Die Funktion `createBatch` wurde in `app/(tabs)/generate.tsx` verwendet, war aber nicht aus dem Store importiert.
|
||||
|
||||
**Lösung**: Import aus `useBatchStore()` hinzugefügt:
|
||||
```typescript
|
||||
const {
|
||||
isBatchModalOpen,
|
||||
openBatchModal,
|
||||
closeBatchModal,
|
||||
activeBatches,
|
||||
createBatch // ✅ Hinzugefügt
|
||||
} = useBatchStore();
|
||||
```
|
||||
|
||||
**Datei**: `app/(tabs)/generate.tsx:50-54`
|
||||
|
||||
---
|
||||
|
||||
### 2. Löschen von store/store.ts (Bears demo)
|
||||
|
||||
**Problem**: Der `bears` Store war ein Demo-Beispiel und wurde nirgendwo im Projekt verwendet.
|
||||
|
||||
**Lösung**: Datei komplett gelöscht.
|
||||
|
||||
**Gelöschte Datei**: `store/store.ts`
|
||||
|
||||
---
|
||||
|
||||
### 3. Error Boundaries implementieren
|
||||
|
||||
**Problem**: Keine React Error Boundaries im Projekt vorhanden. Bei Fehlern würde die gesamte App abstürzen ohne Feedback an den User.
|
||||
|
||||
**Lösung**:
|
||||
- Neue `ErrorBoundary` Komponente erstellt mit:
|
||||
- Schönem Fehler-UI
|
||||
- "Erneut versuchen" Button
|
||||
- Development-Mode: Detaillierte Error-Logs
|
||||
- Production-Mode: Benutzerfreundliche Fehlermeldungen
|
||||
- HOC `withErrorBoundary` für einfaches Wrappen von Komponenten
|
||||
|
||||
- Error Boundary im Root Layout integriert für App-weites Error Handling
|
||||
|
||||
**Neue Datei**: `components/ErrorBoundary.tsx`
|
||||
|
||||
**Geänderte Datei**: `app/_layout.tsx`
|
||||
|
||||
**Features**:
|
||||
- ✅ Catch React-Fehler auf höchster Ebene
|
||||
- ✅ Zeigt benutzerfreundliche Fehleranzeige
|
||||
- ✅ Reset-Funktion zum erneuten Versuchen
|
||||
- ✅ Optional: Custom Fallback UI
|
||||
- ✅ Optional: Error-Callback für Logging
|
||||
|
||||
---
|
||||
|
||||
### 4. Constants zentralisieren
|
||||
|
||||
**Problem**: Magic Numbers und Konstanten waren über verschiedene Dateien verstreut:
|
||||
- `PAGE_SIZE = 20` in `index.tsx`
|
||||
- `PAGE_SIZE = 30` in `explore.tsx`
|
||||
- `TAB_BAR_HEIGHT = 49` in `explore.tsx`
|
||||
- Verschiedene Padding-Werte hardcodiert
|
||||
|
||||
**Lösung**: Drei neue Konstanten-Dateien erstellt:
|
||||
|
||||
#### `constants/pagination.ts`
|
||||
```typescript
|
||||
export const PAGINATION = {
|
||||
GALLERY_PAGE_SIZE: 20,
|
||||
EXPLORE_PAGE_SIZE: 30,
|
||||
INITIAL_LOAD: 20,
|
||||
LOAD_MORE_THRESHOLD: 0.5,
|
||||
} as const;
|
||||
```
|
||||
|
||||
#### `constants/layout.ts`
|
||||
```typescript
|
||||
export const LAYOUT = {
|
||||
TAB_BAR_HEIGHT: 49,
|
||||
QUICK_GENERATE_BAR_HEIGHT: 60,
|
||||
FILTER_BAR_HEIGHT: 50,
|
||||
PADDING: {
|
||||
xs: 4, sm: 8, md: 16, lg: 24, xl: 32,
|
||||
},
|
||||
GRID: {
|
||||
COLUMN_SPACING: 48,
|
||||
COLUMNS: 2,
|
||||
},
|
||||
} as const;
|
||||
|
||||
export const ANIMATION = {
|
||||
SHORT: 150,
|
||||
MEDIUM: 250,
|
||||
LONG: 350,
|
||||
} as const;
|
||||
```
|
||||
|
||||
#### `constants/index.ts`
|
||||
```typescript
|
||||
export * from './colors';
|
||||
export * from './layout';
|
||||
export * from './pagination';
|
||||
```
|
||||
|
||||
**Geänderte Dateien**:
|
||||
- `app/(tabs)/index.tsx` - Verwendet jetzt `PAGINATION` und `LAYOUT`
|
||||
- `app/(tabs)/explore.tsx` - Verwendet jetzt `PAGINATION`, `LAYOUT` und `ANIMATION`
|
||||
|
||||
**Vorteile**:
|
||||
- ✅ Single source of truth für alle Konstanten
|
||||
- ✅ Einfachere Wartung
|
||||
- ✅ Type-safe mit `as const`
|
||||
- ✅ Zentrale Stelle für Änderungen
|
||||
- ✅ Bessere Lesbarkeit im Code
|
||||
|
||||
---
|
||||
|
||||
## 🔧 Zusätzliche Code-Qualitäts-Verbesserungen
|
||||
|
||||
### ESLint Warnings behoben
|
||||
|
||||
**Behobene Warnings**:
|
||||
1. ✅ Doppelte Imports von `react-native-safe-area-context` in `explore.tsx`
|
||||
2. ✅ Ungenutzte Variable `Ionicons` in `index.tsx`
|
||||
3. ✅ Ungenutzte Variablen in `generate.tsx`:
|
||||
- `setSteps`
|
||||
- `setGuidanceScale`
|
||||
- `currentBatch`
|
||||
- `showBatchProgress`
|
||||
- `batchId`
|
||||
4. ✅ Ungenutzte Variable `EmptyState` in `index.tsx`
|
||||
|
||||
---
|
||||
|
||||
## 📊 Statistik
|
||||
|
||||
- **Dateien erstellt**: 4
|
||||
- `components/ErrorBoundary.tsx`
|
||||
- `constants/pagination.ts`
|
||||
- `constants/layout.ts`
|
||||
- `constants/index.ts`
|
||||
|
||||
- **Dateien gelöscht**: 1
|
||||
- `store/store.ts`
|
||||
|
||||
- **Dateien geändert**: 3
|
||||
- `app/_layout.tsx`
|
||||
- `app/(tabs)/index.tsx`
|
||||
- `app/(tabs)/explore.tsx`
|
||||
- `app/(tabs)/generate.tsx`
|
||||
|
||||
- **ESLint Warnings behoben**: 9
|
||||
- **Zeilen Code**: ~120 neue Zeilen (ErrorBoundary + Constants)
|
||||
|
||||
---
|
||||
|
||||
## 🚀 Nächste Schritte (Medium Priority)
|
||||
|
||||
Die folgenden Refactorings könnten als nächstes angegangen werden:
|
||||
|
||||
1. **FlatList Performance-Props hinzufügen**
|
||||
- `removeClippedSubviews={true}`
|
||||
- `maxToRenderPerBatch={10}`
|
||||
- `windowSize={5}`
|
||||
- `getItemLayout` für bessere Performance
|
||||
|
||||
2. **Optimistic Updates für Likes/Favorites**
|
||||
- UI sofort updaten
|
||||
- DB im Hintergrund
|
||||
- Rollback bei Fehler
|
||||
|
||||
3. **Custom Hooks extrahieren**
|
||||
- `useImageFetching` aus `index.tsx`
|
||||
- `usePagination` (wiederverwendbar)
|
||||
- `useKeyboardAnimation` aus `explore.tsx`
|
||||
|
||||
4. **Loading/Empty States zentralisieren**
|
||||
- `components/LoadingScreen.tsx`
|
||||
- `components/EmptyState.tsx`
|
||||
|
||||
---
|
||||
|
||||
## 💡 Best Practices etabliert
|
||||
|
||||
- ✅ **Error Handling**: App-weite Error Boundary
|
||||
- ✅ **Code Organization**: Konstanten zentralisiert
|
||||
- ✅ **Type Safety**: `as const` für unveränderbare Konstanten
|
||||
- ✅ **Import Hygiene**: Keine doppelten Imports
|
||||
- ✅ **Clean Code**: Ungenutzte Variablen entfernt
|
||||
Loading…
Add table
Add a link
Reference in a new issue