AOSSIE-Org / AOSSIE-Org/PictoPy

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

Ouverte
#1,006 2 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
Langage dominant
Python
Étoiles
283
Forks
679
Merge moyen
7 j 2 h
PR mergées (30 j)
3

Description

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

Guide de contribution

Ouvrir le guide de contribution

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.