From 6efe8e7d7cf8b3f057451a1d076073e31814c5eb Mon Sep 17 00:00:00 2001 From: Simon Laux Date: Wed, 12 Feb 2020 11:08:43 +0100 Subject: [PATCH] change ChatInfo.archived to tri-state and add to the changelog --- CHANGELOG.md | 8 ++++++++ deltachat-ffi/deltachat.h | 4 ++++ deltachat-ffi/src/lib.rs | 3 ++- src/chat.rs | 15 +++++++-------- 4 files changed, 21 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f3efb271c..7533d3b29 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## Unreleased + +- pinned chats #1248 + +#### Api Changes + + - ChatInfo.archived is now a tri-state + ## 1.0.0-beta.24 - fix oauth2/gmail bug introduced in beta23 (not used in releases) #1219 diff --git a/deltachat-ffi/deltachat.h b/deltachat-ffi/deltachat.h index 040a3ec2b..12ac1b470 100644 --- a/deltachat-ffi/deltachat.h +++ b/deltachat-ffi/deltachat.h @@ -2700,6 +2700,10 @@ dc_context_t* dc_chatlist_get_context (dc_chatlist_t* chatlist); * * id: chat id * name: chat/group name + * archived: archived state can be one of: + * DC_CHAT_ARCHIVE_STATE_NORMAL + * DC_CHAT_ARCHIVE_STATE_ARCHIVED + * DC_CHAT_ARCHIVE_STATE_PINNED * color: color of this chat * last-message-from: who sent the last message * last-message-text: message (truncated) diff --git a/deltachat-ffi/src/lib.rs b/deltachat-ffi/src/lib.rs index fb514fe51..cd6502d63 100644 --- a/deltachat-ffi/src/lib.rs +++ b/deltachat-ffi/src/lib.rs @@ -1203,7 +1203,8 @@ pub unsafe extern "C" fn dc_archive_chat( 1 => ArchiveState::Archived, 2 => ArchiveState::Pinned, _ => { - ffi_context.warning("ignoring careless call to dc_archive_chat(): unknown archived state"); + ffi_context + .warning("ignoring careless call to dc_archive_chat(): unknown archived state"); return; } }; diff --git a/src/chat.rs b/src/chat.rs index 3e418d2c1..1e54893b9 100644 --- a/src/chat.rs +++ b/src/chat.rs @@ -668,8 +668,11 @@ impl Chat { id: self.id, type_: self.typ as u32, name: self.name.clone(), - archived: archive_state == ArchiveState::Archived, - pinned: archive_state == ArchiveState::Pinned, + archived: match archive_state { + ArchiveState::Normal => 0, + ArchiveState::Archived => 1, + ArchiveState::Pinned => 2, + }, param: self.param.to_string(), gossiped_timestamp: self.get_gossiped_timestamp(context), is_sending_locations: self.is_sending_locations, @@ -994,10 +997,7 @@ pub struct ChatInfo { pub name: String, /// Whether the chat is archived. - pub archived: bool, - - /// Wether the chat is pinned. - pub pinned: bool, + pub archived: u8, /// The "params" of the chat. /// @@ -2535,8 +2535,7 @@ mod tests { "id": 10, "type": 100, "name": "bob", - "archived": false, - "pinned": false, + "archived": 0, "param": "", "gossiped_timestamp": 0, "is_sending_locations": false,