From 64384442755338a8e0398e48063309cf617a84e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Thu, 12 Mar 2020 16:28:02 +0100 Subject: [PATCH] base_client: Restore the olm machine if a session given at client creation. --- src/base_client.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/base_client.rs b/src/base_client.rs index e6d8bdfb..b0398a49 100644 --- a/src/base_client.rs +++ b/src/base_client.rs @@ -200,12 +200,18 @@ impl Client { /// * `session` - An optional session if the user already has one from a /// previous login call. pub fn new(session: Option) -> Self { + #[cfg(feature = "encryption")] + let olm = match &session { + Some(s) => Some(OlmMachine::new(&s.user_id, &s.device_id)), + None => None, + }; + Client { session, sync_token: None, joined_rooms: HashMap::new(), #[cfg(feature = "encryption")] - olm: Arc::new(Mutex::new(None)), + olm: Arc::new(Mutex::new(olm)), } }