feat: Sync chat Blocked state across devices (#4817)

This commit is contained in:
iequidoo
2023-10-20 02:39:30 -03:00
committed by iequidoo
parent 0619e2a129
commit 79cebe66de
6 changed files with 257 additions and 16 deletions

View File

@@ -173,6 +173,7 @@ impl ContextBuilder {
#[derive(Clone, Debug)]
pub struct Context {
pub(crate) inner: Arc<InnerContext>,
nosync: bool,
}
impl Deref for Context {
@@ -392,11 +393,34 @@ impl Context {
let ctx = Context {
inner: Arc::new(inner),
nosync: false,
};
Ok(ctx)
}
/// Returns a `Context` in which sending sync messages must be skipped. `Self::unwrap_nosync()`
/// should be used to check this.
pub(crate) fn nosync(&self) -> Self {
Self {
inner: self.inner.clone(),
nosync: true,
}
}
/// Checks if sending sync messages must be skipped. Returns the original context and the result
/// of the check. If it's `true`, calls to [`Self::add_sync_item()`] mustn't be done to prevent
/// extra/recursive synchronisation.
pub(crate) fn unwrap_nosync(&self) -> (Self, bool) {
(
Self {
inner: self.inner.clone(),
nosync: false,
},
self.nosync,
)
}
/// Starts the IO scheduler.
pub async fn start_io(&mut self) {
if !self.is_configured().await.unwrap_or_default() {