fix compile errors

This commit is contained in:
appflowy 2021-12-29 21:49:31 +08:00
parent 152cb17701
commit f17f0dd6cf
6 changed files with 40 additions and 62 deletions

View File

@ -15,10 +15,9 @@ use flowy_collaboration::{
}, },
errors::CollaborateError, errors::CollaborateError,
protobuf::DocIdentifier, protobuf::DocIdentifier,
sync::{DocumentPersistence, ServerDocumentManager},
}; };
use lib_infra::future::BoxResultFuture; use lib_infra::future::BoxResultFuture;
use flowy_collaboration::sync::{DocumentPersistence, ServerDocumentManager};
use std::{ use std::{
convert::TryInto, convert::TryInto,
fmt::{Debug, Formatter}, fmt::{Debug, Formatter},
@ -57,9 +56,10 @@ impl WebSocketReceiver for DocumentWebSocketReceiver {
actix_rt::spawn(async move { actix_rt::spawn(async move {
let msg = WSActorMessage::ClientData { let msg = WSActorMessage::ClientData {
client_data: data, client_data: data,
ret,
persistence, persistence,
ret,
}; };
match sender.send(msg).await { match sender.send(msg).await {
Ok(_) => {}, Ok(_) => {},
Err(e) => log::error!("{}", e), Err(e) => log::error!("{}", e),

View File

@ -1,2 +1,2 @@
mod edit_script; // mod edit_script;
mod edit_test; // mod edit_test;

View File

@ -6,12 +6,12 @@ import 'package:app_flowy/workspace/domain/i_user.dart';
import 'package:app_flowy/workspace/infrastructure/repos/user_repo.dart'; import 'package:app_flowy/workspace/infrastructure/repos/user_repo.dart';
import 'package:flowy_infra/notifier.dart'; import 'package:flowy_infra/notifier.dart';
import 'package:flowy_sdk/protobuf/dart-notify/protobuf.dart'; import 'package:flowy_sdk/protobuf/dart-notify/protobuf.dart';
import 'package:flowy_sdk/protobuf/flowy-core/observable.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-user-data-model/errors.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-user-data-model/errors.pb.dart';
// import 'package:flowy_sdk/protobuf/flowy-user/errors.pb.dart' as user_error; // import 'package:flowy_sdk/protobuf/flowy-user/errors.pb.dart' as user_error;
import 'package:flowy_sdk/protobuf/flowy-user/observable.pb.dart' as user; import 'package:flowy_sdk/protobuf/flowy-user/observable.pb.dart' as user;
import 'package:flowy_sdk/protobuf/flowy-core-data-model/workspace_create.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-core-data-model/workspace_create.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-core/observable.pb.dart';
export 'package:app_flowy/workspace/domain/i_user.dart'; export 'package:app_flowy/workspace/domain/i_user.dart';
export 'package:app_flowy/workspace/infrastructure/repos/user_repo.dart'; export 'package:app_flowy/workspace/infrastructure/repos/user_repo.dart';
import 'package:flowy_sdk/rust_stream.dart'; import 'package:flowy_sdk/rust_stream.dart';

View File

@ -51,7 +51,7 @@ impl WorkspaceServerAPI for WorkspaceServerMock {
fn create_view(&self, _token: &str, params: CreateViewParams) -> FutureResult<View, FlowyError> { fn create_view(&self, _token: &str, params: CreateViewParams) -> FutureResult<View, FlowyError> {
let time = timestamp(); let time = timestamp();
let view = View { let view = View {
id: uuid_string(), id: params.view_id,
belong_to_id: params.belong_to_id, belong_to_id: params.belong_to_id,
name: params.name, name: params.name,
desc: params.desc, desc: params.desc,

View File

@ -29,7 +29,7 @@ pub(crate) struct ViewController {
user: Arc<dyn WorkspaceUser>, user: Arc<dyn WorkspaceUser>,
server: Server, server: Server,
database: Arc<dyn WorkspaceDatabase>, database: Arc<dyn WorkspaceDatabase>,
trash_can: Arc<TrashController>, trash_controller: Arc<TrashController>,
document_ctx: Arc<DocumentContext>, document_ctx: Arc<DocumentContext>,
} }
@ -45,7 +45,7 @@ impl ViewController {
user, user,
server, server,
database, database,
trash_can, trash_controller: trash_can,
document_ctx, document_ctx,
} }
} }
@ -64,7 +64,7 @@ impl ViewController {
pub(crate) async fn create_view_on_local(&self, view: View) -> Result<View, FlowyError> { pub(crate) async fn create_view_on_local(&self, view: View) -> Result<View, FlowyError> {
let conn = &*self.database.db_connection()?; let conn = &*self.database.db_connection()?;
let trash_can = self.trash_can.clone(); let trash_can = self.trash_controller.clone();
conn.immediate_transaction::<_, FlowyError, _>(|| { conn.immediate_transaction::<_, FlowyError, _>(|| {
let _ = self.save_view(view.clone(), conn)?; let _ = self.save_view(view.clone(), conn)?;
@ -87,7 +87,7 @@ impl ViewController {
let conn = self.database.db_connection()?; let conn = self.database.db_connection()?;
let view_table = ViewTableSql::read_view(&params.view_id, &*conn)?; let view_table = ViewTableSql::read_view(&params.view_id, &*conn)?;
let trash_ids = self.trash_can.read_trash_ids(&conn)?; let trash_ids = self.trash_controller.read_trash_ids(&conn)?;
if trash_ids.contains(&view_table.id) { if trash_ids.contains(&view_table.id) {
return Err(FlowyError::record_not_found()); return Err(FlowyError::record_not_found());
} }
@ -177,7 +177,7 @@ impl ViewController {
pub(crate) async fn read_views_belong_to(&self, belong_to_id: &str) -> Result<RepeatedView, FlowyError> { pub(crate) async fn read_views_belong_to(&self, belong_to_id: &str) -> Result<RepeatedView, FlowyError> {
// TODO: read from server // TODO: read from server
let conn = self.database.db_connection()?; let conn = self.database.db_connection()?;
let repeated_view = read_belonging_views_on_local(belong_to_id, self.trash_can.clone(), &conn)?; let repeated_view = read_belonging_views_on_local(belong_to_id, self.trash_controller.clone(), &conn)?;
Ok(repeated_view) Ok(repeated_view)
} }
@ -197,7 +197,7 @@ impl ViewController {
.send(); .send();
// //
let _ = notify_views_changed(&updated_view.belong_to_id, self.trash_can.clone(), conn)?; let _ = notify_views_changed(&updated_view.belong_to_id, self.trash_controller.clone(), conn)?;
let _ = self.update_view_on_server(params); let _ = self.update_view_on_server(params);
Ok(updated_view) Ok(updated_view)
} }
@ -277,10 +277,10 @@ impl ViewController {
} }
fn listen_trash_can_event(&self) { fn listen_trash_can_event(&self) {
let mut rx = self.trash_can.subscribe(); let mut rx = self.trash_controller.subscribe();
let database = self.database.clone(); let database = self.database.clone();
let document = self.document_ctx.clone(); let document = self.document_ctx.clone();
let trash_can = self.trash_can.clone(); let trash_can = self.trash_controller.clone();
let _ = tokio::spawn(async move { let _ = tokio::spawn(async move {
loop { loop {
let mut stream = Box::pin(rx.recv().into_stream().filter_map(|result| async move { let mut stream = Box::pin(rx.recv().into_stream().filter_map(|result| async move {
@ -377,10 +377,10 @@ fn notify_dart(view_table: ViewTable, notification: WorkspaceNotification) {
#[tracing::instrument(skip(belong_to_id, trash_can, conn), fields(view_count), err)] #[tracing::instrument(skip(belong_to_id, trash_can, conn), fields(view_count), err)]
fn notify_views_changed( fn notify_views_changed(
belong_to_id: &str, belong_to_id: &str,
trash_can: Arc<TrashController>, trash_controller: Arc<TrashController>,
conn: &SqliteConnection, conn: &SqliteConnection,
) -> FlowyResult<()> { ) -> FlowyResult<()> {
let repeated_view = read_belonging_views_on_local(belong_to_id, trash_can.clone(), conn)?; let repeated_view = read_belonging_views_on_local(belong_to_id, trash_controller.clone(), conn)?;
tracing::Span::current().record("view_count", &format!("{}", repeated_view.len()).as_str()); tracing::Span::current().record("view_count", &format!("{}", repeated_view.len()).as_str());
send_dart_notification(&belong_to_id, WorkspaceNotification::AppViewsChanged) send_dart_notification(&belong_to_id, WorkspaceNotification::AppViewsChanged)
.payload(repeated_view) .payload(repeated_view)

View File

@ -18,6 +18,7 @@ use flowy_collaboration::{
use flowy_error::{internal_error, FlowyError, FlowyResult}; use flowy_error::{internal_error, FlowyError, FlowyResult};
use lib_infra::future::FutureResult; use lib_infra::future::FutureResult;
use crate::services::doc::web_socket::local_ws_impl::LocalWebSocketManager;
use flowy_collaboration::entities::ws::DocumentServerWSDataType; use flowy_collaboration::entities::ws::DocumentServerWSDataType;
use lib_ws::WSConnectState; use lib_ws::WSConnectState;
use std::{collections::VecDeque, convert::TryFrom, sync::Arc}; use std::{collections::VecDeque, convert::TryFrom, sync::Arc};
@ -35,52 +36,29 @@ pub(crate) async fn make_document_ws_manager(
rev_manager: Arc<RevisionManager>, rev_manager: Arc<RevisionManager>,
ws: Arc<dyn DocumentWebSocket>, ws: Arc<dyn DocumentWebSocket>,
) -> Arc<dyn DocumentWebSocketManager> { ) -> Arc<dyn DocumentWebSocketManager> {
// if cfg!(feature = "http_server") { if cfg!(feature = "http_server") {
// let shared_sink = let shared_sink = Arc::new(SharedWSSinkDataProvider::new(rev_manager.clone()));
// Arc::new(SharedWSSinkDataProvider::new(rev_manager.clone())); let ws_stream_consumer = Arc::new(DocumentWebSocketSteamConsumerAdapter {
// let ws_stream_consumer = Arc::new(DocumentWebSocketSteamConsumerAdapter { doc_id: doc_id.clone(),
// doc_id: doc_id.clone(), user_id: user_id.clone(),
// user_id: user_id.clone(), editor_edit_queue: editor_edit_queue.clone(),
// editor_edit_queue: editor_edit_queue.clone(), rev_manager: rev_manager.clone(),
// rev_manager: rev_manager.clone(), shared_sink: shared_sink.clone(),
// shared_sink: shared_sink.clone(), });
// }); let ws_stream_provider = DocumentWSSinkDataProviderAdapter(shared_sink.clone());
// let ws_stream_provider = let ws_manager = Arc::new(HttpWebSocketManager::new(
// DocumentWSSinkDataProviderAdapter(shared_sink.clone()); &doc_id,
// let ws_manager = Arc::new(HttpWebSocketManager::new( ws.clone(),
// &doc_id, Arc::new(ws_stream_provider),
// ws.clone(), ws_stream_consumer,
// Arc::new(ws_stream_provider), ));
// ws_stream_consumer, notify_user_has_connected(&user_id, &doc_id, rev_manager.clone(), shared_sink).await;
// )); listen_document_ws_state(&user_id, &doc_id, ws_manager.scribe_state(), rev_manager.clone());
// notify_user_has_connected(&user_id, &doc_id, rev_manager.clone(),
// shared_sink).await; listen_document_ws_state(&user_id, &doc_id,
// ws_manager.scribe_state(), rev_manager.clone());
//
// Arc::new(ws_manager)
// } else {
// Arc::new(Arc::new(LocalWebSocketManager {}))
// }
let shared_sink = Arc::new(SharedWSSinkDataProvider::new(rev_manager.clone())); Arc::new(ws_manager)
let ws_stream_consumer = Arc::new(DocumentWebSocketSteamConsumerAdapter { } else {
doc_id: doc_id.clone(), Arc::new(Arc::new(LocalWebSocketManager {}))
user_id: user_id.clone(), }
editor_edit_queue: editor_edit_queue.clone(),
rev_manager: rev_manager.clone(),
shared_sink: shared_sink.clone(),
});
let ws_stream_provider = DocumentWSSinkDataProviderAdapter(shared_sink.clone());
let ws_manager = Arc::new(HttpWebSocketManager::new(
&doc_id,
ws.clone(),
Arc::new(ws_stream_provider),
ws_stream_consumer,
));
notify_user_has_connected(&user_id, &doc_id, rev_manager.clone(), shared_sink).await;
listen_document_ws_state(&user_id, &doc_id, ws_manager.scribe_state(), rev_manager.clone());
Arc::new(ws_manager)
} }
async fn notify_user_has_connected( async fn notify_user_has_connected(