From 3df0bac9dc7dfc230e2d5b4e32ad563b606d7ab4 Mon Sep 17 00:00:00 2001 From: Nariman Jelveh Date: Sun, 3 Aug 2025 18:39:14 -0700 Subject: [PATCH] count websites and workers at start --- src/dev-center/js/websites.js | 9 +++++---- src/dev-center/js/workers.js | 7 +++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/dev-center/js/websites.js b/src/dev-center/js/websites.js index ba66153e6..d67685551 100644 --- a/src/dev-center/js/websites.js +++ b/src/dev-center/js/websites.js @@ -40,6 +40,10 @@ window.refresh_websites_list = async (show_loading = false) => { async function init_websites() { + puter.hosting.list().then((websites) => { + window.websites = websites; + count_websites(); + }); } $(document).on('click', '.create-a-website-btn', async function (e) { @@ -173,10 +177,7 @@ function sort_websites() { } function count_websites() { - let count = 0; - $('.website-card').each(function () { - count++; - }) + let count = window.websites.length; $('.website-count').html(count ? count : ''); return count; } diff --git a/src/dev-center/js/workers.js b/src/dev-center/js/workers.js index f8b585e8f..e7fe0b0b4 100644 --- a/src/dev-center/js/workers.js +++ b/src/dev-center/js/workers.js @@ -46,6 +46,8 @@ window.refresh_worker_list = async (show_loading = false) => { async function init_workers() { + window.workers = await puter.workers.list(); + count_workers(); } $(document).on('click', '.create-a-worker-btn', async function (e) { @@ -206,10 +208,7 @@ function sort_workers() { } function count_workers() { - let count = 0; - $('.worker-card').each(function () { - count++; - }) + let count = window.workers.length; $('.worker-count').html(count ? count : ''); return count; }