feat: remove attempt
This commit is contained in:
parent
2e83efcf12
commit
3740224f79
@ -276,24 +276,27 @@ fn WithUserInteraction(
|
||||
});
|
||||
|
||||
let onclick_flash = move |_| {
|
||||
let attempt = if ui_is_flash.get() { None } else { Some(models::Attempt::Flash) };
|
||||
submit_attempt.dispatch(RonEncoded(server_functions::UpsertTodaysAttempt {
|
||||
wall_uid: wall_uid.get(),
|
||||
problem_uid: problem_uid.get(),
|
||||
attempt: models::Attempt::Flash,
|
||||
attempt,
|
||||
}));
|
||||
};
|
||||
let onclick_send = move |_| {
|
||||
let attempt = if ui_is_send.get() { None } else { Some(models::Attempt::Send) };
|
||||
submit_attempt.dispatch(RonEncoded(server_functions::UpsertTodaysAttempt {
|
||||
wall_uid: wall_uid.get(),
|
||||
problem_uid: problem_uid.get(),
|
||||
attempt: models::Attempt::Send,
|
||||
attempt,
|
||||
}));
|
||||
};
|
||||
let onclick_attempt = move |_| {
|
||||
let attempt = if ui_is_attempt.get() { None } else { Some(models::Attempt::Attempt) };
|
||||
submit_attempt.dispatch(RonEncoded(server_functions::UpsertTodaysAttempt {
|
||||
wall_uid: wall_uid.get(),
|
||||
problem_uid: problem_uid.get(),
|
||||
attempt: models::Attempt::Attempt,
|
||||
attempt,
|
||||
}));
|
||||
};
|
||||
|
||||
|
@ -217,7 +217,7 @@ pub(crate) async fn get_problem_by_uid(
|
||||
pub(crate) async fn upsert_todays_attempt(
|
||||
wall_uid: models::WallUid,
|
||||
problem_uid: models::ProblemUid,
|
||||
attempt: models::Attempt,
|
||||
attempt: Option<models::Attempt>,
|
||||
) -> Result<RonEncoded<models::UserInteraction>, ServerFnError> {
|
||||
use crate::server::db::Database;
|
||||
use crate::server::db::DatabaseOperationError;
|
||||
@ -233,7 +233,7 @@ pub(crate) async fn upsert_todays_attempt(
|
||||
DatabaseOperation(DatabaseOperationError),
|
||||
}
|
||||
|
||||
async fn inner(wall_uid: models::WallUid, problem_uid: models::ProblemUid, attempt: models::Attempt) -> Result<UserInteraction, Error> {
|
||||
async fn inner(wall_uid: models::WallUid, problem_uid: models::ProblemUid, attempt: Option<models::Attempt>) -> Result<UserInteraction, Error> {
|
||||
let db = expect_context::<Database>();
|
||||
|
||||
let user_interaction = db
|
||||
@ -260,7 +260,9 @@ pub(crate) async fn upsert_todays_attempt(
|
||||
}
|
||||
}
|
||||
|
||||
user_interaction.attempted_on.insert(chrono::Utc::now(), attempt);
|
||||
if let Some(attempt) = attempt {
|
||||
user_interaction.attempted_on.insert(chrono::Utc::now(), attempt);
|
||||
}
|
||||
|
||||
user_table.insert(key, user_interaction.clone())?;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user