AOSSIE-Org / AOSSIE-Org/PictoPy
Feat: Real-Time Image Library Synchronization after new image add in Local
- Lingua principale
- Python
- Stelle
- 283
- Fork
- 679
- Merge medio
- 7g 2h
- PR unite (30g)
- 3
Descrizione
### Describe the feature
# Real-Time Image Library Synchronization
## Problem
Currently, PictoPy does not update the gallery in real time when images are added via the OS file system (Explorer/Finder).
- The `sync-microservice` exists but only logs file events
- Newly added images appear only after restarting the application
- This makes the application feel static and unreliable
---
## Goal
Enable real-time library synchronization so that when a new image is added to the library folder:
- The image is detected immediately
- The image is inserted into the database instantly
- The frontend shows a toast notification
- The gallery updates without requiring an application restart
**Example notification:**
New photo detected: IMG_1234.jpg
---
## Proposed Workflow (High-Level)
```
OS File System
↓
sync-microservice (File Watcher)
↓
Backend API (db_insert_image)
↓
Tauri Event
↓
Frontend Toast Notification
↓
Gallery Auto-Refresh
```
---
## Implementation Plan
### 1. Watch Library Folder (sync-microservice)
- Use a cross-platform file watcher (e.g. `chokidar`)
- Watch the user-configured library path (no hardcoded paths)
- Detect only supported image formats (`.jpg`, `.jpeg`, `.png`, `.webp`)
**Files to change:**
- `sync-microservice/index.ts` (update)
- `sync-microservice/fileWatcher.ts` (new)
---
### 2. Backend API – Insert Image Immediately
- Add a new endpoint:
```
POST /sync/new-image
```
- Reuse existing `db_insert_image` logic
- Prevent duplicate entries using a unique path or hash
**Files to change:**
- `backend/routes/sync.routes.ts` (new)
- `backend/controllers/sync.controller.ts` (new)
---
### 3. Emit Real-Time Event to Frontend
- After inserting the image into the database, emit a Tauri event
- Event name: `image-added`
- Payload structure:
```json
{
"id": "image_id",
"name": "IMG_1234.jpg",
"path": "/absolute/path/to/image"
}
```
## 4. Files to change:
src-tauri/src/main.rs (update – event emission only)
### 5. Frontend – Toast Notification and Auto Refresh
Listen for the image-added event
Display a toast notification
Refresh gallery data automatically without user interaction
## Files to change:
```
frontend/src/App.tsx or frontend/src/Home.tsx (update)
frontend/src/hooks/useImageEvents.ts (new)
```
### Add ScreenShots
## demo screenshot
hello @rahulharpal1603 sir
Please assign this issue to me
### Record
- [x] I agree to follow this project's Code of Conduct
- [x] I want to work on this issue
Guida per i contributori
Apri la guida per i contributori
Valutazione
Questa issue non è ancora stata valutata.