Skip to content

Commit d92088f

Browse files
committed
.
1 parent 63dcffc commit d92088f

File tree

9 files changed

+86
-36
lines changed

9 files changed

+86
-36
lines changed

.vscode/launch.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"configurations": [
3+
{
4+
"name": "Launch Browser Chrome",
5+
"request": "launch",
6+
"type": "chrome",
7+
"url": "http://localhost:3000",
8+
"webRoot": "${workspaceFolder}/web/dist",
9+
"cwd": "${workspaceFolder}/web",
10+
"userDataDir": true,
11+
"runtimeArgs": [
12+
"--remote-debugging-port=9222"
13+
]
14+
}
15+
]
16+
}

shared/src/sync_engine/mod.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ pub use websocket_updates::transport::*;
77
mod conversions;
88
mod initial_sync;
99

10+
mod new_defn;
1011
pub mod changes;
1112
pub mod error;
1213
pub mod mutations;
@@ -36,7 +37,15 @@ pub struct DbSubscription {
3637
pub original_reactivity_trackers: ReactivityTrackers,
3738
pub func: Arc<dyn Fn()>,
3839
}
39-
mod new_defn;
40+
41+
impl std::fmt::Debug for DbSubscription {
42+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
43+
f.debug_struct("DbSubscription")
44+
.field("original_reactivity_trackers", &self.original_reactivity_trackers)
45+
.field("func", &"some func yo")
46+
.finish()
47+
}
48+
}
4049

4150
pub use new_defn::DbStoreMarkers;
4251

shared/src/sync_engine/new_defn.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -79,24 +79,11 @@ impl<BackendApi: BackendApiTrait, Transport: TransportTrait, GithubApi>
7979
let matching_trackers = orig_trackers
8080
.iter()
8181
.filter(|sub| {
82-
tracing::trace!(
83-
"checking if {:?} is affected by {:?}",
84-
sub.original_reactivity_trackers,
85-
reactivity_trackers
86-
);
8782
sub.original_reactivity_trackers
8883
.is_affected_by_writes_in(reactivity_trackers)
8984
})
9085
.collect::<Vec<_>>();
9186

92-
tracing::trace!(
93-
"matching_trackers: {:?}",
94-
matching_trackers
95-
.iter()
96-
.map(|sub| sub.original_reactivity_trackers.clone())
97-
.collect::<Vec<_>>()
98-
);
99-
10087
matching_trackers.into_iter().for_each(|sub| (sub.func)());
10188
}),
10289
)

shared/src/sync_engine/registry.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ impl<T> Registry<T> {
3131
pub fn new() -> Self {
3232
Default::default()
3333
}
34-
34+
}
35+
impl<T> Registry<T> {
3536
/// Will return the function that will remove it from the registry
3637
pub fn add(&self, t: T) -> impl Fn() + Send + Sync {
3738
let id = {
@@ -43,7 +44,7 @@ impl<T> Registry<T> {
4344
let inner = self.inner.clone();
4445

4546
move || {
46-
inner.borrow_mut().map.remove(&id);
47+
let item = inner.borrow_mut().map.remove(&id);
4748
}
4849
}
4950
}

typesafe_idb/src/store.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
use std::fmt::Debug;
12
use serde::{de::DeserializeOwned, Serialize};
23
use std::hash::Hash;
34

45
use crate::StoreName;
56

67
#[allow(async_fn_in_trait)]
7-
pub trait Store: Serialize + DeserializeOwned + Clone + 'static {
8+
pub trait Store: Serialize + DeserializeOwned + Clone + 'static + Debug {
89
const NAME: StoreName;
910
type Marker: Default;
1011

web/src/app/flowbite/button.rs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,24 @@ impl ButtonColor {
2828
}
2929
}
3030
}
31+
#[allow(dead_code)]
32+
#[derive(Default, Clone)]
33+
pub enum ButtonType {
34+
Submit,
35+
#[default]
36+
Button
37+
}
38+
39+
impl ButtonType {
40+
fn get_type_str(&self) -> &'static str {
41+
match self {
42+
ButtonType::Submit => "submit",
43+
ButtonType::Button => "button"
44+
}
45+
}
46+
}
47+
48+
3149

3250
#[allow(dead_code)]
3351
#[derive(Default)]
@@ -52,13 +70,18 @@ impl ButtonSize {
5270
}
5371
}
5472

