rework installing page and add cancel install button (#2915)

* rework installing page and add cancel install button

* actually call cancel endpoint

* fix two bugs

* include translations in progress component

* cancellable installs

* fix: comments (#2916)

* fix: comments

* delete comments

* ensure trailing slash and no qp for new registry url

---------

Co-authored-by: Matt Hill <mattnine@protonmail.com>

* fix raspi

* bump sdk

---------

Co-authored-by: Aiden McClelland <me@drbonez.dev>
Co-authored-by: Alex Inkin <alexander@inkin.ru>
This commit is contained in:
Matt Hill
2025-04-30 13:50:08 -06:00
committed by GitHub
parent 5c473eb9cc
commit e6f0067728
37 changed files with 431 additions and 269 deletions

View File

@@ -154,13 +154,15 @@ pub async fn install(
})?
.s9pk;
let progress_tracker = FullProgressTracker::new();
let download_progress = progress_tracker.add_phase("Downloading".into(), Some(100));
let download = ctx
.services
.install(
ctx.clone(),
|| asset.deserialize_s9pk_buffered(ctx.client.clone()),
|| asset.deserialize_s9pk_buffered(ctx.client.clone(), download_progress),
None::<Never>,
None,
Some(progress_tracker),
)
.await?;
tokio::spawn(async move { download.await?.await });
@@ -188,10 +190,15 @@ pub async fn sideload(
ctx: RpcContext,
SideloadParams { session }: SideloadParams,
) -> Result<SideloadResponse, Error> {
let (upload, file) = upload(&ctx, session.clone()).await?;
let (err_send, mut err_recv) = oneshot::channel::<Error>();
let progress = Guid::new();
let progress_tracker = FullProgressTracker::new();
let (upload, file) = upload(
&ctx,
session.clone(),
progress_tracker.add_phase("Uploading".into(), Some(100)),
)
.await?;
let mut progress_listener = progress_tracker.stream(Some(Duration::from_millis(200)));
ctx.rpc_continuations
.add(
@@ -268,6 +275,24 @@ pub async fn sideload(
Ok(SideloadResponse { upload, progress })
}
#[derive(Debug, Clone, Deserialize, Serialize, Parser, TS)]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
pub struct CancelInstallParams {
pub id: PackageId,
}
#[instrument(skip_all)]
pub fn cancel_install(
ctx: RpcContext,
CancelInstallParams { id }: CancelInstallParams,
) -> Result<(), Error> {
if let Some(cancel) = ctx.cancellable_installs.mutate(|c| c.remove(&id)) {
cancel.send(()).ok();
}
Ok(())
}
#[derive(Deserialize, Serialize, Parser)]
pub struct QueryPackageParams {
id: PackageId,