1
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
use super::*;
|
||||
use crate::mapper::*;
|
||||
use crate::module_bindings::delete_puzzle_work_procedure::delete_puzzle_work;
|
||||
use crate::module_bindings::record_puzzle_work_like_procedure::record_puzzle_work_like;
|
||||
use crate::module_bindings::remix_puzzle_work_procedure::remix_puzzle_work;
|
||||
|
||||
impl SpacetimeClient {
|
||||
@@ -55,6 +56,31 @@ impl SpacetimeClient {
|
||||
.await
|
||||
}
|
||||
|
||||
pub async fn save_puzzle_form_draft(
|
||||
&self,
|
||||
input: PuzzleFormDraftSaveRecordInput,
|
||||
) -> Result<PuzzleAgentSessionRecord, SpacetimeClientError> {
|
||||
let procedure_input = PuzzleFormDraftSaveInput {
|
||||
session_id: input.session_id,
|
||||
owner_user_id: input.owner_user_id,
|
||||
seed_text: input.seed_text,
|
||||
saved_at_micros: input.saved_at_micros,
|
||||
};
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection.procedures().save_puzzle_form_draft_then(
|
||||
procedure_input,
|
||||
move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
||||
.and_then(map_puzzle_agent_session_procedure_result);
|
||||
send_once(&sender, mapped);
|
||||
},
|
||||
);
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
pub async fn submit_puzzle_agent_message(
|
||||
&self,
|
||||
input: PuzzleAgentMessageSubmitRecordInput,
|
||||
@@ -143,6 +169,7 @@ impl SpacetimeClient {
|
||||
let procedure_input = PuzzleGeneratedImagesSaveInput {
|
||||
session_id: input.session_id,
|
||||
owner_user_id: input.owner_user_id,
|
||||
level_id: input.level_id,
|
||||
candidates_json: input.candidates_json,
|
||||
saved_at_micros: input.saved_at_micros,
|
||||
};
|
||||
@@ -168,6 +195,7 @@ impl SpacetimeClient {
|
||||
let procedure_input = PuzzleSelectCoverImageInput {
|
||||
session_id: input.session_id,
|
||||
owner_user_id: input.owner_user_id,
|
||||
level_id: input.level_id,
|
||||
candidate_id: input.candidate_id,
|
||||
selected_at_micros: input.selected_at_micros,
|
||||
};
|
||||
@@ -196,9 +224,12 @@ impl SpacetimeClient {
|
||||
work_id: input.work_id,
|
||||
profile_id: input.profile_id,
|
||||
author_display_name: input.author_display_name,
|
||||
work_title: input.work_title,
|
||||
work_description: input.work_description,
|
||||
level_name: input.level_name,
|
||||
summary: input.summary,
|
||||
theme_tags: input.theme_tags,
|
||||
levels_json: input.levels_json,
|
||||
published_at_micros: input.published_at_micros,
|
||||
};
|
||||
|
||||
@@ -261,11 +292,14 @@ impl SpacetimeClient {
|
||||
let procedure_input = PuzzleWorkUpsertInput {
|
||||
profile_id: input.profile_id,
|
||||
owner_user_id: input.owner_user_id,
|
||||
work_title: input.work_title,
|
||||
work_description: input.work_description,
|
||||
level_name: input.level_name,
|
||||
summary: input.summary,
|
||||
theme_tags: input.theme_tags,
|
||||
cover_image_src: input.cover_image_src,
|
||||
cover_asset_id: input.cover_asset_id,
|
||||
levels_json: input.levels_json,
|
||||
updated_at_micros: input.updated_at_micros,
|
||||
};
|
||||
|
||||
@@ -341,6 +375,30 @@ impl SpacetimeClient {
|
||||
.await
|
||||
}
|
||||
|
||||
pub async fn record_puzzle_work_like(
|
||||
&self,
|
||||
input: PuzzleWorkLikeReportRecordInput,
|
||||
) -> Result<PuzzleWorkProfileRecord, SpacetimeClientError> {
|
||||
let procedure_input = PuzzleWorkLikeRecordInput {
|
||||
profile_id: input.profile_id,
|
||||
user_id: input.user_id,
|
||||
liked_at_micros: input.liked_at_micros,
|
||||
};
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection.procedures().record_puzzle_work_like_then(
|
||||
procedure_input,
|
||||
move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
||||
.and_then(map_puzzle_work_procedure_result);
|
||||
send_once(&sender, mapped);
|
||||
},
|
||||
);
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
pub async fn remix_puzzle_work(
|
||||
&self,
|
||||
input: PuzzleWorkRemixRecordInput,
|
||||
@@ -377,6 +435,7 @@ impl SpacetimeClient {
|
||||
run_id: input.run_id,
|
||||
owner_user_id: input.owner_user_id,
|
||||
profile_id: input.profile_id,
|
||||
level_id: input.level_id,
|
||||
started_at_micros: input.started_at_micros,
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user