From adb67d1910ce7faa6f0365e7c261387352ddb86b Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Mon, 12 Aug 2019 01:28:36 +0200 Subject: [PATCH 1/2] off by one: show chats cnt-1..0 instead of cnt-1..1 --- examples/repl/cmdline.rs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/examples/repl/cmdline.rs b/examples/repl/cmdline.rs index 8aea771f2..675b21890 100644 --- a/examples/repl/cmdline.rs +++ b/examples/repl/cmdline.rs @@ -606,7 +606,6 @@ pub unsafe fn dc_cmdline(context: &Context, line: &str) -> Result<(), failure::E let listflags = if arg0 == "listarchived" { 0x01 } else { 0 }; let chatlist = Chatlist::try_load(context, listflags, Some(arg1), None)?; - let mut i: usize; let cnt = chatlist.len(); if cnt > 0 { info!( @@ -614,9 +613,7 @@ pub unsafe fn dc_cmdline(context: &Context, line: &str) -> Result<(), failure::E "================================================================================" ); - i = cnt - 1; - - while i > 0 { + for i in (0..cnt).rev() { let chat = dc_get_chat(context, chatlist.get_chat_id(i)); let temp_subtitle = dc_chat_get_subtitle(chat); let temp_name = dc_chat_get_name(chat); @@ -670,8 +667,6 @@ pub unsafe fn dc_cmdline(context: &Context, line: &str) -> Result<(), failure::E context, 0, "================================================================================" ); - - i -= 1 } } if dc_is_sending_locations_to_chat(context, 0 as uint32_t) { From 5554df29fd023826d96519a5b75bddef97de4c53 Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Mon, 12 Aug 2019 01:37:05 +0200 Subject: [PATCH 2/2] show full chatlist by just entering 'chats' in cmdline --- examples/repl/cmdline.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/examples/repl/cmdline.rs b/examples/repl/cmdline.rs index 675b21890..c961bb5cc 100644 --- a/examples/repl/cmdline.rs +++ b/examples/repl/cmdline.rs @@ -604,7 +604,12 @@ pub unsafe fn dc_cmdline(context: &Context, line: &str) -> Result<(), failure::E } "listchats" | "listarchived" | "chats" => { let listflags = if arg0 == "listarchived" { 0x01 } else { 0 }; - let chatlist = Chatlist::try_load(context, listflags, Some(arg1), None)?; + let chatlist = Chatlist::try_load( + context, + listflags, + if arg1.is_empty() { None } else { Some(arg1) }, + None, + )?; let cnt = chatlist.len(); if cnt > 0 {