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

View File

@ -1,2 +1,2 @@
mod edit_script;
mod edit_test;
// mod edit_script;
// 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:flowy_infra/notifier.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/errors.pb.dart' as user_error;
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-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/infrastructure/repos/user_repo.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> {
let time = timestamp();
let view = View {
id: uuid_string(),
id: params.view_id,
belong_to_id: params.belong_to_id,
name: params.name,
desc: params.desc,

View File

@ -29,7 +29,7 @@ pub(crate) struct ViewController {
user: Arc<dyn WorkspaceUser>,
server: Server,
database: Arc<dyn WorkspaceDatabase>,
trash_can: Arc<TrashController>,
trash_controller: Arc<TrashController>,
document_ctx: Arc<DocumentContext>,
}
@ -45,7 +45,7 @@ impl ViewController {
user,
server,
database,
trash_can,
trash_controller: trash_can,
document_ctx,
}
}
@ -64,7 +64,7 @@ impl ViewController {
pub(crate) async fn create_view_on_local(&self, view: View) -> Result<View, FlowyError> {
let conn = &*self.database.db_connection()?;
let trash_can = self.trash_can.clone();
let trash_can = self.trash_controller.clone();
conn.immediate_transaction::<_, FlowyError, _>(|| {
let _ = self.save_view(view.clone(), conn)?;
@ -87,7 +87,7 @@ impl ViewController {
let conn = self.database.db_connection()?;
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) {
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> {
// TODO: read from server
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)
}
@ -197,7 +197,7 @@ impl ViewController {
.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);
Ok(updated_view)
}
@ -277,10 +277,10 @@ impl ViewController {
}
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 document = self.document_ctx.clone();
let trash_can = self.trash_can.clone();
let trash_can = self.trash_controller.clone();
let _ = tokio::spawn(async move {
loop {
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)]
fn notify_views_changed(
belong_to_id: &str,
trash_can: Arc<TrashController>,
trash_controller: Arc<TrashController>,
conn: &SqliteConnection,
) -> 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());
send_dart_notification(&belong_to_id, WorkspaceNotification::AppViewsChanged)
.payload(repeated_view)

View File

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