change ChatInfo.archived to tri-state

and add to the changelog
This commit is contained in:
Simon Laux
2020-02-12 11:08:43 +01:00
committed by B. Petersen
parent 2e8409f146
commit 6efe8e7d7c
4 changed files with 21 additions and 9 deletions

View File

@@ -1,5 +1,13 @@
# Changelog # Changelog
## Unreleased
- pinned chats #1248
#### Api Changes
- ChatInfo.archived is now a tri-state
## 1.0.0-beta.24 ## 1.0.0-beta.24
- fix oauth2/gmail bug introduced in beta23 (not used in releases) #1219 - fix oauth2/gmail bug introduced in beta23 (not used in releases) #1219

View File

@@ -2700,6 +2700,10 @@ dc_context_t* dc_chatlist_get_context (dc_chatlist_t* chatlist);
* *
* id: chat id * id: chat id
* name: chat/group name * 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 * color: color of this chat
* last-message-from: who sent the last message * last-message-from: who sent the last message
* last-message-text: message (truncated) * last-message-text: message (truncated)

View File

@@ -1203,7 +1203,8 @@ pub unsafe extern "C" fn dc_archive_chat(
1 => ArchiveState::Archived, 1 => ArchiveState::Archived,
2 => ArchiveState::Pinned, 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; return;
} }
}; };

View File

@@ -668,8 +668,11 @@ impl Chat {
id: self.id, id: self.id,
type_: self.typ as u32, type_: self.typ as u32,
name: self.name.clone(), name: self.name.clone(),
archived: archive_state == ArchiveState::Archived, archived: match archive_state {
pinned: archive_state == ArchiveState::Pinned, ArchiveState::Normal => 0,
ArchiveState::Archived => 1,
ArchiveState::Pinned => 2,
},
param: self.param.to_string(), param: self.param.to_string(),
gossiped_timestamp: self.get_gossiped_timestamp(context), gossiped_timestamp: self.get_gossiped_timestamp(context),
is_sending_locations: self.is_sending_locations, is_sending_locations: self.is_sending_locations,
@@ -994,10 +997,7 @@ pub struct ChatInfo {
pub name: String, pub name: String,
/// Whether the chat is archived. /// Whether the chat is archived.
pub archived: bool, pub archived: u8,
/// Wether the chat is pinned.
pub pinned: bool,
/// The "params" of the chat. /// The "params" of the chat.
/// ///
@@ -2535,8 +2535,7 @@ mod tests {
"id": 10, "id": 10,
"type": 100, "type": 100,
"name": "bob", "name": "bob",
"archived": false, "archived": 0,
"pinned": false,
"param": "", "param": "",
"gossiped_timestamp": 0, "gossiped_timestamp": 0,
"is_sending_locations": false, "is_sending_locations": false,