diff options
| author | Owen Jacobson <owen@grimoire.ca> | 2024-09-11 19:14:22 -0400 |
|---|---|---|
| committer | Owen Jacobson <owen@grimoire.ca> | 2024-09-11 19:14:22 -0400 |
| commit | 4563f221bf61123b15f9608bb14e8f46db05e4f6 (patch) | |
| tree | 58a5ee7e0e14b918a332d4536dec06d4ad8367e8 /src/index.rs | |
| parent | 588a14848d4ac45f31ee8646555e1e21cca5595d (diff) | |
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.
Diffstat (limited to 'src/index.rs')
| -rw-r--r-- | src/index.rs | 47 |
1 files changed, 8 insertions, 39 deletions
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<Markup, InternalError> { 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<SqlitePool> { @@ -38,8 +33,7 @@ mod templates { pub fn authenticated<'c>( login: Login, - joined_channels: impl IntoIterator<Item = &'c Channel>, - unjoined_channels: impl IntoIterator<Item = &'c Channel>, + channels: impl IntoIterator<Item = &'c Channel>, ) -> 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<Item = &'c Channel>) -> Markup { + fn channel_list<'c>(channels: impl IntoIterator<Item = &'c Channel>) -> 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<Item = &'c Channel>) -> 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" - } } } } |
