feat: PWA icon + download count increment on market install
This commit is contained in:
@@ -606,6 +606,21 @@ async def api_market_install(id: str = "", filename: str = ""):
|
||||
zip_data = resp.content
|
||||
from models.dashboard import dashboard_manager
|
||||
ok = dashboard_manager.import_theme_zip(zip_data)
|
||||
|
||||
if ok:
|
||||
try:
|
||||
async with httpx.AsyncClient(timeout=5) as client2:
|
||||
# Get current downloads
|
||||
r = await client2.get(f"{url}/api/collections/dashboards/records/{id}")
|
||||
current = r.json().get("downloads", 0) or 0
|
||||
# Increment
|
||||
await client2.patch(
|
||||
f"{url}/api/collections/dashboards/records/{id}",
|
||||
json={"downloads": current + 1}
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
return {"ok": ok}
|
||||
except Exception as e:
|
||||
return {"ok": False, "error": str(e)}
|
||||
|
||||
Reference in New Issue
Block a user