mirror of
https://github.com/chatmail/core.git
synced 2026-04-17 21:46:35 +03:00
Use ephemeral::Timer in MsgId.ephemeral_timer() method
This commit is contained in:
committed by
link2xt
parent
f931a905a7
commit
0c47489a3b
@@ -211,10 +211,7 @@ impl ChatId {
|
|||||||
|
|
||||||
impl MsgId {
|
impl MsgId {
|
||||||
/// Returns ephemeral message timer value for the message.
|
/// Returns ephemeral message timer value for the message.
|
||||||
pub(crate) async fn ephemeral_timer(
|
pub(crate) async fn ephemeral_timer(self, context: &Context) -> crate::sql::Result<Timer> {
|
||||||
self,
|
|
||||||
context: &Context,
|
|
||||||
) -> crate::sql::Result<Option<i64>> {
|
|
||||||
let res = match context
|
let res = match context
|
||||||
.sql
|
.sql
|
||||||
.query_get_value_result(
|
.query_get_value_result(
|
||||||
@@ -223,16 +220,16 @@ impl MsgId {
|
|||||||
)
|
)
|
||||||
.await?
|
.await?
|
||||||
{
|
{
|
||||||
None | Some(0) => None,
|
None | Some(0) => Timer::Disabled,
|
||||||
Some(timer) => Some(timer),
|
Some(duration) => Timer::Enabled { duration },
|
||||||
};
|
};
|
||||||
Ok(res)
|
Ok(res)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Starts ephemeral message timer for the message if it is not started yet.
|
/// Starts ephemeral message timer for the message if it is not started yet.
|
||||||
pub(crate) async fn start_ephemeral_timer(self, context: &Context) -> crate::sql::Result<()> {
|
pub(crate) async fn start_ephemeral_timer(self, context: &Context) -> crate::sql::Result<()> {
|
||||||
if let Some(ephemeral_timer) = self.ephemeral_timer(context).await? {
|
if let Timer::Enabled { duration } = self.ephemeral_timer(context).await? {
|
||||||
let ephemeral_timestamp = time() + ephemeral_timer;
|
let ephemeral_timestamp = time() + i64::from(duration);
|
||||||
|
|
||||||
context
|
context
|
||||||
.sql
|
.sql
|
||||||
|
|||||||
Reference in New Issue
Block a user