From e021d4a55d3ef6a33f5b50a95174a74869ca856a Mon Sep 17 00:00:00 2001 From: vaw Date: Sat, 25 Oct 2025 20:41:34 +0000 Subject: [PATCH] Add `:forget` to forget all left rooms (#507) --- docs/iamb.1 | 2 ++ src/base.rs | 2 ++ src/commands.rs | 16 ++++++++++++++++ src/main.rs | 7 +++++++ 4 files changed, 27 insertions(+) diff --git a/docs/iamb.1 b/docs/iamb.1 index 2487b92..c1e6c73 100644 --- a/docs/iamb.1 +++ b/docs/iamb.1 @@ -67,6 +67,8 @@ View a list of unread rooms. Mark all rooms as read. .It Sy ":welcome" View the startup Welcome window. +.It Sy ":forget" +Remove all left rooms from the internal database. .El .Sh "E2EE COMMANDS" diff --git a/src/base.rs b/src/base.rs index ba206f2..b195e6a 100644 --- a/src/base.rs +++ b/src/base.rs @@ -491,6 +491,8 @@ pub enum HomeserverAction { /// Create a new room with an optional localpart. CreateRoom(Option, CreateRoomType, CreateRoomFlags), Logout(String, bool), + /// Forget all left rooms + Forget, } /// An action performed against the user's room keys. diff --git a/src/commands.rs b/src/commands.rs index c70a2af..4e0dd9f 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -200,6 +200,17 @@ fn iamb_leave(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult { return Ok(step); } +fn iamb_forget(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult { + if !desc.arg.text.is_empty() { + return Result::Err(CommandError::InvalidArgument); + } + + let forget = IambAction::Homeserver(HomeserverAction::Forget); + let step = CommandStep::Continue(forget.into(), ctx.context.clone()); + + return Ok(step); +} + fn iamb_cancel(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult { if !desc.arg.text.is_empty() { return Result::Err(CommandError::InvalidArgument); @@ -731,6 +742,11 @@ fn add_iamb_commands(cmds: &mut ProgramCommands) { aliases: vec![], f: iamb_leave, }); + cmds.add_command(ProgramCommand { + name: "forget".into(), + aliases: vec![], + f: iamb_forget, + }); cmds.add_command(ProgramCommand { name: "members".into(), aliases: vec![], diff --git a/src/main.rs b/src/main.rs index cee2247..7e00137 100644 --- a/src/main.rs +++ b/src/main.rs @@ -663,6 +663,13 @@ impl Application { Err(UIError::NeedConfirm(prompt)) }, + HomeserverAction::Forget => { + let client = &store.application.worker.client; + for room in client.left_rooms() { + room.forget().await.map_err(IambError::from)?; + } + Ok(vec![]) + }, } }