Fix version panel showing 'null' instead of timestamp, exclude current version from list, auto-refresh versions after upload

This commit is contained in:
2026-02-24 17:19:12 +08:00
parent 9c2809c195
commit e06f653606
3 changed files with 17 additions and 6 deletions

View File

@@ -1301,12 +1301,14 @@ def object_versions(bucket_name: str, object_key: str):
for v in resp.get("Versions", []):
if v.get("Key") != object_key:
continue
if v.get("IsLatest", False):
continue
versions.append({
"version_id": v.get("VersionId", ""),
"last_modified": v["LastModified"].isoformat() if v.get("LastModified") else None,
"size": v.get("Size", 0),
"etag": v.get("ETag", "").strip('"'),
"is_latest": v.get("IsLatest", False),
"is_latest": False,
})
return jsonify({"versions": versions})
except (ClientError, EndpointConnectionError, ConnectionClosedError) as exc:

View File

@@ -1,6 +1,6 @@
from __future__ import annotations
APP_VERSION = "0.3.0"
APP_VERSION = "0.3.1"
def get_version() -> str:

View File

@@ -1537,7 +1537,7 @@
const confirmVersionRestore = (row, version, label = null, onConfirm) => {
if (!version) return;
const timestamp = version.archived_at ? new Date(version.archived_at).toLocaleString() : version.version_id;
const timestamp = (version.archived_at || version.last_modified) ? new Date(version.archived_at || version.last_modified).toLocaleString() : version.version_id;
const sizeLabel = formatBytes(Number(version.size) || 0);
const reasonLabel = describeVersionReason(version.reason);
const targetLabel = label || row?.dataset.key || 'this object';
@@ -1610,7 +1610,7 @@
const latestCell = document.createElement('td');
if (item.latest) {
const ts = item.latest.archived_at ? new Date(item.latest.archived_at).toLocaleString() : item.latest.version_id;
const ts = (item.latest.archived_at || item.latest.last_modified) ? new Date(item.latest.archived_at || item.latest.last_modified).toLocaleString() : item.latest.version_id;
const sizeLabel = formatBytes(Number(item.latest.size) || 0);
latestCell.innerHTML = `<div class="small">${ts}</div><div class="text-muted small">${sizeLabel} · ${describeVersionReason(item.latest.reason)}</div>`;
} else {
@@ -1785,7 +1785,7 @@
badge.textContent = `#${versionNumber}`;
const title = document.createElement('div');
title.className = 'fw-semibold small';
const timestamp = entry.archived_at ? new Date(entry.archived_at).toLocaleString() : entry.version_id;
const timestamp = (entry.archived_at || entry.last_modified) ? new Date(entry.archived_at || entry.last_modified).toLocaleString() : entry.version_id;
title.textContent = timestamp;
heading.appendChild(badge);
heading.appendChild(title);
@@ -2816,7 +2816,16 @@
uploadFileInput.value = '';
}
loadObjects(false);
const previousKey = activeRow?.dataset.key || null;
loadObjects(false).then(() => {
if (previousKey) {
const newRow = document.querySelector(`[data-object-row][data-key="${CSS.escape(previousKey)}"]`);
if (newRow) {
selectRow(newRow);
if (versioningEnabled) loadObjectVersions(newRow, { force: true });
}
}
});
const successCount = uploadSuccessFiles.length;
const errorCount = uploadErrorFiles.length;