mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
Refactor/dart notification (#1740)
* refactor: notification send * refactor: rename dart-notify to flowy-notification * ci: fix clippy wanrings * ci: fix rust code converage
This commit is contained in:
@ -16,7 +16,7 @@ lib-infra = { path = "../../../shared-lib/lib-infra" }
|
||||
flowy-document = { path = "../flowy-document" }
|
||||
flowy-database = { path = "../flowy-database", optional = true }
|
||||
flowy-error = { path = "../flowy-error", features = ["db", "http_server"]}
|
||||
dart-notify = { path = "../dart-notify" }
|
||||
flowy-notification = { path = "../flowy-notification" }
|
||||
lib-dispatch = { path = "../lib-dispatch" }
|
||||
flowy-revision = { path = "../flowy-revision" }
|
||||
flowy-revision-persistence = { path = "../flowy-revision-persistence" }
|
||||
@ -52,5 +52,5 @@ sync = []
|
||||
cloud_sync = ["sync"]
|
||||
rev-sqlite = ["flowy-database", "flowy-folder/rev-sqlite"]
|
||||
flowy_unit_test = ["lib-ot/flowy_unit_test", "flowy-revision/flowy_unit_test"]
|
||||
dart = ["flowy-codegen/dart", "dart-notify/dart"]
|
||||
ts = ["flowy-codegen/ts"]
|
||||
dart = ["flowy-codegen/dart", "flowy-notification/dart"]
|
||||
ts = ["flowy-codegen/ts", "flowy-notification/ts"]
|
||||
|
@ -1,3 +1,3 @@
|
||||
# Check out the FlowyConfig (located in flowy_toml.rs) for more details.
|
||||
proto_input = ["src/entities", "src/event_map.rs", "src/dart_notification.rs"]
|
||||
proto_input = ["src/entities", "src/event_map.rs", "src/notification.rs"]
|
||||
event_files = ["src/event_map.rs"]
|
@ -8,8 +8,8 @@ mod macros;
|
||||
#[macro_use]
|
||||
extern crate flowy_database;
|
||||
|
||||
mod dart_notification;
|
||||
pub mod manager;
|
||||
mod notification;
|
||||
pub mod protobuf;
|
||||
mod util;
|
||||
|
||||
|
@ -2,10 +2,10 @@ use crate::entities::view::ViewDataFormatPB;
|
||||
use crate::entities::{ViewLayoutTypePB, ViewPB};
|
||||
use crate::services::folder_editor::FolderRevisionMergeable;
|
||||
use crate::{
|
||||
dart_notification::{send_dart_notification, FolderNotification},
|
||||
entities::workspace::RepeatedWorkspacePB,
|
||||
errors::FlowyResult,
|
||||
event_map::{FolderCouldServiceV1, WorkspaceDatabase, WorkspaceUser},
|
||||
notification::{send_dart_notification, FolderNotification},
|
||||
services::{
|
||||
folder_editor::FolderEditor, persistence::FolderPersistence, set_current_workspace, AppController,
|
||||
TrashController, ViewController, WorkspaceController,
|
||||
|
@ -1,5 +1,5 @@
|
||||
use dart_notify::DartNotifyBuilder;
|
||||
use flowy_derive::ProtoBuf_Enum;
|
||||
use flowy_notification::NotificationBuilder;
|
||||
const OBSERVABLE_CATEGORY: &str = "Workspace";
|
||||
|
||||
#[derive(ProtoBuf_Enum, Debug)]
|
||||
@ -33,11 +33,11 @@ impl std::convert::From<FolderNotification> for i32 {
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "trace")]
|
||||
pub(crate) fn send_dart_notification(id: &str, ty: FolderNotification) -> DartNotifyBuilder {
|
||||
DartNotifyBuilder::new(id, ty, OBSERVABLE_CATEGORY)
|
||||
pub(crate) fn send_dart_notification(id: &str, ty: FolderNotification) -> NotificationBuilder {
|
||||
NotificationBuilder::new(id, ty, OBSERVABLE_CATEGORY)
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "trace")]
|
||||
pub(crate) fn send_anonymous_dart_notification(ty: FolderNotification) -> DartNotifyBuilder {
|
||||
DartNotifyBuilder::new("", ty, OBSERVABLE_CATEGORY)
|
||||
pub(crate) fn send_anonymous_dart_notification(ty: FolderNotification) -> NotificationBuilder {
|
||||
NotificationBuilder::new("", ty, OBSERVABLE_CATEGORY)
|
||||
}
|
@ -1,11 +1,11 @@
|
||||
use crate::{
|
||||
dart_notification::*,
|
||||
entities::{
|
||||
app::{AppPB, CreateAppParams, *},
|
||||
trash::TrashType,
|
||||
},
|
||||
errors::*,
|
||||
event_map::{FolderCouldServiceV1, WorkspaceUser},
|
||||
notification::*,
|
||||
services::{
|
||||
persistence::{AppChangeset, FolderPersistence, FolderPersistenceTransaction},
|
||||
TrashController, TrashEvent,
|
||||
|
@ -1,8 +1,8 @@
|
||||
use crate::{
|
||||
dart_notification::{send_anonymous_dart_notification, FolderNotification},
|
||||
entities::trash::{RepeatedTrashIdPB, RepeatedTrashPB, TrashIdPB, TrashPB, TrashType},
|
||||
errors::{FlowyError, FlowyResult},
|
||||
event_map::{FolderCouldServiceV1, WorkspaceUser},
|
||||
notification::{send_anonymous_dart_notification, FolderNotification},
|
||||
services::persistence::{FolderPersistence, FolderPersistenceTransaction},
|
||||
};
|
||||
|
||||
@ -59,7 +59,7 @@ impl TrashController {
|
||||
delete_all: false,
|
||||
})?;
|
||||
|
||||
tracing::Span::current().record("putback", &format!("{:?}", &identifier).as_str());
|
||||
tracing::Span::current().record("putback", format!("{:?}", &identifier).as_str());
|
||||
let _ = self.notify.send(TrashEvent::Putback(vec![identifier].into(), tx));
|
||||
rx.recv().await.unwrap()?;
|
||||
Ok(())
|
||||
@ -118,7 +118,7 @@ impl TrashController {
|
||||
#[tracing::instrument(level = "debug", skip(self), fields(delete_trash_ids), err)]
|
||||
pub async fn delete_with_identifiers(&self, trash_identifiers: RepeatedTrashIdPB) -> FlowyResult<()> {
|
||||
let (tx, mut rx) = mpsc::channel::<FlowyResult<()>>(1);
|
||||
tracing::Span::current().record("delete_trash_ids", &format!("{}", trash_identifiers).as_str());
|
||||
tracing::Span::current().record("delete_trash_ids", format!("{}", trash_identifiers).as_str());
|
||||
let _ = self.notify.send(TrashEvent::Delete(trash_identifiers.clone(), tx));
|
||||
|
||||
match rx.recv().await {
|
||||
@ -156,7 +156,7 @@ impl TrashController {
|
||||
|
||||
tracing::Span::current().record(
|
||||
"trash_ids",
|
||||
&format!(
|
||||
format!(
|
||||
"{:?}",
|
||||
identifiers
|
||||
.iter()
|
||||
@ -282,7 +282,7 @@ impl TrashController {
|
||||
#[tracing::instrument(level = "debug", skip(repeated_trash), fields(n_trash))]
|
||||
fn notify_trash_changed<T: Into<RepeatedTrashPB>>(repeated_trash: T) {
|
||||
let repeated_trash = repeated_trash.into();
|
||||
tracing::Span::current().record("n_trash", &repeated_trash.len());
|
||||
tracing::Span::current().record("n_trash", repeated_trash.len());
|
||||
send_anonymous_dart_notification(FolderNotification::TrashUpdated)
|
||||
.payload(repeated_trash)
|
||||
.send();
|
||||
|
@ -2,13 +2,13 @@ pub use crate::entities::view::ViewDataFormatPB;
|
||||
use crate::entities::{AppPB, DeletedViewPB, ViewInfoPB, ViewLayoutTypePB};
|
||||
use crate::manager::{ViewDataProcessor, ViewDataProcessorMap};
|
||||
use crate::{
|
||||
dart_notification::{send_dart_notification, FolderNotification},
|
||||
entities::{
|
||||
trash::{RepeatedTrashIdPB, TrashType},
|
||||
view::{CreateViewParams, RepeatedViewPB, UpdateViewParams, ViewIdPB, ViewPB},
|
||||
},
|
||||
errors::{FlowyError, FlowyResult},
|
||||
event_map::{FolderCouldServiceV1, WorkspaceUser},
|
||||
notification::{send_dart_notification, FolderNotification},
|
||||
services::{
|
||||
persistence::{FolderPersistence, FolderPersistenceTransaction, ViewChangeset},
|
||||
TrashController, TrashEvent,
|
||||
|
@ -1,9 +1,9 @@
|
||||
use crate::entities::workspace::*;
|
||||
use crate::manager::FolderManager;
|
||||
use crate::{
|
||||
dart_notification::*,
|
||||
errors::*,
|
||||
event_map::{FolderCouldServiceV1, WorkspaceUser},
|
||||
notification::*,
|
||||
services::{
|
||||
persistence::{FolderPersistence, FolderPersistenceTransaction, WorkspaceChangeset},
|
||||
read_local_workspace_apps, TrashController,
|
||||
|
@ -4,9 +4,9 @@ use crate::entities::{
|
||||
workspace::{RepeatedWorkspacePB, WorkspaceIdPB, WorkspaceSettingPB, *},
|
||||
};
|
||||
use crate::{
|
||||
dart_notification::{send_dart_notification, FolderNotification},
|
||||
errors::FlowyError,
|
||||
manager::FolderManager,
|
||||
notification::{send_dart_notification, FolderNotification},
|
||||
services::{get_current_workspace, read_local_workspace_apps, WorkspaceController},
|
||||
};
|
||||
use lib_dispatch::prelude::{data_result, AFPluginData, AFPluginState, DataResult};
|
||||
|
Reference in New Issue
Block a user