Better typed Message.ephemeral_timer

This commit is contained in:
Alexander Krotov
2020-12-05 07:12:29 +03:00
committed by link2xt
parent 30e7f84770
commit dea9630380
2 changed files with 6 additions and 5 deletions

View File

@@ -2724,7 +2724,7 @@ pub unsafe extern "C" fn dc_msg_get_ephemeral_timer(msg: *mut dc_msg_t) -> u32 {
return 0; return 0;
} }
let ffi_msg = &*msg; let ffi_msg = &*msg;
ffi_msg.message.get_ephemeral_timer() ffi_msg.message.get_ephemeral_timer().to_u32()
} }
#[no_mangle] #[no_mangle]

View File

@@ -11,6 +11,7 @@ use crate::constants::*;
use crate::contact::*; use crate::contact::*;
use crate::context::*; use crate::context::*;
use crate::dc_tools::*; use crate::dc_tools::*;
use crate::ephemeral::Timer as EphemeralTimer;
use crate::error::{ensure, Error}; use crate::error::{ensure, Error};
use crate::events::EventType; use crate::events::EventType;
use crate::job::{self, Action}; use crate::job::{self, Action};
@@ -255,7 +256,7 @@ pub struct Message {
pub(crate) timestamp_sort: i64, pub(crate) timestamp_sort: i64,
pub(crate) timestamp_sent: i64, pub(crate) timestamp_sent: i64,
pub(crate) timestamp_rcvd: i64, pub(crate) timestamp_rcvd: i64,
pub(crate) ephemeral_timer: u32, pub(crate) ephemeral_timer: EphemeralTimer,
pub(crate) ephemeral_timestamp: i64, pub(crate) ephemeral_timestamp: i64,
pub(crate) text: Option<String>, pub(crate) text: Option<String>,
pub(crate) rfc724_mid: String, pub(crate) rfc724_mid: String,
@@ -523,7 +524,7 @@ impl Message {
self.param.get_int(Param::GuaranteeE2ee).unwrap_or_default() != 0 self.param.get_int(Param::GuaranteeE2ee).unwrap_or_default() != 0
} }
pub fn get_ephemeral_timer(&self) -> u32 { pub fn get_ephemeral_timer(&self) -> EphemeralTimer {
self.ephemeral_timer self.ephemeral_timer
} }
@@ -1065,8 +1066,8 @@ pub async fn get_msg_info(context: &Context, msg_id: MsgId) -> String {
ret += "\n"; ret += "\n";
} }
if msg.ephemeral_timer != 0 { if let EphemeralTimer::Enabled { duration } = msg.ephemeral_timer {
ret += &format!("Ephemeral timer: {}\n", msg.ephemeral_timer); ret += &format!("Ephemeral timer: {}\n", duration);
} }
if msg.ephemeral_timestamp != 0 { if msg.ephemeral_timestamp != 0 {