Skip to content

Commit

Permalink
feat: save user metadata (AppFlowy-IO#3754)
Browse files Browse the repository at this point in the history
* feat: save user metadata

* chore: update client api

* refactor: separate test methods

* chore: save updated at

* chore: clippy

* chore: fix test
  • Loading branch information
appflowy authored Oct 24, 2023
1 parent 16a4bab commit 71f80be
Show file tree
Hide file tree
Showing 62 changed files with 1,525 additions and 1,476 deletions.
23 changes: 0 additions & 23 deletions .run/ProtoBuf_Gen.run.xml

This file was deleted.

18 changes: 0 additions & 18 deletions .run/Run backend.run.xml

This file was deleted.

16 changes: 0 additions & 16 deletions .run/dart-event.run.xml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,7 @@ class PluginSandbox {
PluginConfig? config,
}) {
if (_pluginBuilders.containsKey(pluginType)) {
throw PlatformException(
code: '-1',
message: "$pluginType was registered before",
);
return;
}
_pluginBuilders[pluginType] = builder;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:appflowy/env/env.dart';
import 'package:appflowy/startup/startup.dart';
import 'package:appflowy/user/application/auth/auth_service.dart';
import 'package:appflowy/user/application/user_auth_listener.dart';
import 'package:appflowy_backend/log.dart';

class InitAppFlowyCloudTask extends LaunchTask {
final _authStateListener = UserAuthStateListener();
Expand All @@ -18,6 +19,7 @@ class InitAppFlowyCloudTask extends LaunchTask {
isLoggingOut = false;
},
onInvalidAuth: (message) async {
Log.error(message);
await getIt<AuthService>().signOut();
// TODO(nathan): Show a dialog to notify the user that the session is expired.
if (!isLoggingOut) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class UserAuthStateListener {
_didSignIn?.call();
break;
case AuthStatePB.InvalidAuth:
_onInvalidAuth?.call("");
_onInvalidAuth?.call(pb.message);
break;
default:
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,6 @@ import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:go_router/go_router.dart';

// [[diagram: splash screen]]
// ┌────────────────┐1.get user ┌──────────┐ ┌────────────┐ 2.send UserEventCheckUser
// │ SplashScreen │──────────▶│SplashBloc│────▶│ISplashUser │─────┐
// └────────────────┘ └──────────┘ └────────────┘ │
// │
// ▼
// ┌───────────┐ ┌─────────────┐ ┌────────┐
// │HomeScreen │◀───────────│BlocListener │◀────────────────│RustSDK │
// └───────────┘ └─────────────┘ └────────┘
// 4. Show HomeScreen or SignIn 3.return AuthState
class SplashScreen extends StatelessWidget {
/// Root Page of the app.
const SplashScreen({
Expand Down Expand Up @@ -82,7 +72,7 @@ class SplashScreen extends StatelessWidget {
(check) async {
/// If encryption is needed, the user is navigated to the encryption screen.
/// Otherwise, it fetches the current workspace for the user and navigates them
if (check.isNeedSecret) {
if (check.requireSecret) {
getIt<AuthRouter>().pushEncryptionScreen(context, userProfile);
} else {
final result = await FolderEventGetCurrentWorkspace().send();
Expand Down
15 changes: 8 additions & 7 deletions frontend/appflowy_tauri/src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion frontend/appflowy_tauri/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ custom-protocol = ["tauri/custom-protocol"]
# Run the script:
# scripts/tool/update_client_api_rev.sh new_rev_id
# ⚠️⚠️⚠️️
client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "7a309c6f69d8b34709292052e9ef0561e16c82a1" }
client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "141354bfa9d08c387cf9beb9697b89b052790e89" }
# Please use the following script to update collab.
# Working directory: frontend
#
Expand Down
33 changes: 24 additions & 9 deletions frontend/rust-lib/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion frontend/rust-lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ incremental = false
# Run the script:
# scripts/tool/update_client_api_rev.sh new_rev_id
# ⚠️⚠️⚠️️
client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "7a309c6f69d8b34709292052e9ef0561e16c82a1" }
client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "141354bfa9d08c387cf9beb9697b89b052790e89" }
# Please use the following script to update collab.
# Working directory: frontend
#
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
use std::collections::HashMap;

use serde_json::Value;

use flowy_document2::entities::*;
use flowy_document2::event_map::DocumentEvent;
use flowy_folder2::entities::{CreateViewPayloadPB, ViewLayoutPB, ViewPB};
use flowy_folder2::event_map::FolderEvent;
use serde_json::Value;
use std::collections::HashMap;

use crate::document::utils::{gen_delta_str, gen_id, gen_text_block_data};
use crate::event_builder::EventBuilder;
use crate::FlowyCoreTest;
use crate::EventIntegrationTest;

const TEXT_BLOCK_TY: &str = "paragraph";

pub struct DocumentEventTest {
inner: FlowyCoreTest,
inner: EventIntegrationTest,
}

pub struct OpenDocumentData {
Expand All @@ -22,11 +24,11 @@ pub struct OpenDocumentData {

impl DocumentEventTest {
pub async fn new() -> Self {
let sdk = FlowyCoreTest::new_with_guest_user().await;
let sdk = EventIntegrationTest::new_with_guest_user().await;
Self { inner: sdk }
}

pub fn new_with_core(core: FlowyCoreTest) -> Self {
pub fn new_with_core(core: EventIntegrationTest) -> Self {
Self { inner: core }
}

Expand Down
8 changes: 4 additions & 4 deletions frontend/rust-lib/event-integration/src/event_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ use lib_dispatch::prelude::{
AFPluginDispatcher, AFPluginEventResponse, AFPluginFromBytes, AFPluginRequest, ToBytes, *,
};

use crate::FlowyCoreTest;
use crate::EventIntegrationTest;

#[derive(Clone)]
pub struct EventBuilder {
context: TestContext,
}

impl EventBuilder {
pub fn new(sdk: FlowyCoreTest) -> Self {
pub fn new(sdk: EventIntegrationTest) -> Self {
Self {
context: TestContext::new(sdk),
}
Expand Down Expand Up @@ -121,13 +121,13 @@ impl EventBuilder {

#[derive(Clone)]
pub struct TestContext {
pub sdk: FlowyCoreTest,
pub sdk: EventIntegrationTest,
request: Option<AFPluginRequest>,
response: Option<AFPluginEventResponse>,
}

impl TestContext {
pub fn new(sdk: FlowyCoreTest) -> Self {
pub fn new(sdk: EventIntegrationTest) -> Self {
Self {
sdk,
request: None,
Expand Down
Loading

0 comments on commit 71f80be

Please sign in to comment.