73+
74+
5575
/// https://flowbite.com/docs/components/buttons/#default-button
76+
#[allow(non_snake_case)]
5677
#[component]
5778
pub fn Button(
5879
#[prop(optional, into)] color: Signal<ButtonColor>,
5980
#[prop(optional)] children: Option<Children>,
81+
#[prop(optional, into)] type_: Signal<ButtonType>,
6082
#[prop(optional, into)] size: Signal<ButtonSize>,
6183
) -> impl IntoView {
84+
let type_= move || type_.read().get_type_str();
6285
let class = move || {
6386
format!(
6487
"font-medium rounded-lg me-2 mb-2 focus:outline-none {} {}",
@@ -67,7 +90,7 @@ pub fn Button(
6790
)
6891
};
6992
view! {
70-
<button type="button" class=class>
93+
<button type=type_ class=class>
7194
{children.map(|c| c())}
7295
</button>
7396
}

web/src/app/repository/issues_tab/list.rs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
use jiff::{fmt::strtime, Timestamp};
22
use leptos::prelude::*;
33
use macros::zwang_url;
4-
use shared::{sync_engine::optimistic::db::MaybeOptimistic, types::{
5-
issue::{Issue, RepositoryIdIndex},
6-
issue_comment::{IssueComment, IssueIdIndex},
7-
user::User,
8-
}};
4+
use shared::{
5+
sync_engine::optimistic::db::MaybeOptimistic,
6+
types::{
7+
issue::{Issue, RepositoryIdIndex},
8+
issue_comment::{IssueComment, IssueIdIndex},
9+
user::User,
10+
},
11+
};
912

1013
use itertools::Itertools;
1114
use zwang_router::{ArgFromParent, RouteParams, A};
@@ -33,11 +36,12 @@ pub fn IssuesList(
3336
let issues = sync_engine.idb_signal(
3437
|builder| builder.with_store::<Issue>().build(),
3538
move |txn| async move {
36-
Ok(txn
39+
let issues = txn
3740
.object_store::<Issue>()?
3841
.index::<RepositoryIdIndex>()?
3942
.get_all_optimistically(Some(&repository_page_context.read().repository.id))
40-
.await?)
43+
.await?;
44+
Ok(issues)
4145
},
4246
);
4347

@@ -123,7 +127,10 @@ fn IssueRow(
123127
Some(u) => u,
124128
None => return Ok(None),
125129
};
126-
Ok(txn.object_store::<User>()?.get_optimistically(&user_id).await?)
130+
Ok(txn
131+
.object_store::<User>()?
132+
.get_optimistically(&user_id)
133+
.await?)
127134
}
128135
},
129136
);

web/src/app/repository/issues_tab/new_issue.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::app::repository::RepositoryPageContextInner;
1+
use crate::app::{flowbite::button::ButtonType, repository::RepositoryPageContextInner};
22
use crate::app::routing::*;
33
use github_api::models::IssuesCreateRequestTitle;
44
use leptos::{prelude::*, task::spawn_local};
@@ -25,7 +25,7 @@ pub fn NewIssue(
2525
let body = RwSignal::new(Default::default());
2626
move || {
2727
let sync_engine = use_sync_engine();
28-
let on_create = move |_| {
28+
let on_submit = move |_| {
2929
let sync_engine = sync_engine.clone();
3030
let RepositoryPageContextInner {
3131
user: owner,
@@ -66,6 +66,7 @@ pub fn NewIssue(
6666
});
6767
};
6868
view! {
69+
<form on:submit=on_submit>
6970
<Thirds
7071
two_thirds=view! {
7172
<div class="flex flex-nowrap gap-2">
@@ -90,13 +91,14 @@ pub fn NewIssue(
9091
<div
9192
class="flex gap-2 flex-end justify-end flex-end mb-4">
9293
<Button color=ButtonColor::Light>Cancel</Button>
93-
<Button on:click=on_create>Create</Button>
94+
<Button type_=ButtonType::Submit>Create</Button>
9495
</div>
9596
</div>
9697
</div>
9798
}
9899
one_third=()
99100
/>
101+
</form>
100102
}
101103
}
102104
}

web/src/idb_signal_from_sync_engine.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,20 @@ use leptos::prelude::*;
22
use std::{future::Future, sync::Arc};
33

44
use send_wrapper::SendWrapper;
5-
use shared::{backend_api_trait::BackendApiTrait, sync_engine::{
6-
optimistic::db::{TxnBuilderWithOptimisticChanges, TxnWithOptimisticChanges},
7-
DbStoreMarkers, SyncEngine, TransportTrait,
8-
}};
5+
use shared::{
6+
backend_api_trait::BackendApiTrait,
7+
sync_engine::{
8+
optimistic::db::{TxnBuilderWithOptimisticChanges, TxnWithOptimisticChanges},
9+
DbStoreMarkers, SyncEngine, TransportTrait,
10+
},
11+
};
912
use typesafe_idb::{ReadOnly, TxnMode};
1013

1114
use crate::{frontend_error::FrontendError, idb_signal::IdbSignal};
1215

1316
pub trait IdbSignalFromSyncEngine<DbStoreMarkers, TxnStoreMarkers, Mode, Fut, T>
1417
where
15-
T: 'static,
18+
T: 'static + std::fmt::Debug,
1619
{
1720
/// Will create a signal that will be recomputed every time an indexeddb change is committed by
1821
/// the sync engine.
@@ -30,12 +33,13 @@ where
3033
}
3134

3235
impl<BA, TT, GH, TxnStoreMarkers, Mode, Fut, T>
33-
IdbSignalFromSyncEngine<DbStoreMarkers, TxnStoreMarkers, Mode, Fut, T> for SyncEngine<BA, TT, GH>
36+
IdbSignalFromSyncEngine<DbStoreMarkers, TxnStoreMarkers, Mode, Fut, T>
37+
for SyncEngine<BA, TT, GH>
3438
where
3539
TxnStoreMarkers: 'static,
3640
Fut: Future<Output = Result<T, FrontendError>>,
3741
Mode: TxnMode + 'static,
38-
T: 'static,
42+
T: 'static + std::fmt::Debug,
3943
TT: TransportTrait,
4044
BA: BackendApiTrait,
4145
{

0 commit comments

Comments
 (0)