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.
71Mark all rooms as read. 71Mark all rooms as read.
72.It Sy ":mentions" 72.It Sy ":mentions"
73View a list of rooms with mentions of the current user. 73View a list of rooms with mentions of the current user.
74.It Sy ":invites"
75View a list of rooms you are invited to.
74.It Sy ":welcome" 76.It Sy ":welcome"
75View the startup Welcome window. 77View the startup Welcome window.
76.It Sy ":forget" 78.It Sy ":forget"
src/base.rs +15
@@ -2005,6 +2005,9 @@ pub enum IambId {
2005 2005
2006 /// The `:mentions` window. 2006 /// The `:mentions` window.
2007 MentionsList, 2007 MentionsList,
2008
2009 /// The `:invites` window.
2010 InvitesList,
2008} 2011}
2009 2012
2010impl Display for IambId { 2013impl Display for IambId {
@@ -2027,6 +2030,7 @@ impl Display for IambId {
2027 IambId::ChatList => f.write_str("iamb://chats"), 2030 IambId::ChatList => f.write_str("iamb://chats"),
2028 IambId::UnreadList => f.write_str("iamb://unreads"), 2031 IambId::UnreadList => f.write_str("iamb://unreads"),
2029 IambId::MentionsList => f.write_str("iamb://mentions"), 2032 IambId::MentionsList => f.write_str("iamb://mentions"),
2033 IambId::InvitesList => f.write_str("iamb://invites"),
2030 } 2034 }
2031 } 2035 }
2032} 2036}
@@ -2172,6 +2176,13 @@ impl Visitor<'_> for IambIdVisitor {
2172 2176
2173 Ok(IambId::MentionsList) 2177 Ok(IambId::MentionsList)
2174 }, 2178 },
2179 Some("invites") => {
2180 if url.path() != "" {
2181 return Err(E::custom("iamb://invites takes no path"));
2182 }
2183
2184 Ok(IambId::InvitesList)
2185 },
2175 Some(s) => Err(E::custom(format!("{s:?} is not a valid window"))), 2186 Some(s) => Err(E::custom(format!("{s:?} is not a valid window"))),
2176 None => Err(E::custom("Invalid iamb window URL")), 2187 None => Err(E::custom("Invalid iamb window URL")),
2177 } 2188 }
@@ -2245,6 +2256,9 @@ pub enum IambBufferId {
2245 2256
2246 /// The `:mentions` window. 2257 /// The `:mentions` window.
2247 MentionsList, 2258 MentionsList,
2259
2260 /// The `:invites` window.
2261 InvitesList,
2248} 2262}
2249 2263
2250impl IambBufferId { 2264impl IambBufferId {
@@ -2262,6 +2276,7 @@ impl IambBufferId {
2262 IambBufferId::ChatList => IambId::ChatList, 2276 IambBufferId::ChatList => IambId::ChatList,
2263 IambBufferId::UnreadList => IambId::UnreadList, 2277 IambBufferId::UnreadList => IambId::UnreadList,
2264 IambBufferId::MentionsList => IambId::MentionsList, 2278 IambBufferId::MentionsList => IambId::MentionsList,
2279 IambBufferId::InvitesList => IambId::InvitesList,
2265 }; 2280 };
2266 2281
2267 Some(id) 2282 Some(id)
src/commands.rs +16
@@ -435,6 +435,17 @@ fn iamb_mentions(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult
435 return Ok(step); 435 return Ok(step);
436} 436}
437 437
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
438fn iamb_self(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult { 449fn iamb_self(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult {
439 let mut iter = desc.arg.strings()?.into_iter(); 450 let mut iter = desc.arg.strings()?.into_iter();
440 let field = iter.next().ok_or(CommandError::InvalidArgument)?; 451 let field = iter.next().ok_or(CommandError::InvalidArgument)?;
@@ -1101,6 +1112,11 @@ pub fn add_iamb_commands(cmds: &mut ProgramCommands) {
1101 aliases: vec![], 1112 aliases: vec![],
1102 f: iamb_mentions, 1113 f: iamb_mentions,
1103 }); 1114 });
1115 cmds.add_command(ProgramCommand {
1116 name: "invites".into(),
1117 aliases: vec![],
1118 f: iamb_invites,
1119 });
1104 cmds.add_command(ProgramCommand { name: "self".into(), aliases: vec![], f: iamb_self }); 1120 cmds.add_command(ProgramCommand { name: "self".into(), aliases: vec![], f: iamb_self });
1105 cmds.add_command(ProgramCommand { 1121 cmds.add_command(ProgramCommand {
1106 name: "unreact".into(), 1122 name: "unreact".into(),
src/completions.rs +4 −3
@@ -611,8 +611,8 @@ fn complete_cmdarg(
611 "verify" => complete_iamb_verify(args, store), 611 "verify" => complete_iamb_verify(args, store),
612 612
613 // These have no arguments 613 // These have no arguments
614 "cancel" | "chats" | "dms" | "editor" | "edit" | "forget" | "leave" | "members" | 614 "cancel" | "chats" | "dms" | "editor" | "edit" | "forget" | "invites" | "leave" |
615 "mentions" | "replied" | "reply" | "rooms" | "spaces" | "welcome" => vec![], 615 "members" | "mentions" | "replied" | "reply" | "rooms" | "spaces" | "welcome" => vec![],
616 616
617 "abo" | "aboveleft" | "bel" | "belowright" | "hor" | "horizontal" | "lefta" | 617 "abo" | "aboveleft" | "bel" | "belowright" | "hor" | "horizontal" | "lefta" |
618 "leftabove" | "rightb" | "rightbelow" | "tab" | "vert" | "vertical" => { 618 "leftabove" | "rightb" | "rightbelow" | "tab" | "vert" | "vertical" => {
@@ -782,6 +782,7 @@ impl Completer<IambInfo> for IambCompleter {
782 IambBufferId::ChatList => vec![], 782 IambBufferId::ChatList => vec![],
783 IambBufferId::UnreadList => vec![], 783 IambBufferId::UnreadList => vec![],
784 IambBufferId::MentionsList => vec![], 784 IambBufferId::MentionsList => vec![],
785 IambBufferId::InvitesList => vec![],
785 } 786 }
786 } 787 }
787} 788}
@@ -877,7 +878,7 @@ pub mod tests {
877 let text = EditRope::from("abo hor inv"); 878 let text = EditRope::from("abo hor inv");
878 let mut cursor = Cursor::new(0, 11); 879 let mut cursor = Cursor::new(0, 11);
879 let res = complete_cmdbar(&text, &mut cursor, &store); 880 let res = complete_cmdbar(&text, &mut cursor, &store);
880 assert_eq!(res, vec!["invite"]); 881 assert_eq!(res, vec!["invite", "invites"]);
881 882
882 let text = EditRope::from("abo hor invite send \n"); 883 let text = EditRope::from("abo hor invite send \n");
883 let mut cursor = Cursor::new(0, 20); 884 let mut cursor = Cursor::new(0, 20);
src/windows/mod.rs +47
@@ -307,6 +307,7 @@ macro_rules! delegate {
307 IambWindow::ChatList($id) => $e, 307 IambWindow::ChatList($id) => $e,
308 IambWindow::UnreadList($id) => $e, 308 IambWindow::UnreadList($id) => $e,
309 IambWindow::MentionsList($id) => $e, 309 IambWindow::MentionsList($id) => $e,
310 IambWindow::InvitesList($id) => $e,
310 } 311 }
311 }; 312 };
312} 313}
@@ -322,6 +323,7 @@ pub enum IambWindow {
322 ChatList(ChatListState), 323 ChatList(ChatListState),
323 UnreadList(UnreadListState), 324 UnreadList(UnreadListState),
324 MentionsList(MentionsListState), 325 MentionsList(MentionsListState),
326 InvitesList(InvitesListState),
325} 327}
326 328
327impl IambWindow { 329impl IambWindow {
@@ -406,6 +408,7 @@ pub type RoomListState = ListState<RoomItem, IambInfo>;
406pub type ChatListState = ListState<GenericChatItem, IambInfo>; 408pub type ChatListState = ListState<GenericChatItem, IambInfo>;
407pub type UnreadListState = ListState<GenericChatItem, IambInfo>; 409pub type UnreadListState = ListState<GenericChatItem, IambInfo>;
408pub type MentionsListState = ListState<GenericChatItem, IambInfo>; 410pub type MentionsListState = ListState<GenericChatItem, IambInfo>;
411pub type InvitesListState = ListState<GenericChatItem, IambInfo>;
409pub type SpaceListState = ListState<SpaceItem, IambInfo>; 412pub type SpaceListState = ListState<SpaceItem, IambInfo>;
410pub type VerifyListState = ListState<VerifyItem, IambInfo>; 413pub type VerifyListState = ListState<VerifyItem, IambInfo>;
411 414
@@ -682,6 +685,41 @@ impl WindowOps<IambInfo> for IambWindow {
682 .focus(focused) 685 .focus(focused)
683 .render(area, buf, state); 686 .render(area, buf, state);
684 }, 687 },
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 },
685 IambWindow::SpaceList(state) => { 723 IambWindow::SpaceList(state) => {
686 let mut items = store 724 let mut items = store
687 .application 725 .application
@@ -746,6 +784,7 @@ impl WindowOps<IambInfo> for IambWindow {
746 IambWindow::ChatList(w) => w.dup(store).into(), 784 IambWindow::ChatList(w) => w.dup(store).into(),
747 IambWindow::UnreadList(w) => w.dup(store).into(), 785 IambWindow::UnreadList(w) => w.dup(store).into(),
748 IambWindow::MentionsList(w) => w.dup(store).into(), 786 IambWindow::MentionsList(w) => w.dup(store).into(),
787 IambWindow::InvitesList(w) => w.dup(store).into(),
749 } 788 }
750 } 789 }
751 790
@@ -788,6 +827,7 @@ impl Window<IambInfo> for IambWindow {
788 IambWindow::ChatList(_) => IambId::ChatList, 827 IambWindow::ChatList(_) => IambId::ChatList,
789 IambWindow::UnreadList(_) => IambId::UnreadList, 828 IambWindow::UnreadList(_) => IambId::UnreadList,
790 IambWindow::MentionsList(_) => IambId::MentionsList, 829 IambWindow::MentionsList(_) => IambId::MentionsList,
830 IambWindow::InvitesList(_) => IambId::InvitesList,
791 } 831 }
792 } 832 }
793 833
@@ -801,6 +841,7 @@ impl Window<IambInfo> for IambWindow {
801 IambWindow::ChatList(_) => bold_spans("DMs & Rooms"), 841 IambWindow::ChatList(_) => bold_spans("DMs & Rooms"),
802 IambWindow::UnreadList(_) => bold_spans("Unread Messages"), 842 IambWindow::UnreadList(_) => bold_spans("Unread Messages"),
803 IambWindow::MentionsList(_) => bold_spans("Unread Mentions"), 843 IambWindow::MentionsList(_) => bold_spans("Unread Mentions"),
844 IambWindow::InvitesList(_) => bold_spans("Open Invites"),
804 845
805 IambWindow::Room(w) => { 846 IambWindow::Room(w) => {
806 let title = store.application.get_room_title(w.id()); 847 let title = store.application.get_room_title(w.id());
@@ -830,6 +871,7 @@ impl Window<IambInfo> for IambWindow {
830 IambWindow::ChatList(_) => bold_spans("DMs & Rooms"), 871 IambWindow::ChatList(_) => bold_spans("DMs & Rooms"),
831 IambWindow::UnreadList(_) => bold_spans("Unread Messages"), 872 IambWindow::UnreadList(_) => bold_spans("Unread Messages"),
832 IambWindow::MentionsList(_) => bold_spans("Unread Mentions"), 873 IambWindow::MentionsList(_) => bold_spans("Unread Mentions"),
874 IambWindow::InvitesList(_) => bold_spans("Open Invites"),
833 875
834 IambWindow::Room(w) => w.get_title(store), 876 IambWindow::Room(w) => w.get_title(store),
835 IambWindow::MemberList(state, room_id, _) => { 877 IambWindow::MemberList(state, room_id, _) => {
@@ -901,6 +943,11 @@ impl Window<IambInfo> for IambWindow {
901 943
902 Ok(IambWindow::MentionsList(list)) 944 Ok(IambWindow::MentionsList(list))
903 }, 945 },
946 IambId::InvitesList => {
947 let list = InvitesListState::new(IambBufferId::InvitesList, vec![]);
948
949 Ok(IambWindow::InvitesList(list))
950 },
904 } 951 }
905 } 952 }
906 953