Skip to content

Commit

Permalink
Refactor of server_functions to include routes.
Browse files Browse the repository at this point in the history
It is recommended that routes be split further
  • Loading branch information
MinaMatta98 committed Feb 15, 2024
1 parent 7f8ec9d commit 517c2ca
Show file tree
Hide file tree
Showing 11 changed files with 1,400 additions and 1,382 deletions.
12 changes: 6 additions & 6 deletions src/app/callback/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use crate::{app::{NameSchema, SignupSchema,
EmailSchema, PhoneSchema, EmailContext,
FormValidation, validation::ValidationSchema,
PasswordSchema, VerifyPassword},
server_function::{ConfirmSubscription,
self, Login, sign_up}};
server_function::{routes::ConfirmSubscription,
self, routes::Login, routes::sign_up}};

use super::{VerificationValidation, SignupContext, AppState};

Expand Down Expand Up @@ -72,8 +72,8 @@ let signup = create_resource(cx, move || sign_up_schema.clone(), move |sign_up_s
{ match val {
Ok(FormValidation::Success {random_string}) => {
database_connection_result_setter.set(String::from("Sending Verification Email..."));
let verification = create_server_action::<crate::server_function::VerifyEmail>(cx);
verification.dispatch(crate::server_function::VerifyEmail { first_name:
let verification = create_server_action::<crate::server_function::routes::VerifyEmail>(cx);
verification.dispatch(crate::server_function::routes::VerifyEmail { first_name:
info.first_name.get().unwrap().value(), email: info.email.get().unwrap().value(),
random_string: random_string.unwrap()} );

Expand Down Expand Up @@ -276,7 +276,7 @@ let signup = create_resource(cx, move || sign_up_schema.clone(), move |sign_up_s
toggle
) {
true => {
match server_function::cred_validation(cx, Some(email_schema), None)
match server_function::routes::cred_validation(cx, Some(email_schema), None)
.await
.unwrap()
{
Expand Down Expand Up @@ -326,7 +326,7 @@ let signup = create_resource(cx, move || sign_up_schema.clone(), move |sign_up_s
toggle
) {
true => {
match server_function::cred_validation(cx, None, Some(phone_schema))
match server_function::routes::cred_validation(cx, None, Some(phone_schema))
.await
.unwrap()
{
Expand Down
6 changes: 3 additions & 3 deletions src/app/pages/components/anciliary/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::{
pages::{conversation::ConversationParams, Avatar, SettingsModal, ICONVEC, SINKVEC},
IsOpen, SideBarContext,
},
server_function::{self, login_status, UserLogin},
server_function::{self, routes::login_status, UserLogin},
};

use super::avatar::STREAMVEC;
Expand Down Expand Up @@ -64,7 +64,7 @@ impl<'a> SidebarIcon<'a> {
create_resource(
cx,
|| (),
async move |_| server_function::logout(cx).await.unwrap(),
async move |_| server_function::routes::logout(cx).await.unwrap(),
);
// queue_microtask(move || use_navigate(cx)("/login", Default::default()).unwrap());
})),
Expand Down Expand Up @@ -155,7 +155,7 @@ pub fn Sidebar(cx: Scope, children: Children) -> impl IntoView {
fn DesktopSidebar(cx: Scope) -> impl IntoView {
create_effect(cx, move |_| {
spawn_local(async move {
if server_function::redirect(cx).await.unwrap() {
if server_function::routes::redirect(cx).await.unwrap() {
queue_microtask(move || {
leptos_router::use_navigate(cx)("/login", Default::default()).unwrap()
});
Expand Down
2 changes: 1 addition & 1 deletion src/app/pages/components/avatar/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::app::pages::{
components::anciliary::loading_fallback, HandleWebSocket, StreamData, SyncChannel, WsData,
};
use crate::server_function::get_icon;
use crate::server_function::routes::get_icon;
use base64::{engine::general_purpose, Engine};
use lazy_static::lazy_static;
use leptos::*;
Expand Down
4 changes: 3 additions & 1 deletion src/app/pages/components/modal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ use crate::app::{
};

use crate::server_function::{
delete_conversations, get_users, login_status, upload_user_info, CreateGroupConversation,
routes::{
delete_conversations, get_users, login_status, upload_user_info, CreateGroupConversation,
},
UserModel,
};

Expand Down
11 changes: 7 additions & 4 deletions src/app/pages/conversation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@ use crate::{
DrawerContext, IsOpen, MessageDrawerContext, SeenContext, SeenContextInner,
},
server_function::{
self, find_image, get_conversations, handle_seen, login_status, validate_conversation,
view_messages, ConversationMeta, ImageAvailability, MergedConversation, MergedMessages,
SeenMessageFacing, UserLogin,
self,
routes::{
find_image, get_conversations, handle_seen, login_status, validate_conversation,
view_messages,
},
ConversationMeta, ImageAvailability, MergedConversation, MergedMessages, SeenMessageFacing,
UserLogin,
},
};

Expand Down Expand Up @@ -414,7 +418,6 @@ fn Body(cx: Scope, messages: Vec<MergedMessages>) -> impl IntoView {
{
seen_context.get().get(index).unwrap().last_message_id
} else {

let last_message = if let Some(last_message) = boxed_messages.clone().iter().last() {
last_message.message_id
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/app/pages/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
app::pages::components::{anciliary::UserContext, avatar},
server_function::get_image,
server_function::routes::get_image,
};

pub mod components;
Expand Down
4 changes: 3 additions & 1 deletion src/app/pages/users/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ use crate::{
components::anciliary::{loading_fallback, EmptyState, Sidebar, UserContexts},
Avatar, ICONVEC, SINKVEC, STREAMVEC,
},
server_function::{associated_conversation, conversation_action, get_users, UserModel},
server_function::{
routes::associated_conversation, routes::conversation_action, routes::get_users, UserModel,
},
};

#[component]
Expand Down
2 changes: 1 addition & 1 deletion src/app/pages/websocket/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use super::components::avatar::{self, IconData, SINKVEC, STREAMVEC};
use super::conversation::Message;
use super::UserContext;
use crate::app::{pages::components::avatar::ToStreamData, SeenContext};
use crate::server_function::handle_message_input;
use crate::server_function::routes::handle_message_input;

#[derive(Debug, Clone)]
pub enum SyncChannel {
Expand Down
Loading

0 comments on commit 517c2ca

Please sign in to comment.