Skip to content

Commit 7ba3020

Browse files
authored
chore: skip create sync plugin when the authenticator for given user … (#4252)
* chore: skip create sync plugin when the authenticator for given user is local * chore: bump collab
1 parent 50694bb commit 7ba3020

File tree

16 files changed

+174
-127
lines changed

16 files changed

+174
-127
lines changed

frontend/appflowy_flutter/lib/user/application/supabase_realtime.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ import 'package:appflowy_backend/log.dart';
99
import 'package:appflowy_backend/protobuf/flowy-user/protobuf.dart';
1010
import 'package:supabase_flutter/supabase_flutter.dart';
1111

12-
import 'auth/auth_service.dart';
13-
1412
/// A service to manage realtime interactions with Supabase.
1513
///
1614
/// `SupbaseRealtimeService` handles subscribing to table changes in Supabase
@@ -37,10 +35,10 @@ class SupabaseRealtimeService {
3735
},
3836
onInvalidAuth: (message) async {
3937
Log.error(message);
40-
await getIt<AuthService>().signOut();
4138
channel?.unsubscribe();
4239
channel = null;
4340
if (!isLoggingOut) {
41+
isLoggingOut = true;
4442
await runAppFlowy();
4543
}
4644
},

frontend/appflowy_tauri/src-tauri/Cargo.lock

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/appflowy_tauri/src-tauri/Cargo.toml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,14 @@ client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "a45
6767
# To switch to the local path, run:
6868
# scripts/tool/update_collab_source.sh
6969
# ⚠️⚠️⚠️️
70-
collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "e7d77a4b233886c4e9b7e03934c03d3e4489ec86" }
71-
collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "e7d77a4b233886c4e9b7e03934c03d3e4489ec86" }
72-
collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "e7d77a4b233886c4e9b7e03934c03d3e4489ec86" }
73-
collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "e7d77a4b233886c4e9b7e03934c03d3e4489ec86" }
74-
collab-plugins = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "e7d77a4b233886c4e9b7e03934c03d3e4489ec86" }
75-
collab-user = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "e7d77a4b233886c4e9b7e03934c03d3e4489ec86" }
76-
collab-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "e7d77a4b233886c4e9b7e03934c03d3e4489ec86" }
77-
collab-persistence = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "e7d77a4b233886c4e9b7e03934c03d3e4489ec86" }
70+
collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "cf6aae1fbeb97d7b2f475fcdfc73217942ed8c8f" }
71+
collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "cf6aae1fbeb97d7b2f475fcdfc73217942ed8c8f" }
72+
collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "cf6aae1fbeb97d7b2f475fcdfc73217942ed8c8f" }
73+
collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "cf6aae1fbeb97d7b2f475fcdfc73217942ed8c8f" }
74+
collab-plugins = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "cf6aae1fbeb97d7b2f475fcdfc73217942ed8c8f" }
75+
collab-user = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "cf6aae1fbeb97d7b2f475fcdfc73217942ed8c8f" }
76+
collab-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "cf6aae1fbeb97d7b2f475fcdfc73217942ed8c8f" }
77+
collab-persistence = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "cf6aae1fbeb97d7b2f475fcdfc73217942ed8c8f" }
7878

7979

8080

