Skip to content

Commit

Permalink
uplaoad video event changes - add post_id (#263)
Browse files Browse the repository at this point in the history
uplaod video event changes
  • Loading branch information
komal-sai-yral authored Jul 29, 2024
1 parent 7cbcfba commit fb8a28b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
8 changes: 4 additions & 4 deletions ssr/src/page/upload/cf_upload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ mod cf_impl {
uid: String,
enable_hot_or_not: bool,
is_nsfw: bool,
) -> Result<(), ServerFnError> {
) -> Result<u64, ServerFnError> {
let user = canisters.authenticated_user().await?;
let res = user
.add_post_v_2(PostDetailsFromFrontend {
Expand All @@ -144,7 +144,7 @@ mod cf_impl {
Result_::Err(e) => return Err(ServerFnError::new(e)),
};
user.update_post_as_ready_to_view(post_id).await?;
Ok(())
Ok(post_id)
}
}

Expand Down Expand Up @@ -196,9 +196,9 @@ mod mock_impl {
_uid: String,
_enable_hot_or_not: bool,
_is_nsfw: bool,
) -> Result<(), ServerFnError> {
) -> Result<u64, ServerFnError> {
use gloo::timers::future::TimeoutFuture;
TimeoutFuture::new(1000).await;
Ok(())
Ok(0)
}
}
19 changes: 10 additions & 9 deletions ssr/src/page/upload/video_upload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use web_time::SystemTime;
pub fn DropBox() -> impl IntoView {
view! {
<div class="flex flex-col items-center justify-self-center justify-center w-full border-2 border-dashed rounded-lg cursor-pointer border-gray-600 hover:bg-gray-600 aspect-[3/4] lg:aspect-[5/4]">
<Icon class="w-10 h-10 mb-4 text-gray-400" icon=icondata::BiCloudUploadRegular/>
<Icon class="w-10 h-10 mb-4 text-gray-400" icon=icondata::BiCloudUploadRegular />
<p class="text-center mb-2 mx-2 text-sm text-gray-400">
<span class="font-semibold">Click to upload</span>
or drag and drop
Expand Down Expand Up @@ -110,7 +110,7 @@ pub fn PreVideoUpload(file_blob: WriteSignal<Option<FileWithUrl>>) -> impl IntoV
class="flex justify-start flex-col h-full w-full cursor-pointer"
>
<Show when=move || { with!(| file | file.is_none()) }>
<DropBox/>
<DropBox />
</Show>
<video
_ref=video_ref
Expand All @@ -124,8 +124,7 @@ pub fn PreVideoUpload(file_blob: WriteSignal<Option<FileWithUrl>>) -> impl IntoV
style:display=move || {
with!(| file | file.as_ref().map(| _ | "block").unwrap_or("none"))
}
>
</video>
></video>
<input
on:click=move |_| modal_show.set(true)
id="dropzone-file"
Expand Down Expand Up @@ -155,13 +154,13 @@ pub fn ProgressItem(
when=loading
fallback=move || {
view! {
<Icon class="w-10 h-10 text-green-600" icon=icondata::BsCheckCircleFill/>
<Icon class="w-10 h-10 text-green-600" icon=icondata::BsCheckCircleFill />
<span class="text-white text-lg font-semibold">{done_text.clone()}</span>
}
}
>

<Icon class="w-10 h-10 text-primary-600 animate-spin" icon=icondata::CgSpinnerTwo/>
<Icon class="w-10 h-10 text-primary-600 animate-spin" icon=icondata::CgSpinnerTwo />
<span class="text-white text-lg font-semibold">{initial_text.clone()}</span>
</Show>
}
Expand Down Expand Up @@ -300,11 +299,13 @@ pub fn VideoUploader(params: UploadParams) -> impl IntoView {

publishing.set(false);

let post_id = res.unwrap();
VideoUploadSuccessful.send_event(
uid,
hashtags_len,
is_nsfw,
enable_hot_or_not,
post_id,
canister_store,
);

Expand All @@ -327,13 +328,13 @@ pub fn VideoUploader(params: UploadParams) -> impl IntoView {
</div>
<div class="flex flex-col basis-full lg:basis-7/12 gap-4 px-4">
<div class="flex flex-row gap-4">
<ProgressItem initial_text="Uploading" done_text="Uploaded" loading=uploading/>
<ProgressItem initial_text="Uploading" done_text="Uploaded" loading=uploading />
</div>
<div class="flex flex-row gap-4">
<ProgressItem initial_text="Processing" done_text="Processed" loading=processing/>
<ProgressItem initial_text="Processing" done_text="Processed" loading=processing />
</div>
<div class="flex flex-row gap-4">
<ProgressItem initial_text="Publishing" done_text="Published" loading=publishing/>
<ProgressItem initial_text="Publishing" done_text="Published" loading=publishing />
<Suspense>
{move || {
let uid = upload_action().flatten()?;
Expand Down
2 changes: 2 additions & 0 deletions ssr/src/utils/event_streaming/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ impl VideoUploadSuccessful {
hashtags_len: usize,
is_nsfw: bool,
enable_hot_or_not: bool,
post_id: u64,
cans_store: RwSignal<Option<Canisters<true>>>,
) {
#[cfg(all(feature = "hydrate", feature = "ga4"))]
Expand All @@ -429,6 +430,7 @@ impl VideoUploadSuccessful {
"is_hotorNot": enable_hot_or_not,
"is_filter_used": false,
"video_id": video_id,
"post_id": post_id,
}),
);
}
Expand Down

0 comments on commit fb8a28b

Please sign in to comment.