feat: wire up album filtering to photo queue

Album selection now controls which photos are displayed.
Uses POST /api/search/random with albumIds filter (Immich v3
compatible) instead of the removed GET /api/albums/{id} assets.

- Add albumIds parameter to fetchRandomAssets/fetchRandomAssetIds
- syncFromAlbums: fetch random assets filtered by selected albums
- syncFromAllPhotos: preserve existing global random behavior
- Album mode reshuffles on exhaustion instead of re-fetching
- 24h resync checks album assetCounts for changes before re-fetch
- requestSync + albums_changed action triggers queue rebuild on save
- timerWakeCycle respects album selection
- Discard stale pre-renders on album change

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-03 22:46:17 -04:00
parent 033ab8d33b
commit 3483b9bef8
6 changed files with 202 additions and 41 deletions

View File

@@ -1,5 +1,6 @@
#include <Arduino.h>
#include <M5Unified.h>
#include <ArduinoJson.h>
#include <esp_heap_caps.h>
#include <freertos/FreeRTOS.h>
#include <freertos/task.h>
@@ -238,9 +239,10 @@ void displayTask(void* param) {
xSemaphoreGive(stateMutex);
}
// Periodic re-sync
// Periodic re-sync (includes album change requests)
if (photoQueue.needsResync() && wifiManager.isConnected()) {
photoQueue.sync();
discardPending(pending);
}
// --- Phase 1: Display ---
@@ -343,6 +345,9 @@ void webActionCallback(const String& action) {
slideshowPlaying = false;
} else if (action == "play") {
slideshowPlaying = true;
} else if (action == "albums_changed") {
photoQueue.requestSync();
refreshRequested = true;
}
xSemaphoreGive(stateMutex);
}
@@ -368,11 +373,25 @@ void timerWakeCycle() {
imagePipeline.setBlueNoiseEnabled(s.dither_noise != 0);
displayManager.setTranslucent(s.meta_translucent != 0);
// Fetch a small batch of random assets
// Fetch assets — respect album selection
static constexpr int TIMER_WAKE_RETRIES = 5;
bool displayed = false;
std::vector<String> ids = immichClient.fetchRandomAssetIds(10);
// Parse selected album IDs from settings
std::vector<String> albumIds;
{
JsonDocument doc;
DeserializationError err = deserializeJson(doc, s.albums_json);
if (!err) {
JsonArray arr = doc.as<JsonArray>();
for (JsonVariant v : arr) {
albumIds.push_back(v.as<String>());
}
}
}
std::vector<String> ids = immichClient.fetchRandomAssetIds(10, albumIds);
for (int i = 0; i < (int)ids.size() && i < TIMER_WAKE_RETRIES && !displayed; i++) {
AssetInfo info = immichClient.fetchAssetInfo(ids[i]);