frontend/rust-lib/Cargo.lock

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/rust-lib/Cargo.toml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,11 @@ client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "a45
109109
# To switch to the local path, run:
110110
# scripts/tool/update_collab_source.sh
111111
# ⚠️⚠️⚠️️
112-
collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "e7d77a4b233886c4e9b7e03934c03d3e4489ec86" }
113-
collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "e7d77a4b233886c4e9b7e03934c03d3e4489ec86" }
114-
collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "e7d77a4b233886c4e9b7e03934c03d3e4489ec86" }
115-
collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "e7d77a4b233886c4e9b7e03934c03d3e4489ec86" }
116-
collab-plugins = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "e7d77a4b233886c4e9b7e03934c03d3e4489ec86" }
117-
collab-user = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "e7d77a4b233886c4e9b7e03934c03d3e4489ec86" }
118-
collab-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "e7d77a4b233886c4e9b7e03934c03d3e4489ec86" }
119-
collab-persistence = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "e7d77a4b233886c4e9b7e03934c03d3e4489ec86" }
112+
collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "cf6aae1fbeb97d7b2f475fcdfc73217942ed8c8f" }
113+
collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "cf6aae1fbeb97d7b2f475fcdfc73217942ed8c8f" }
114+
collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "cf6aae1fbeb97d7b2f475fcdfc73217942ed8c8f" }
115+
collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "cf6aae1fbeb97d7b2f475fcdfc73217942ed8c8f" }
116+
collab-plugins = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "cf6aae1fbeb97d7b2f475fcdfc73217942ed8c8f" }
117+
collab-user = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "cf6aae1fbeb97d7b2f475fcdfc73217942ed8c8f" }
118+
collab-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "cf6aae1fbeb97d7b2f475fcdfc73217942ed8c8f" }
119+
collab-persistence = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "cf6aae1fbeb97d7b2f475fcdfc73217942ed8c8f" }

frontend/rust-lib/collab-integrate/src/collab_builder.rs

Lines changed: 43 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::fmt::Debug;
1+
use std::fmt::{Debug, Display};
22
use std::sync::{Arc, Weak};
33

44
use anyhow::Error;
@@ -16,13 +16,13 @@ use tracing::trace;
1616
use lib_infra::future::Fut;
1717

1818
#[derive(Clone, Debug)]
19-
pub enum CollabDataSource {
19+
pub enum CollabPluginProviderType {
2020
Local,
2121
AppFlowyCloud,
2222
Supabase,
2323
}
2424

25-
pub enum CollabStorageProviderContext {
25+
pub enum CollabPluginProviderContext {
2626
Local,
2727
AppFlowyCloud {
2828
uid: i64,
@@ -37,23 +37,43 @@ pub enum CollabStorageProviderContext {
3737
},
3838
}
3939

40-
pub trait CollabStorageProvider: Send + Sync + 'static {
41-
fn storage_source(&self) -> CollabDataSource;
40+
impl Display for CollabPluginProviderContext {
41+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
42+
let str = match self {
43+
CollabPluginProviderContext::Local => "Local".to_string(),
44+
CollabPluginProviderContext::AppFlowyCloud {
45+
uid: _,
46+
collab_object,
47+
local_collab: _,
48+
} => collab_object.to_string(),
49+
CollabPluginProviderContext::Supabase {
50+
uid: _,
51+
collab_object,
52+
local_collab: _,
53+
local_collab_db: _,
54+
} => collab_object.to_string(),
55+
};
56+
write!(f, "{}", str)
57+
}
58+
}
59+
60+
pub trait CollabCloudPluginProvider: Send + Sync + 'static {
61+
fn provider_type(&self) -> CollabPluginProviderType;
4262

43-
fn get_plugins(&self, context: CollabStorageProviderContext) -> Fut<Vec<Arc<dyn CollabPlugin>>>;
63+
fn get_plugins(&self, context: CollabPluginProviderContext) -> Fut<Vec<Arc<dyn CollabPlugin>>>;
4464

4565
fn is_sync_enabled(&self) -> bool;
4666
}
4767

48-
impl<T> CollabStorageProvider for Arc<T>
68+
impl<T> CollabCloudPluginProvider for Arc<T>
4969
where
50-
T: CollabStorageProvider,
70+
T: CollabCloudPluginProvider,
5171
{
52-
fn storage_source(&self) -> CollabDataSource {
53-
(**self).storage_source()
72+
fn provider_type(&self) -> CollabPluginProviderType {
73+
(**self).provider_type()
5474
}
5575

56-
fn get_plugins(&self, context: CollabStorageProviderContext) -> Fut<Vec<Arc<dyn CollabPlugin>>> {
76+
fn get_plugins(&self, context: CollabPluginProviderContext) -> Fut<Vec<Arc<dyn CollabPlugin>>> {
5777
(**self).get_plugins(context)
5878
}
5979

@@ -65,7 +85,7 @@ where
6585
pub struct AppFlowyCollabBuilder {
6686
network_reachability: CollabNetworkReachability,
6787
workspace_id: RwLock<Option<String>>,
68-
cloud_storage: tokio::sync::RwLock<Arc<dyn CollabStorageProvider>>,
88+
plugin_provider: tokio::sync::RwLock<Arc<dyn CollabCloudPluginProvider>>,
6989
snapshot_persistence: Mutex<Option<Arc<dyn SnapshotPersistence>>>,
7090
rocksdb_backup: Mutex<Option<Arc<dyn RocksdbBackup>>>,
7191
device_id: String,
@@ -89,11 +109,11 @@ impl CollabBuilderConfig {
89109
}
90110

91111
impl AppFlowyCollabBuilder {
92-
pub fn new<T: CollabStorageProvider>(storage_provider: T, device_id: String) -> Self {
112+
pub fn new<T: CollabCloudPluginProvider>(storage_provider: T, device_id: String) -> Self {
93113
Self {
94114
network_reachability: CollabNetworkReachability::new(),
95115
workspace_id: Default::default(),
96-
cloud_storage: tokio::sync::RwLock::new(Arc::new(storage_provider)),
116+
plugin_provider: tokio::sync::RwLock::new(Arc::new(storage_provider)),
97117
snapshot_persistence: Default::default(),
98118
rocksdb_backup: Default::default(),
99119
device_id,
@@ -219,20 +239,20 @@ impl AppFlowyCollabBuilder {
219239
{
220240
let collab_object = self.collab_object(uid, object_id, object_type)?;
221241
if build_config.sync_enable {
222-
let cloud_storage_type = self.cloud_storage.read().await.storage_source();
242+
let provider_type = self.plugin_provider.read().await.provider_type();
223243
let span = tracing::span!(tracing::Level::TRACE, "collab_builder", object_id = %object_id);
224244
let _enter = span.enter();
225-
match cloud_storage_type {
226-
CollabDataSource::AppFlowyCloud => {
245+
match provider_type {
246+
CollabPluginProviderType::AppFlowyCloud => {
227247
#[cfg(feature = "appflowy_cloud_integrate")]
228248
{
229249
trace!("init appflowy cloud collab plugins");
230250
let local_collab = Arc::downgrade(&collab);
231251
let plugins = self
232-
.cloud_storage
252+
.plugin_provider
233253
.read()
234254
.await
235-
.get_plugins(CollabStorageProviderContext::AppFlowyCloud {
255+
.get_plugins(CollabPluginProviderContext::AppFlowyCloud {
236256
uid,
237257
collab_object: collab_object.clone(),
238258
local_collab,
@@ -245,17 +265,17 @@ impl AppFlowyCollabBuilder {
245265
}
246266
}
247267
},
248-
CollabDataSource::Supabase => {
268+
CollabPluginProviderType::Supabase => {
249269
#[cfg(feature = "supabase_integrate")]
250270
{
251271
trace!("init supabase collab plugins");
252272
let local_collab = Arc::downgrade(&collab);
253273
let local_collab_db = collab_db.clone();
254274
let plugins = self
255-
.cloud_storage
275+
.plugin_provider
256276
.read()
257277
.await
258-
.get_plugins(CollabStorageProviderContext::Supabase {
278+
.get_plugins(CollabPluginProviderContext::Supabase {
259279
uid,
260280
collab_object: collab_object.clone(),
261281
local_collab,
@@ -267,7 +287,7 @@ impl AppFlowyCollabBuilder {
267287
}
268288
}
269289
},
270-
CollabDataSource::Local => {},
290+
CollabPluginProviderType::Local => {},
271291
}
272292
}
273293

0 commit comments

Comments
 (0)