Skip to content

Commit

Permalink
feat: return all reminders
Browse files Browse the repository at this point in the history
  • Loading branch information
appflowy committed Aug 13, 2023
1 parent 235bcf5 commit 7f26d56
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
19 changes: 10 additions & 9 deletions appflowy-integrate/src/collab_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,24 +55,25 @@ pub struct AppFlowyCollabBuilder {
network_reachability: CollabNetworkReachability,
workspace_id: RwLock<Option<String>>,
cloud_storage: RwLock<Arc<dyn CollabStorageProvider>>,
snapshot_persistence: Option<Arc<dyn SnapshotPersistence>>,
snapshot_persistence: Mutex<Option<Arc<dyn SnapshotPersistence>>>,
device_id: Mutex<String>,
}

impl AppFlowyCollabBuilder {
pub fn new<T: CollabStorageProvider>(
cloud_storage: T,
snapshot_persistence: Option<Arc<dyn SnapshotPersistence>>,
) -> Self {
pub fn new<T: CollabStorageProvider>(cloud_storage: T) -> Self {
Self {
network_reachability: CollabNetworkReachability::new(),
workspace_id: Default::default(),
cloud_storage: RwLock::new(Arc::new(cloud_storage)),
snapshot_persistence,
snapshot_persistence: Default::default(),
device_id: Default::default(),
}
}

pub fn set_snapshot_persistence(&self, snapshot_persistence: Arc<dyn SnapshotPersistence>) {
*self.snapshot_persistence.lock() = Some(snapshot_persistence);
}

pub fn initialize(&self, workspace_id: String) {
*self.workspace_id.write() = Some(workspace_id);
}
Expand Down Expand Up @@ -104,13 +105,13 @@ impl AppFlowyCollabBuilder {
object_id: &str,
object_type: CollabType,
raw_data: CollabRawData,
db: Weak<RocksCollabDB>,
collab_db: Weak<RocksCollabDB>,
) -> Result<Arc<MutexCollab>, Error> {
self.build_with_config(
uid,
object_id,
object_type,
db,
collab_db,
raw_data,
&CollabPersistenceConfig::default(),
)
Expand Down Expand Up @@ -196,7 +197,7 @@ impl AppFlowyCollabBuilder {
CollabStorageType::Local => {},
}

if let Some(snapshot_persistence) = &self.snapshot_persistence {
if let Some(snapshot_persistence) = self.snapshot_persistence.lock().as_ref() {
if config.enable_snapshot {
let collab_object = CollabObject::new(uid, object_id.to_string(), object_type)
.with_device_id(self.device_id.lock().clone());
Expand Down
2 changes: 2 additions & 0 deletions collab-plugins/src/cloud_storage/remote_collab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,7 @@ pub enum CollabType {
WorkspaceDatabase = 2,
Folder = 3,
DatabaseRow = 4,
UserAwareness = 5,
}

impl CollabType {
Expand All @@ -614,6 +615,7 @@ impl Display for CollabType {
Self::WorkspaceDatabase => f.write_str("WorkspaceDatabase"),
Self::DatabaseRow => f.write_str("DatabaseRow"),
Self::Folder => f.write_str("Folder"),
Self::UserAwareness => f.write_str("UserAwareness"),
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions collab-user/src/user_awareness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,11 @@ impl UserAwareness {
self.reminders.add(reminder);
}

/// Returns all reminders in the `UserAwareness` object.
pub fn get_all_reminders(&self) -> Vec<Reminder> {
self.reminders.get_all_reminders()
}

/// Removes an existing reminder from the `UserAwareness` object.
///
/// # Arguments
Expand Down

0 comments on commit 7f26d56

Please sign in to comment.