From 4563f221bf61123b15f9608bb14e8f46db05e4f6 Mon Sep 17 00:00:00 2001 From: Owen Jacobson Date: Wed, 11 Sep 2024 19:14:22 -0400 Subject: Remove the notion of "channel members." This came out of a conversation with Kit. Their position, loosely, was that seeing scrollback when you look at a channel is useful, and since message delivery isn't meaningfully tied to membership (or at least doesn't have to be), what the hell is membership even doing? (I may have added that last part.) My take, on top of that, is that membership increases the amount of concepts we're committed to. We don't need that commitment yet. --- src/index.rs | 47 ++++++++--------------------------------------- 1 file changed, 8 insertions(+), 39 deletions(-) (limited to 'src/index.rs') diff --git a/src/index.rs b/src/index.rs index 9de91d5..9efd7cc 100644 --- a/src/index.rs +++ b/src/index.rs @@ -16,15 +16,10 @@ async fn index( async fn index_authenticated(db: SqlitePool, login: Login) -> Result { let mut tx = db.begin().await?; - let joined_channels = tx.channels().joined(&login.id).await?; - let unjoined_channels = tx.channels().unjoined(&login.id).await?; + let channels = tx.channels().all().await?; tx.commit().await?; - Ok(templates::authenticated( - login, - &joined_channels, - &unjoined_channels, - )) + Ok(templates::authenticated(login, &channels)) } pub fn router() -> Router { @@ -38,8 +33,7 @@ mod templates { pub fn authenticated<'c>( login: Login, - joined_channels: impl IntoIterator, - unjoined_channels: impl IntoIterator, + channels: impl IntoIterator, ) -> Markup { html! { (DOCTYPE) @@ -48,8 +42,7 @@ mod templates { } body { section { - (channel_list(joined_channels)) - (join_channel(unjoined_channels)) + (channel_list(channels)) (create_channel()) } section { @@ -59,44 +52,20 @@ mod templates { } } - fn channel_list<'c>(joined_channels: impl IntoIterator) -> Markup { + fn channel_list<'c>(channels: impl IntoIterator) -> Markup { html! { ul { - @for channel in joined_channels { - (joined_channel_entry(&channel)) + @for channel in channels { + (channel_list_entry(&channel)) } } } } - fn joined_channel_entry(channel: &Channel) -> Markup { - let leave_url = format!("/{}/leave", channel.id); + fn channel_list_entry(channel: &Channel) -> Markup { html! { li { (channel.name) " (" (channel.id) ")" - form action=(leave_url) method="post" { - button { - "leave" - } - } - } - } - } - - fn join_channel<'c>(unjoined_channels: impl IntoIterator) -> Markup { - html! { - form action="join" method="post" { - select name="channel" required { - option value="" { "channel" } - @for channel in unjoined_channels { - option value=(channel.id) { - (channel.name) " (" (channel.id) ")" - } - } - } - button { - "join" - } } } } -- cgit v1.2.3