Skip to content

Commit

Permalink
Get the result of the run for binary upload
Browse files Browse the repository at this point in the history
  • Loading branch information
bitbrain-za committed Nov 5, 2023
1 parent 7376757 commit e4513f9
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions src/apps/binary_upload.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::helpers::{
refresh,
submission::{Submission, SubmissionResult},
submission::{Submission, SubmissionPromise, SubmissionResult},
Challenges, Languages,
};
use gloo_net::http;
Expand All @@ -18,8 +18,9 @@ struct Binary {
#[serde(default)]
pub struct BinaryUpload {
#[serde(skip)]
promise: Option<Promise<Result<SubmissionResult, String>>>,
promise: SubmissionPromise,
#[serde(skip)]
last_result: SubmissionResult,
url: String,
#[serde(skip)]
run: Submission,
Expand All @@ -45,6 +46,7 @@ impl Default for BinaryUpload {
binary_channel: channel(),
submit: false,
token_refresh_promise: None,
last_result: SubmissionResult::NotStarted,
}
}
}
Expand Down Expand Up @@ -123,6 +125,18 @@ impl super::App for BinaryUpload {
refresh::RefreshStatus::Failed(_) => {}
_ => (),
}

let submission = Submission::check_submit_promise(&mut self.promise);
match submission {
SubmissionResult::NotStarted => {}
SubmissionResult::NotAuthorized => {
self.token_refresh_promise = refresh::submit_refresh(&self.url);
self.last_result = submission;
}
_ => {
self.last_result = submission;
}
}
}
}

Expand Down Expand Up @@ -171,10 +185,12 @@ impl super::View for BinaryUpload {
}
});
}
ui.separator();

if ui.button("Submit").clicked() {
self.submit = true;
if "Select Binary" != &self.run.filename {
ui.separator();
if ui.button("Submit").clicked() {
self.submit = true;
}
}
}
}
Expand Down

0 comments on commit e4513f9

Please sign in to comment.