base: Use Instant instead of SystemTime for wasm compatibility
parent
b83399ba14
commit
cb12bc1584
|
@ -20,7 +20,6 @@ use std::{
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
result::Result as StdResult,
|
result::Result as StdResult,
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
time::SystemTime,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use matrix_sdk_common::{
|
use matrix_sdk_common::{
|
||||||
|
@ -36,6 +35,7 @@ use matrix_sdk_common::{
|
||||||
AnyToDeviceEvent, EventContent, StateEvent,
|
AnyToDeviceEvent, EventContent, StateEvent,
|
||||||
},
|
},
|
||||||
identifiers::{RoomId, UserId},
|
identifiers::{RoomId, UserId},
|
||||||
|
instant::Instant,
|
||||||
locks::RwLock,
|
locks::RwLock,
|
||||||
Raw,
|
Raw,
|
||||||
};
|
};
|
||||||
|
@ -701,7 +701,7 @@ impl BaseClient {
|
||||||
return Ok(SyncResponse::new(response.next_batch));
|
return Ok(SyncResponse::new(response.next_batch));
|
||||||
}
|
}
|
||||||
|
|
||||||
let now = SystemTime::now();
|
let now = Instant::now();
|
||||||
|
|
||||||
#[cfg(feature = "encryption")]
|
#[cfg(feature = "encryption")]
|
||||||
let to_device = {
|
let to_device = {
|
||||||
|
@ -892,7 +892,7 @@ impl BaseClient {
|
||||||
*self.sync_token.write().await = Some(response.next_batch.clone());
|
*self.sync_token.write().await = Some(response.next_batch.clone());
|
||||||
self.apply_changes(&changes).await;
|
self.apply_changes(&changes).await;
|
||||||
|
|
||||||
info!("Processed a sync response in {:?}", now.elapsed().unwrap());
|
info!("Processed a sync response in {:?}", now.elapsed());
|
||||||
|
|
||||||
let response = SyncResponse {
|
let response = SyncResponse {
|
||||||
next_batch: response.next_batch,
|
next_batch: response.next_batch,
|
||||||
|
|
|
@ -12,10 +12,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
use std::{
|
use std::sync::{Arc, RwLock};
|
||||||
sync::{Arc, RwLock},
|
|
||||||
time::SystemTime,
|
|
||||||
};
|
|
||||||
|
|
||||||
use dashmap::{DashMap, DashSet};
|
use dashmap::{DashMap, DashSet};
|
||||||
use matrix_sdk_common::{
|
use matrix_sdk_common::{
|
||||||
|
@ -26,6 +23,7 @@ use matrix_sdk_common::{
|
||||||
AnyBasicEvent, AnyStrippedStateEvent, AnySyncStateEvent, EventContent, EventType,
|
AnyBasicEvent, AnyStrippedStateEvent, AnySyncStateEvent, EventContent, EventType,
|
||||||
},
|
},
|
||||||
identifiers::{RoomId, UserId},
|
identifiers::{RoomId, UserId},
|
||||||
|
instant::Instant,
|
||||||
};
|
};
|
||||||
|
|
||||||
use tracing::info;
|
use tracing::info;
|
||||||
|
@ -91,7 +89,7 @@ impl MemoryStore {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn save_changes(&self, changes: &StateChanges) -> Result<()> {
|
pub async fn save_changes(&self, changes: &StateChanges) -> Result<()> {
|
||||||
let now = SystemTime::now();
|
let now = Instant::now();
|
||||||
|
|
||||||
if let Some(s) = &changes.sync_token {
|
if let Some(s) = &changes.sync_token {
|
||||||
*self.sync_token.write().unwrap() = Some(s.to_owned());
|
*self.sync_token.write().unwrap() = Some(s.to_owned());
|
||||||
|
|
Loading…
Reference in New Issue