Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions kinode/packages/app_store/app_store/src/http_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ use crate::{

use kinode_process_lib::{
http::{self, server, Method, StatusCode},
Address, LazyLoadBlob, PackageId, Request,
println, Address, LazyLoadBlob, PackageId, Request, SendError, SendErrorKind,
};
use kinode_process_lib::{SendError, SendErrorKind};
use serde_json::json;
use std::{collections::HashMap, str::FromStr};

Expand Down Expand Up @@ -266,7 +265,7 @@ fn serve_paths(
}
}
// GET detail about a specific app
// update a downloaded app: PUT
// DELETE uninstall an app
"/apps/:id" => {
let Ok(package_id) = get_package_id(url_params) else {
return Ok((
Expand Down Expand Up @@ -294,6 +293,7 @@ fn serve_paths(
Method::DELETE => {
// uninstall an app
crate::utils::uninstall(state, &package_id)?;
println!("successfully uninstalled {:?}", package_id);
Ok((
StatusCode::NO_CONTENT,
None,
Expand Down Expand Up @@ -474,7 +474,10 @@ fn serve_paths(
state,
&our.node().to_string(),
) {
Ok(_) => Ok((StatusCode::CREATED, None, vec![])),
Ok(_) => {
println!("successfully installed package: {:?}", process_package_id);
Ok((StatusCode::CREATED, None, vec![]))
}
Err(e) => Ok((
StatusCode::SERVICE_UNAVAILABLE,
None,
Expand Down
20 changes: 12 additions & 8 deletions kinode/packages/app_store/ui/src/pages/DownloadPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default function DownloadPage() {
fetchData(id);
clearAllActiveDownloads();
}
}, [id, fetchData, clearAllActiveDownloads]);
}, [id, fetchData, clearAllActiveDownloads, installedApp]);

const handleMirrorSelect = useCallback((mirror: string, status: boolean | null | 'http') => {
setSelectedMirror(mirror);
Expand Down Expand Up @@ -75,19 +75,22 @@ export default function DownloadPage() {
if (!app || !selectedVersion) return false;
const versionData = sortedVersions.find(v => v.version === selectedVersion);
if (!versionData) return false;
const downloadKey = `${app.package_id.package_name}:${selectedMirror}:${versionData.hash}`;
return !!activeDownloads[downloadKey];
}, [app, selectedVersion, sortedVersions, selectedMirror, activeDownloads]);

// Check for any active download for this app, not just the selected version
return Object.keys(activeDownloads).some(key => key.startsWith(`${app.package_id.package_name}:`));
}, [app, selectedVersion, sortedVersions, activeDownloads]);

const downloadProgress = useMemo(() => {
if (!isDownloading || !app || !selectedVersion) return null;
const versionData = sortedVersions.find(v => v.version === selectedVersion);
if (!versionData) return null;
const downloadKey = `${app.package_id.package_name}:${selectedMirror}:${versionData.hash}`;
const progress = activeDownloads[downloadKey];
// Find the active download for this app
const activeDownloadKey = Object.keys(activeDownloads).find(key =>
key.startsWith(`${app.package_id.package_name}:`)
);
if (!activeDownloadKey) return null;
const progress = activeDownloads[activeDownloadKey];
return progress ? Math.round((progress.downloaded / progress.total) * 100) : 0;
}, [isDownloading, app, selectedVersion, sortedVersions, selectedMirror, activeDownloads]);
}, [isDownloading, app, selectedVersion, sortedVersions, activeDownloads]);

const isCurrentVersionInstalled = useMemo(() => {
if (!app || !selectedVersion || !installedApp) return false;
Expand Down Expand Up @@ -170,6 +173,7 @@ export default function DownloadPage() {
{sortedVersions.map(({ version }, index) => (
<option key={version} value={version}>
{version} {index === 0 ? "(newest)" : ""}
{installedApp && installedApp.our_version_hash === sortedVersions[index].hash ? " (installed)" : ""}
</option>
))}
</select>
Expand Down