diff options
Diffstat (limited to 'server.mjs')
| -rw-r--r-- | server.mjs | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -646,12 +646,14 @@ const server = http.createServer(async (req, res) => { if (path === "/api/admin/photos") { const q = (url.searchParams.get("q") || "").trim().toLowerCase() const limit = Math.min(100, Number(url.searchParams.get("limit") || 30)) + const recent = url.searchParams.get("recent") === "1" let list = Array.from(state.byId.values()) if (q) { const n = Number(q) list = list.filter((p) => (n && p.id === n) || (p.title || "").toLowerCase().includes(q)) } - list.sort((a, b) => (a.title || "").localeCompare(b.title || "")) + if (recent) list.sort((a, b) => b.id - a.id) + else list.sort((a, b) => (a.title || "").localeCompare(b.title || "")) return json(res, 200, { photos: list.slice(0, limit).map((p) => ({ id: p.id, title: p.title, thumb: p.thumb, date: p.date })) }) } if (path === "/api/admin/graph/reset") { |
