From e4513f9278581520bb4ab73d0ecf46f86f306cf3 Mon Sep 17 00:00:00 2001 From: phil Date: Sun, 5 Nov 2023 18:03:04 +0200 Subject: [PATCH] Get the result of the run for binary upload --- src/apps/binary_upload.rs | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/apps/binary_upload.rs b/src/apps/binary_upload.rs index 99e2871..f97ce21 100644 --- a/src/apps/binary_upload.rs +++ b/src/apps/binary_upload.rs @@ -1,6 +1,6 @@ use crate::helpers::{ refresh, - submission::{Submission, SubmissionResult}, + submission::{Submission, SubmissionPromise, SubmissionResult}, Challenges, Languages, }; use gloo_net::http; @@ -18,8 +18,9 @@ struct Binary { #[serde(default)] pub struct BinaryUpload { #[serde(skip)] - promise: Option>>, + promise: SubmissionPromise, #[serde(skip)] + last_result: SubmissionResult, url: String, #[serde(skip)] run: Submission, @@ -45,6 +46,7 @@ impl Default for BinaryUpload { binary_channel: channel(), submit: false, token_refresh_promise: None, + last_result: SubmissionResult::NotStarted, } } } @@ -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; + } + } } } @@ -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; + } } } }