fix: recognize displayed terminal versions and clean obsolete gallery remnants
This commit is contained in:
@@ -256,7 +256,10 @@ def install_libraries(app, service):
|
||||
offset: int = Query(0, ge=0),
|
||||
limit: int = Query(50, ge=1, le=200),
|
||||
):
|
||||
if not any(t["id"] == terminal_id for t in libraries.terminals()):
|
||||
terminal = next(
|
||||
(t for t in libraries.terminals() if t["id"] == terminal_id), None
|
||||
)
|
||||
if terminal is None:
|
||||
raise FlowError(E.NOT_FOUND, "Terminal not found", 404)
|
||||
binding = libraries.binding(terminal_id)
|
||||
if not binding:
|
||||
@@ -269,6 +272,17 @@ def install_libraries(app, service):
|
||||
+ " ORDER BY v.created_at DESC,v.asset_id LIMIT ? OFFSET ?",
|
||||
(*args, limit, offset),
|
||||
)
|
||||
current_asset = None
|
||||
if rows and terminal["transport_supported"]:
|
||||
try:
|
||||
device = service.registry.get(terminal_id).device()
|
||||
if device.status == "online":
|
||||
current = service.current_content(terminal_id, device=device)
|
||||
if current["synced"] and current["source_known"]:
|
||||
current_asset = current["asset_id"]
|
||||
except FlowError:
|
||||
# Offline devices must not hide locally generated versions.
|
||||
pass
|
||||
items = []
|
||||
for row in rows:
|
||||
version = next(
|
||||
@@ -292,6 +306,7 @@ def install_libraries(app, service):
|
||||
{
|
||||
**version,
|
||||
"operation": operation,
|
||||
"current": row["asset_id"] == current_asset,
|
||||
"delivery_status": operation["status"]
|
||||
if operation
|
||||
else "GENERATED",
|
||||
|
||||
Reference in New Issue
Block a user