AOSSIE-Org / AOSSIE-Org/PictoPy

Feat: Real-Time Image Library Synchronization after new image add in Local

Abierto
#1,006 2 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
Python
Estrellas
283
Forks
679
Merge medio
7 d 2 h
PR fusionados (30 d)
3

Descripción

### 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

Image

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

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.