Commit 2641eaa915

2641eaa9153685cb68b2ebee2b414df6026631bd

parent: 35a211b0c5

Unregistered key

vaw <git@nlih.de> · 2026-09-16 19:37 UTC
committer: <noreply@github.com>

Add `:invites` list (#703)

Layout: unified · split

docs/iamb.1 +2
@@ -71,6 +71,8 @@ View a list of unread rooms.
7171Mark all rooms as read.
7272.It Sy ":mentions"
7373View a list of rooms with mentions of the current user.
74.It Sy ":invites"
75View a list of rooms you are invited to.
7476.It Sy ":welcome"
7577View the startup Welcome window.
7678.It Sy ":forget"
src/base.rs +15
@@ -2005,6 +2005,9 @@ pub enum IambId {
20052005
20062006 /// The `:mentions` window.
20072007 MentionsList,
2008
2009 /// The `:invites` window.
2010 InvitesList,
20082011}
20092012
20102013impl Display for IambId {
@@ -2027,6 +2030,7 @@ impl Display for IambId {
20272030 IambId::ChatList => f.write_str("iamb://chats"),
20282031 IambId::UnreadList => f.write_str("iamb://unreads"),
20292032 IambId::MentionsList => f.write_str("iamb://mentions"),
2033 IambId::InvitesList => f.write_str("iamb://invites"),
20302034 }
20312035 }
20322036}
@@ -2172,6 +2176,13 @@ impl Visitor<'_> for IambIdVisitor {
21722176
21732177 Ok(IambId::MentionsList)
21742178 },
2179 Some("invites") => {
2180 if url.path() != "" {
2181 return Err(E::custom("iamb://invites takes no path"));
2182 }
2183
2184 Ok(IambId::InvitesList)
2185 },
21752186 Some(s) => Err(E::custom(format!("{s:?} is not a valid window"))),
21762187 None => Err(E::custom("Invalid iamb window URL")),
21772188 }
@@ -2245,6 +2256,9 @@ pub enum IambBufferId {
22452256
22462257 /// The `:mentions` window.
22472258 MentionsList,
2259
2260 /// The `:invites` window.
2261 InvitesList,
22482262}
22492263
22502264impl IambBufferId {
@@ -2262,6 +2276,7 @@ impl IambBufferId {
22622276 IambBufferId::ChatList => IambId::ChatList,
22632277 IambBufferId::UnreadList => IambId::UnreadList,
22642278 IambBufferId::MentionsList => IambId::MentionsList,
2279 IambBufferId::InvitesList => IambId::InvitesList,
22652280 };
22662281
22672282 Some(id)
src/commands.rs +16
@@ -435,6 +435,17 @@ fn iamb_mentions(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult
435435 return Ok(step);
436436}
437437
438fn iamb_invites(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult {
439 if !desc.arg.text.is_empty() {
440 return Result::Err(CommandError::InvalidArgument);
441 }
442
443 let open = ctx.switch(OpenTarget::Application(IambId::InvitesList));
444 let step = CommandStep::Continue(open, ctx.context.clone());
445
446 return Ok(step);
447}
448
438449fn iamb_self(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult {
439450 let mut iter = desc.arg.strings()?.into_iter();
440451 let field = iter.next().ok_or(CommandError::InvalidArgument)?;
@@ -1101,6 +1112,11 @@ pub fn add_iamb_commands(cmds: &mut ProgramCommands) {
11011112 aliases: vec![],
11021113 f: iamb_mentions,
11031114 });
1115 cmds.add_command(ProgramCommand {
1116 name: "invites".into(),
1117 aliases: vec![],
1118 f: iamb_invites,
1119 });
11041120 cmds.add_command(ProgramCommand { name: "self".into(), aliases: vec![], f: iamb_self });
11051121 cmds.add_command(ProgramCommand {
11061122 name: "unreact".into(),
src/completions.rs +4 −3
@@ -611,8 +611,8 @@ fn complete_cmdarg(
611611 "verify" => complete_iamb_verify(args, store),
612612
613613 // These have no arguments
614 "cancel" | "chats" | "dms" | "editor" | "edit" | "forget" | "leave" | "members" |
615 "mentions" | "replied" | "reply" | "rooms" | "spaces" | "welcome" => vec![],
614 "cancel" | "chats" | "dms" | "editor" | "edit" | "forget" | "invites" | "leave" |
615 "members" | "mentions" | "replied" | "reply" | "rooms" | "spaces" | "welcome" => vec![],
616616
617617 "abo" | "aboveleft" | "bel" | "belowright" | "hor" | "horizontal" | "lefta" |
618618 "leftabove" | "rightb" | "rightbelow" | "tab" | "vert" | "vertical" => {
@@ -782,6 +782,7 @@ impl Completer<IambInfo> for IambCompleter {
782782 IambBufferId::ChatList => vec![],
783783 IambBufferId::UnreadList => vec![],
784784 IambBufferId::MentionsList => vec![],
785 IambBufferId::InvitesList => vec![],
785786 }
786787 }
787788}
@@ -877,7 +878,7 @@ pub mod tests {
877878 let text = EditRope::from("abo hor inv");
878879 let mut cursor = Cursor::new(0, 11);
879880 let res = complete_cmdbar(&text, &mut cursor, &store);
880 assert_eq!(res, vec!["invite"]);
881 assert_eq!(res, vec!["invite", "invites"]);
881882
882883 let text = EditRope::from("abo hor invite send \n");
883884 let mut cursor = Cursor::new(0, 20);
src/windows/mod.rs +47
@@ -307,6 +307,7 @@ macro_rules! delegate {
307307 IambWindow::ChatList($id) => $e,
308308 IambWindow::UnreadList($id) => $e,
309309 IambWindow::MentionsList($id) => $e,
310 IambWindow::InvitesList($id) => $e,
310311 }
311312 };
312313}
@@ -322,6 +323,7 @@ pub enum IambWindow {
322323 ChatList(ChatListState),
323324 UnreadList(UnreadListState),
324325 MentionsList(MentionsListState),
326 InvitesList(InvitesListState),
325327}
326328
327329impl IambWindow {
@@ -406,6 +408,7 @@ pub type RoomListState = ListState<RoomItem, IambInfo>;
406408pub type ChatListState = ListState<GenericChatItem, IambInfo>;
407409pub type UnreadListState = ListState<GenericChatItem, IambInfo>;
408410pub type MentionsListState = ListState<GenericChatItem, IambInfo>;
411pub type InvitesListState = ListState<GenericChatItem, IambInfo>;
409412pub type SpaceListState = ListState<SpaceItem, IambInfo>;
410413pub type VerifyListState = ListState<VerifyItem, IambInfo>;
411414
@@ -682,6 +685,41 @@ impl WindowOps<IambInfo> for IambWindow {
682685 .focus(focused)
683686 .render(area, buf, state);
684687 },
688 IambWindow::InvitesList(state) => {
689 let mut items = store
690 .application
691 .sync_info
692 .rooms
693 .clone()
694 .into_iter()
695 .map(|room_info| GenericChatItem::new(room_info, store, false))
696 .filter(GenericChatItem::is_invite)
697 .collect::<Vec<_>>();
698
699 let dms = store
700 .application
701 .sync_info
702 .dms
703 .clone()
704 .into_iter()
705 .map(|room_info| GenericChatItem::new(room_info, store, true))
706 .filter(GenericChatItem::is_invite);
707
708 items.extend(dms);
709
710 let fields = &store.application.settings.tunables.sort.chats;
711 let collator = &mut store.application.collator;
712 items.sort_by(|a, b| room_fields_cmp(a, b, fields, collator));
713
714 state.set(items);
715 state.set_ignorecase(store.application.settings.tunables.ignorecase);
716
717 List::new(store)
718 .empty_message("You do not have any open invites")
719 .empty_alignment(Alignment::Center)
720 .focus(focused)
721 .render(area, buf, state);
722 },
685723 IambWindow::SpaceList(state) => {
686724 let mut items = store
687725 .application
@@ -746,6 +784,7 @@ impl WindowOps<IambInfo> for IambWindow {
746784 IambWindow::ChatList(w) => w.dup(store).into(),
747785 IambWindow::UnreadList(w) => w.dup(store).into(),
748786 IambWindow::MentionsList(w) => w.dup(store).into(),
787 IambWindow::InvitesList(w) => w.dup(store).into(),
749788 }
750789 }
751790
@@ -788,6 +827,7 @@ impl Window<IambInfo> for IambWindow {
788827 IambWindow::ChatList(_) => IambId::ChatList,
789828 IambWindow::UnreadList(_) => IambId::UnreadList,
790829 IambWindow::MentionsList(_) => IambId::MentionsList,
830 IambWindow::InvitesList(_) => IambId::InvitesList,
791831 }
792832 }
793833
@@ -801,6 +841,7 @@ impl Window<IambInfo> for IambWindow {
801841 IambWindow::ChatList(_) => bold_spans("DMs & Rooms"),
802842 IambWindow::UnreadList(_) => bold_spans("Unread Messages"),
803843 IambWindow::MentionsList(_) => bold_spans("Unread Mentions"),
844 IambWindow::InvitesList(_) => bold_spans("Open Invites"),
804845
805846 IambWindow::Room(w) => {
806847 let title = store.application.get_room_title(w.id());
@@ -830,6 +871,7 @@ impl Window<IambInfo> for IambWindow {
830871 IambWindow::ChatList(_) => bold_spans("DMs & Rooms"),
831872 IambWindow::UnreadList(_) => bold_spans("Unread Messages"),
832873 IambWindow::MentionsList(_) => bold_spans("Unread Mentions"),
874 IambWindow::InvitesList(_) => bold_spans("Open Invites"),
833875
834876 IambWindow::Room(w) => w.get_title(store),
835877 IambWindow::MemberList(state, room_id, _) => {
@@ -901,6 +943,11 @@ impl Window<IambInfo> for IambWindow {
901943
902944 Ok(IambWindow::MentionsList(list))
903945 },
946 IambId::InvitesList => {
947 let list = InvitesListState::new(IambBufferId::InvitesList, vec![]);
948
949 Ok(IambWindow::InvitesList(list))
950 },
904951 }
905952 }
906953