base_client: Restore the olm machine if a session given at client creation.

master
Damir Jelić 2020-03-12 16:28:02 +01:00
parent 545ebe8d9c
commit 6438444275
1 changed files with 7 additions and 1 deletions

View File

@ -200,12 +200,18 @@ impl Client {
/// * `session` - An optional session if the user already has one from a /// * `session` - An optional session if the user already has one from a
/// previous login call. /// previous login call.
pub fn new(session: Option<Session>) -> Self { pub fn new(session: Option<Session>) -> Self {
#[cfg(feature = "encryption")]
let olm = match &session {
Some(s) => Some(OlmMachine::new(&s.user_id, &s.device_id)),
None => None,
};
Client { Client {
session, session,
sync_token: None, sync_token: None,
joined_rooms: HashMap::new(), joined_rooms: HashMap::new(),
#[cfg(feature = "encryption")] #[cfg(feature = "encryption")]
olm: Arc::new(Mutex::new(None)), olm: Arc::new(Mutex::new(olm)),
} }
} }