mirror of
https://github.com/youwen5/iamb.git
synced 2025-06-20 21:59:52 -07:00
Add commands for viewing and clearing unreads (#332)
This commit is contained in:
parent
4fc05c7b40
commit
480888a1fc
5 changed files with 135 additions and 0 deletions
|
@ -307,6 +307,30 @@ fn iamb_chats(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult {
|
|||
return Ok(step);
|
||||
}
|
||||
|
||||
fn iamb_unreads(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult {
|
||||
let mut args = desc.arg.strings()?;
|
||||
|
||||
if args.len() > 1 {
|
||||
return Result::Err(CommandError::InvalidArgument);
|
||||
}
|
||||
|
||||
match args.pop().as_deref() {
|
||||
Some("clear") => {
|
||||
let clear = IambAction::ClearUnreads;
|
||||
let step = CommandStep::Continue(clear.into(), ctx.context.clone());
|
||||
|
||||
return Ok(step);
|
||||
},
|
||||
Some(_) => return Result::Err(CommandError::InvalidArgument),
|
||||
None => {
|
||||
let open = ctx.switch(OpenTarget::Application(IambId::UnreadList));
|
||||
let step = CommandStep::Continue(open, ctx.context.clone());
|
||||
|
||||
return Ok(step);
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
fn iamb_spaces(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult {
|
||||
if !desc.arg.text.is_empty() {
|
||||
return Result::Err(CommandError::InvalidArgument);
|
||||
|
@ -648,6 +672,11 @@ fn add_iamb_commands(cmds: &mut ProgramCommands) {
|
|||
aliases: vec![],
|
||||
f: iamb_spaces,
|
||||
});
|
||||
cmds.add_command(ProgramCommand {
|
||||
name: "unreads".into(),
|
||||
aliases: vec![],
|
||||
f: iamb_unreads,
|
||||
});
|
||||
cmds.add_command(ProgramCommand {
|
||||
name: "unreact".into(),
|
||||
aliases: vec![],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue