Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: adding suffix for user data folder when current cloud type is appflowy cloud #3918

Merged
merged 16 commits into from
Nov 12, 2023
Merged
8 changes: 0 additions & 8 deletions frontend/.vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -314,13 +314,5 @@
"cwd": "${workspaceFolder}/appflowy_flutter"
}
},
{
"label": "AF: Generate AppFlowyEnv",
"type": "shell",
"command": "dart run build_runner build --delete-conflicting-outputs",
"options": {
"cwd": "${workspaceFolder}/appflowy_flutter/packages/appflowy_backend"
}
}
]
}
22 changes: 15 additions & 7 deletions frontend/appflowy_flutter/dev.env
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,21 @@ CLOUD_TYPE=0

# Supabase Configuration
# If using Supabase (CLOUD_TYPE=1), provide the following details:
SUPABASE_URL=replace-with-your-supabase-url
SUPABASE_ANON_KEY=replace-with-your-supabase-key
SUPABASE_URL=
SUPABASE_ANON_KEY=

# AppFlowy Cloud Configuration
# If using AppFlowy Cloud (CLOUD_TYPE=2), provide the following details:
APPFLOWY_CLOUD_BASE_URL=https://xxxxxxxxx
APPFLOWY_CLOUD_WS_BASE_URL=wss://xxxxxxxxx
APPFLOWY_CLOUD_GOTRUE_URL=https://xxxxxxxxx


# For instance:
# APPFLOWY_CLOUD_BASE_URL=https://xxxxxxxxx
# APPFLOWY_CLOUD_WS_BASE_URL=wss://xxxxxxxxx
# APPFLOWY_CLOUD_GOTRUE_URL=https://xxxxxxxxx
#
# Local host machine(For local develop)
# APPFLOWY_CLOUD_BASE_URL=http://localhost:8000
# APPFLOWY_CLOUD_WS_BASE_URL=ws://localhost:8000/ws
# APPFLOWY_CLOUD_GOTRUE_URL=http://localhost:9998

APPFLOWY_CLOUD_BASE_URL=
APPFLOWY_CLOUD_WS_BASE_URL=
APPFLOWY_CLOUD_GOTRUE_URL=
14 changes: 11 additions & 3 deletions frontend/appflowy_flutter/lib/env/env.dart
Original file line number Diff line number Diff line change
Expand Up @@ -101,16 +101,24 @@ CloudType currentCloudType() {
final value = Env.cloudType;
if (value == 1) {
if (Env.supabaseUrl.isEmpty || Env.supabaseAnonKey.isEmpty) {
Log.error("Supabase is not configured");
Log.error(
"Supabase is not configured correctly. The values are: "
"url: ${Env.supabaseUrl}, anonKey: ${Env.supabaseAnonKey}",
);
return CloudType.unknown;
} else {
return CloudType.supabase;
}
}

if (value == 2) {
if (Env.afCloudBaseUrl.isEmpty || Env.afCloudWSBaseUrl.isEmpty) {
Log.error("AppFlowy cloud is not configured");
if (Env.afCloudBaseUrl.isEmpty ||
Env.afCloudWSBaseUrl.isEmpty ||
Env.afCloudGoTrueUrl.isEmpty) {
Log.error(
"AppFlowy cloud is not configured correctly. The values are: "
"baseUrl: ${Env.afCloudBaseUrl}, wsBaseUrl: ${Env.afCloudWSBaseUrl}, gotrueUrl: ${Env.afCloudGoTrueUrl}",
);
return CloudType.unknown;
} else {
return CloudType.appflowyCloud;
Expand Down
4 changes: 1 addition & 3 deletions frontend/appflowy_flutter/lib/startup/tasks/rust_sdk.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ class InitRustSDKTask extends LaunchTask {

// Pass the environment variables to the Rust SDK
final env = getAppFlowyEnv();
context.getIt<FlowySDK>().setEnv(jsonEncode(env.toJson()));

await context.getIt<FlowySDK>().init(dir);
await context.getIt<FlowySDK>().init(dir, jsonEncode(env.toJson()));
}

@override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,12 @@ class FlowySDK {

void dispose() {}

Future<void> init(Directory sdkDir) async {
Future<void> init(Directory sdkDir, String env) async {
final port = RustStreamReceiver.shared.port;
ffi.set_stream_port(port);

ffi.store_dart_post_cobject(NativeApi.postCObject);
ffi.set_env(env.toNativeUtf8());
ffi.init_sdk(sdkDir.path.toNativeUtf8());
}

void setEnv(String envStr) {
ffi.set_env(envStr.toNativeUtf8());
}
}
Loading