From 43bb2a00384004a2d227c3ef4c883e796a4c730c Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Thu, 25 Sep 2025 15:58:55 -0400 Subject: [PATCH] fix: Display last updated time from packages.json Adds logic to store and display the last updated time from packages.json in the UI. Introduces methods to set and format the update time, ensuring the displayed value reflects the actual data update timestamp. --- gh-pages-template/assets/js/app.js | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/gh-pages-template/assets/js/app.js b/gh-pages-template/assets/js/app.js index e48dae86..d254692e 100644 --- a/gh-pages-template/assets/js/app.js +++ b/gh-pages-template/assets/js/app.js @@ -104,6 +104,7 @@ class UIManager { this.assetCountElement = document.getElementById('assetCount'); this.updateTimeElement = document.getElementById('updateTime'); this.orgName = 'LizardByte'; + this.lastUpdated = null; // Store lastUpdated from packages.json } /** @@ -170,7 +171,28 @@ class UIManager { this.repoCountElement.textContent = repoCount; this.releaseCountElement.textContent = releaseCount; this.assetCountElement.textContent = assetCount; - this.updateTimeElement.textContent = new Date().toLocaleString(); + + if (this.lastUpdated) { // Only set update time if lastUpdated is set + this.updateTimeElement.textContent = this.formatUpdateTime(this.lastUpdated); + } + } + + /** + * Set the last updated time from packages.json + */ + setUpdateTime(lastUpdated) { + this.lastUpdated = lastUpdated; + this.updateTimeElement.textContent = this.formatUpdateTime(lastUpdated); + } + + /** + * Format the update time for display + */ + formatUpdateTime(isoString) { + if (!isoString) return '-'; + const date = new Date(isoString); + if (isNaN(date.getTime())) return isoString; + return date.toLocaleString(); } /** @@ -182,6 +204,7 @@ class UIManager { this.releaseCountElement.textContent = '-'; this.assetCountElement.textContent = '-'; this.updateTimeElement.textContent = '-'; + this.lastUpdated = null; } } @@ -244,6 +267,7 @@ class LizardByteAssetsApp { this.dataManager = new RepositoryDataManager(); this.uiManager = new UIManager(); this.filterManager = null; + this.lastUpdated = null; } /** @@ -255,7 +279,9 @@ class LizardByteAssetsApp { this.uiManager.showLoading(); // Load repository data from packages.json - await this.dataManager.loadRepositoryData(); + const data = await this.dataManager.loadRepositoryData(); + this.lastUpdated = data.lastUpdated; + this.uiManager.setUpdateTime(this.lastUpdated); // Initialize filter functionality first this.filterManager = new FilterManager(this.dataManager, this.uiManager);