mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
Merge branch 'main' into add_workspace_settings
This commit is contained in:
commit
0d216e5647
4
frontend/.vscode/launch.json
vendored
4
frontend/.vscode/launch.json
vendored
@ -62,8 +62,10 @@
|
|||||||
{
|
{
|
||||||
"name": "AF: app_flowy (profile mode)",
|
"name": "AF: app_flowy (profile mode)",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
|
"program": "./lib/main.dart",
|
||||||
"type": "dart",
|
"type": "dart",
|
||||||
"flutterMode": "profile"
|
"flutterMode": "profile",
|
||||||
|
"cwd": "${workspaceRoot}/app_flowy"
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
}
|
}
|
@ -52,6 +52,7 @@ RUST_COMPILE_TARGET = "aarch64-apple-darwin"
|
|||||||
BUILD_FLAG = "debug"
|
BUILD_FLAG = "debug"
|
||||||
FLUTTER_OUTPUT_DIR = "Debug"
|
FLUTTER_OUTPUT_DIR = "Debug"
|
||||||
PRODUCT_EXT = "app"
|
PRODUCT_EXT = "app"
|
||||||
|
BUILD_ARCHS = "arm64"
|
||||||
|
|
||||||
[env.development-mac-x86_64]
|
[env.development-mac-x86_64]
|
||||||
RUST_LOG = "info"
|
RUST_LOG = "info"
|
||||||
@ -60,6 +61,7 @@ RUST_COMPILE_TARGET = "x86_64-apple-darwin"
|
|||||||
BUILD_FLAG = "debug"
|
BUILD_FLAG = "debug"
|
||||||
FLUTTER_OUTPUT_DIR = "Debug"
|
FLUTTER_OUTPUT_DIR = "Debug"
|
||||||
PRODUCT_EXT = "app"
|
PRODUCT_EXT = "app"
|
||||||
|
BUILD_ARCHS = "x86_64"
|
||||||
|
|
||||||
[env.production-mac-arm64]
|
[env.production-mac-arm64]
|
||||||
BUILD_FLAG = "release"
|
BUILD_FLAG = "release"
|
||||||
|
39
frontend/app_flowy/lib/core/folder_notification.dart
Normal file
39
frontend/app_flowy/lib/core/folder_notification.dart
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
import 'dart:typed_data';
|
||||||
|
import 'package:flowy_sdk/protobuf/dart-notify/protobuf.dart';
|
||||||
|
import 'package:dartz/dartz.dart';
|
||||||
|
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
|
||||||
|
import 'package:flowy_sdk/protobuf/flowy-folder/dart_notification.pb.dart';
|
||||||
|
import 'package:flowy_sdk/rust_stream.dart';
|
||||||
|
|
||||||
|
import 'notification_helper.dart';
|
||||||
|
|
||||||
|
// Folder
|
||||||
|
typedef FolderNotificationCallback = void Function(FolderNotification, Either<Uint8List, FlowyError>);
|
||||||
|
|
||||||
|
class FolderNotificationParser extends NotificationParser<FolderNotification, FlowyError> {
|
||||||
|
FolderNotificationParser({String? id, required FolderNotificationCallback callback})
|
||||||
|
: super(
|
||||||
|
id: id,
|
||||||
|
callback: callback,
|
||||||
|
tyParser: (ty) => FolderNotification.valueOf(ty),
|
||||||
|
errorParser: (bytes) => FlowyError.fromBuffer(bytes),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef FolderNotificationHandler = Function(FolderNotification ty, Either<Uint8List, FlowyError> result);
|
||||||
|
|
||||||
|
class FolderNotificationListener {
|
||||||
|
StreamSubscription<SubscribeObject>? _subscription;
|
||||||
|
FolderNotificationParser? _parser;
|
||||||
|
|
||||||
|
FolderNotificationListener({required String objectId, required FolderNotificationHandler handler})
|
||||||
|
: _parser = FolderNotificationParser(id: objectId, callback: handler) {
|
||||||
|
_subscription = RustStreamReceiver.listen((observable) => _parser?.parse(observable));
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> stop() async {
|
||||||
|
_parser = null;
|
||||||
|
await _subscription?.cancel();
|
||||||
|
}
|
||||||
|
}
|
39
frontend/app_flowy/lib/core/grid_notification.dart
Normal file
39
frontend/app_flowy/lib/core/grid_notification.dart
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
import 'dart:typed_data';
|
||||||
|
import 'package:flowy_sdk/protobuf/dart-notify/protobuf.dart';
|
||||||
|
import 'package:dartz/dartz.dart';
|
||||||
|
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
|
||||||
|
import 'package:flowy_sdk/protobuf/flowy-grid/dart_notification.pb.dart';
|
||||||
|
import 'package:flowy_sdk/rust_stream.dart';
|
||||||
|
|
||||||
|
import 'notification_helper.dart';
|
||||||
|
|
||||||
|
// Grid
|
||||||
|
typedef GridNotificationCallback = void Function(GridNotification, Either<Uint8List, FlowyError>);
|
||||||
|
|
||||||
|
class GridNotificationParser extends NotificationParser<GridNotification, FlowyError> {
|
||||||
|
GridNotificationParser({String? id, required GridNotificationCallback callback})
|
||||||
|
: super(
|
||||||
|
id: id,
|
||||||
|
callback: callback,
|
||||||
|
tyParser: (ty) => GridNotification.valueOf(ty),
|
||||||
|
errorParser: (bytes) => FlowyError.fromBuffer(bytes),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef GridNotificationHandler = Function(GridNotification ty, Either<Uint8List, FlowyError> result);
|
||||||
|
|
||||||
|
class GridNotificationListener {
|
||||||
|
StreamSubscription<SubscribeObject>? _subscription;
|
||||||
|
GridNotificationParser? _parser;
|
||||||
|
|
||||||
|
GridNotificationListener({required String objectId, required GridNotificationHandler handler})
|
||||||
|
: _parser = GridNotificationParser(id: objectId, callback: handler) {
|
||||||
|
_subscription = RustStreamReceiver.listen((observable) => _parser?.parse(observable));
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> stop() async {
|
||||||
|
_parser = null;
|
||||||
|
await _subscription?.cancel();
|
||||||
|
}
|
||||||
|
}
|
@ -1,68 +1,6 @@
|
|||||||
import 'dart:async';
|
|
||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
import 'package:flowy_sdk/protobuf/dart-notify/protobuf.dart';
|
import 'package:flowy_sdk/protobuf/dart-notify/protobuf.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-user/protobuf.dart';
|
|
||||||
import 'package:dartz/dartz.dart';
|
import 'package:dartz/dartz.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
|
|
||||||
import 'package:flowy_sdk/protobuf/flowy-folder/dart_notification.pb.dart';
|
|
||||||
import 'package:flowy_sdk/protobuf/flowy-grid/dart_notification.pb.dart';
|
|
||||||
import 'package:flowy_sdk/rust_stream.dart';
|
|
||||||
|
|
||||||
// User
|
|
||||||
typedef UserNotificationCallback = void Function(UserNotification, Either<Uint8List, FlowyError>);
|
|
||||||
|
|
||||||
class UserNotificationParser extends NotificationParser<UserNotification, FlowyError> {
|
|
||||||
UserNotificationParser({required String id, required UserNotificationCallback callback})
|
|
||||||
: super(
|
|
||||||
id: id,
|
|
||||||
callback: callback,
|
|
||||||
tyParser: (ty) => UserNotification.valueOf(ty),
|
|
||||||
errorParser: (bytes) => FlowyError.fromBuffer(bytes),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Folder
|
|
||||||
typedef FolderNotificationCallback = void Function(FolderNotification, Either<Uint8List, FlowyError>);
|
|
||||||
|
|
||||||
class FolderNotificationParser extends NotificationParser<FolderNotification, FlowyError> {
|
|
||||||
FolderNotificationParser({String? id, required FolderNotificationCallback callback})
|
|
||||||
: super(
|
|
||||||
id: id,
|
|
||||||
callback: callback,
|
|
||||||
tyParser: (ty) => FolderNotification.valueOf(ty),
|
|
||||||
errorParser: (bytes) => FlowyError.fromBuffer(bytes),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Grid
|
|
||||||
typedef GridNotificationCallback = void Function(GridNotification, Either<Uint8List, FlowyError>);
|
|
||||||
|
|
||||||
class GridNotificationParser extends NotificationParser<GridNotification, FlowyError> {
|
|
||||||
GridNotificationParser({String? id, required GridNotificationCallback callback})
|
|
||||||
: super(
|
|
||||||
id: id,
|
|
||||||
callback: callback,
|
|
||||||
tyParser: (ty) => GridNotification.valueOf(ty),
|
|
||||||
errorParser: (bytes) => FlowyError.fromBuffer(bytes),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef GridNotificationHandler = Function(GridNotification ty, Either<Uint8List, FlowyError> result);
|
|
||||||
|
|
||||||
class GridNotificationListener {
|
|
||||||
StreamSubscription<SubscribeObject>? _subscription;
|
|
||||||
GridNotificationParser? _parser;
|
|
||||||
|
|
||||||
GridNotificationListener({required String objectId, required GridNotificationHandler handler})
|
|
||||||
: _parser = GridNotificationParser(id: objectId, callback: handler) {
|
|
||||||
_subscription = RustStreamReceiver.listen((observable) => _parser?.parse(observable));
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> stop() async {
|
|
||||||
_parser = null;
|
|
||||||
await _subscription?.cancel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class NotificationParser<T, E> {
|
class NotificationParser<T, E> {
|
||||||
String? id;
|
String? id;
|
||||||
|
39
frontend/app_flowy/lib/core/user_notification.dart
Normal file
39
frontend/app_flowy/lib/core/user_notification.dart
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
import 'dart:typed_data';
|
||||||
|
import 'package:flowy_sdk/protobuf/dart-notify/protobuf.dart';
|
||||||
|
import 'package:flowy_sdk/protobuf/flowy-user/protobuf.dart';
|
||||||
|
import 'package:dartz/dartz.dart';
|
||||||
|
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
|
||||||
|
import 'package:flowy_sdk/rust_stream.dart';
|
||||||
|
|
||||||
|
import 'notification_helper.dart';
|
||||||
|
|
||||||
|
// User
|
||||||
|
typedef UserNotificationCallback = void Function(UserNotification, Either<Uint8List, FlowyError>);
|
||||||
|
|
||||||
|
class UserNotificationParser extends NotificationParser<UserNotification, FlowyError> {
|
||||||
|
UserNotificationParser({required String id, required UserNotificationCallback callback})
|
||||||
|
: super(
|
||||||
|
id: id,
|
||||||
|
callback: callback,
|
||||||
|
tyParser: (ty) => UserNotification.valueOf(ty),
|
||||||
|
errorParser: (bytes) => FlowyError.fromBuffer(bytes),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef UserNotificationHandler = Function(UserNotification ty, Either<Uint8List, FlowyError> result);
|
||||||
|
|
||||||
|
class UserNotificationListener {
|
||||||
|
StreamSubscription<SubscribeObject>? _subscription;
|
||||||
|
UserNotificationParser? _parser;
|
||||||
|
|
||||||
|
UserNotificationListener({required String objectId, required UserNotificationHandler handler})
|
||||||
|
: _parser = UserNotificationParser(id: objectId, callback: handler) {
|
||||||
|
_subscription = RustStreamReceiver.listen((observable) => _parser?.parse(observable));
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> stop() async {
|
||||||
|
_parser = null;
|
||||||
|
await _subscription?.cancel();
|
||||||
|
}
|
||||||
|
}
|
@ -4,7 +4,7 @@ import 'package:app_flowy/plugin/plugin.dart';
|
|||||||
import 'package:app_flowy/startup/startup.dart';
|
import 'package:app_flowy/startup/startup.dart';
|
||||||
import 'package:app_flowy/workspace/presentation/home/home_stack.dart';
|
import 'package:app_flowy/workspace/presentation/home/home_stack.dart';
|
||||||
import 'package:flowy_infra/notifier.dart';
|
import 'package:flowy_infra/notifier.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/view.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
|
|
||||||
export "./src/sandbox.dart";
|
export "./src/sandbox.dart";
|
||||||
|
@ -13,8 +13,8 @@ import 'package:app_flowy/user/application/prelude.dart';
|
|||||||
import 'package:app_flowy/user/presentation/router.dart';
|
import 'package:app_flowy/user/presentation/router.dart';
|
||||||
import 'package:app_flowy/workspace/presentation/home/home_stack.dart';
|
import 'package:app_flowy/workspace/presentation/home/home_stack.dart';
|
||||||
import 'package:app_flowy/workspace/presentation/home/menu/menu.dart';
|
import 'package:app_flowy/workspace/presentation/home/menu/menu.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/app.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-folder/app.pb.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/view.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-user-data-model/user_profile.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-user-data-model/user_profile.pb.dart';
|
||||||
import 'package:fluttertoast/fluttertoast.dart';
|
import 'package:fluttertoast/fluttertoast.dart';
|
||||||
import 'package:get_it/get_it.dart';
|
import 'package:get_it/get_it.dart';
|
||||||
@ -52,7 +52,7 @@ void _resolveHomeDeps(GetIt getIt) {
|
|||||||
getIt.registerSingleton(MenuSharedState());
|
getIt.registerSingleton(MenuSharedState());
|
||||||
|
|
||||||
getIt.registerFactoryParam<UserListener, UserProfile, void>(
|
getIt.registerFactoryParam<UserListener, UserProfile, void>(
|
||||||
(user, _) => UserListener(user: user),
|
(user, _) => UserListener(userProfile: user),
|
||||||
);
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -61,7 +61,7 @@ void _resolveHomeDeps(GetIt getIt) {
|
|||||||
getIt.registerFactoryParam<WelcomeBloc, UserProfile, void>(
|
getIt.registerFactoryParam<WelcomeBloc, UserProfile, void>(
|
||||||
(user, _) => WelcomeBloc(
|
(user, _) => WelcomeBloc(
|
||||||
userService: UserService(userId: user.id),
|
userService: UserService(userId: user.id),
|
||||||
userListener: getIt<UserListener>(param1: user),
|
userWorkspaceListener: UserWorkspaceListener(userProfile: user),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -73,8 +73,8 @@ void _resolveHomeDeps(GetIt getIt) {
|
|||||||
|
|
||||||
void _resolveFolderDeps(GetIt getIt) {
|
void _resolveFolderDeps(GetIt getIt) {
|
||||||
//workspace
|
//workspace
|
||||||
getIt.registerFactoryParam<WorkspaceListener, UserProfile, String>((user, workspaceId) =>
|
getIt.registerFactoryParam<WorkspaceListener, UserProfile, String>(
|
||||||
WorkspaceListener(service: WorkspaceListenerService(user: user, workspaceId: workspaceId)));
|
(user, workspaceId) => WorkspaceListener(user: user, workspaceId: workspaceId));
|
||||||
|
|
||||||
// View
|
// View
|
||||||
getIt.registerFactoryParam<ViewListener, View, void>(
|
getIt.registerFactoryParam<ViewListener, View, void>(
|
||||||
@ -98,10 +98,7 @@ void _resolveFolderDeps(GetIt getIt) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
getIt.registerFactoryParam<MenuUserBloc, UserProfile, void>(
|
getIt.registerFactoryParam<MenuUserBloc, UserProfile, void>(
|
||||||
(user, _) => MenuUserBloc(
|
(user, _) => MenuUserBloc(user),
|
||||||
user,
|
|
||||||
getIt<UserListener>(param1: user),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// App
|
// App
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
import 'package:app_flowy/core/folder_notification.dart';
|
||||||
|
import 'package:app_flowy/core/user_notification.dart';
|
||||||
import 'package:dartz/dartz.dart';
|
import 'package:dartz/dartz.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-error-code/code.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-error-code/code.pb.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/workspace.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-folder/workspace.pb.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
|
||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
import 'package:app_flowy/core/notification_helper.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-folder/dart_notification.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-folder/dart_notification.pb.dart';
|
||||||
@ -14,104 +15,58 @@ import 'package:flowy_sdk/rust_stream.dart';
|
|||||||
|
|
||||||
typedef UserProfileNotifyValue = Either<UserProfile, FlowyError>;
|
typedef UserProfileNotifyValue = Either<UserProfile, FlowyError>;
|
||||||
typedef AuthNotifyValue = Either<Unit, FlowyError>;
|
typedef AuthNotifyValue = Either<Unit, FlowyError>;
|
||||||
typedef WorkspaceListNotifyValue = Either<List<Workspace>, FlowyError>;
|
|
||||||
typedef WorkspaceSettingNotifyValue = Either<CurrentWorkspaceSetting, FlowyError>;
|
|
||||||
|
|
||||||
class UserListener {
|
class UserListener {
|
||||||
StreamSubscription<SubscribeObject>? _subscription;
|
StreamSubscription<SubscribeObject>? _subscription;
|
||||||
final _profileNotifier = PublishNotifier<UserProfileNotifyValue>();
|
PublishNotifier<AuthNotifyValue>? _authNotifier = PublishNotifier();
|
||||||
final _authNotifier = PublishNotifier<AuthNotifyValue>();
|
PublishNotifier<UserProfileNotifyValue>? _profileNotifier = PublishNotifier();
|
||||||
final _workspaceListNotifier = PublishNotifier<WorkspaceListNotifyValue>();
|
|
||||||
final _workSettingNotifier = PublishNotifier<WorkspaceSettingNotifyValue>();
|
|
||||||
|
|
||||||
FolderNotificationParser? _workspaceParser;
|
|
||||||
UserNotificationParser? _userParser;
|
UserNotificationParser? _userParser;
|
||||||
final UserProfile _user;
|
final UserProfile _userProfile;
|
||||||
UserListener({
|
UserListener({
|
||||||
required UserProfile user,
|
required UserProfile userProfile,
|
||||||
}) : _user = user;
|
}) : _userProfile = userProfile;
|
||||||
|
|
||||||
void start({
|
void start({
|
||||||
void Function(AuthNotifyValue)? onAuthChanged,
|
void Function(AuthNotifyValue)? onAuthChanged,
|
||||||
void Function(UserProfileNotifyValue)? onProfileUpdated,
|
void Function(UserProfileNotifyValue)? onProfileUpdated,
|
||||||
void Function(WorkspaceListNotifyValue)? onWorkspaceListUpdated,
|
|
||||||
void Function(WorkspaceSettingNotifyValue)? onWorkspaceSettingUpdated,
|
|
||||||
}) {
|
}) {
|
||||||
if (onAuthChanged != null) {
|
|
||||||
_authNotifier.addListener(() {
|
|
||||||
onAuthChanged(_authNotifier.currentValue!);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (onProfileUpdated != null) {
|
if (onProfileUpdated != null) {
|
||||||
_profileNotifier.addListener(() {
|
_profileNotifier?.addPublishListener(onProfileUpdated);
|
||||||
onProfileUpdated(_profileNotifier.currentValue!);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (onWorkspaceListUpdated != null) {
|
if (onAuthChanged != null) {
|
||||||
_workspaceListNotifier.addListener(() {
|
_authNotifier?.addPublishListener(onAuthChanged);
|
||||||
onWorkspaceListUpdated(_workspaceListNotifier.currentValue!);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (onWorkspaceSettingUpdated != null) {
|
_userParser = UserNotificationParser(id: _userProfile.token, callback: _userNotificationCallback);
|
||||||
_workSettingNotifier.addListener(() {
|
|
||||||
onWorkspaceSettingUpdated(_workSettingNotifier.currentValue!);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
_workspaceParser = FolderNotificationParser(id: _user.token, callback: _notificationCallback);
|
|
||||||
_userParser = UserNotificationParser(id: _user.token, callback: _userNotificationCallback);
|
|
||||||
_subscription = RustStreamReceiver.listen((observable) {
|
_subscription = RustStreamReceiver.listen((observable) {
|
||||||
_workspaceParser?.parse(observable);
|
|
||||||
_userParser?.parse(observable);
|
_userParser?.parse(observable);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> stop() async {
|
Future<void> stop() async {
|
||||||
_workspaceParser = null;
|
|
||||||
_userParser = null;
|
_userParser = null;
|
||||||
await _subscription?.cancel();
|
await _subscription?.cancel();
|
||||||
_profileNotifier.dispose();
|
_profileNotifier?.dispose();
|
||||||
_authNotifier.dispose();
|
_profileNotifier = null;
|
||||||
_workspaceListNotifier.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
void _notificationCallback(FolderNotification ty, Either<Uint8List, FlowyError> result) {
|
_authNotifier?.dispose();
|
||||||
switch (ty) {
|
_authNotifier = null;
|
||||||
case FolderNotification.UserCreateWorkspace:
|
|
||||||
case FolderNotification.UserDeleteWorkspace:
|
|
||||||
case FolderNotification.WorkspaceListUpdated:
|
|
||||||
result.fold(
|
|
||||||
(payload) => _workspaceListNotifier.value = left(RepeatedWorkspace.fromBuffer(payload).items),
|
|
||||||
(error) => _workspaceListNotifier.value = right(error),
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
case FolderNotification.WorkspaceSetting:
|
|
||||||
result.fold(
|
|
||||||
(payload) => _workSettingNotifier.value = left(CurrentWorkspaceSetting.fromBuffer(payload)),
|
|
||||||
(error) => _workSettingNotifier.value = right(error),
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
case FolderNotification.UserUnauthorized:
|
|
||||||
result.fold(
|
|
||||||
(_) {},
|
|
||||||
(error) => _authNotifier.value = right(FlowyError.create()..code = ErrorCode.UserUnauthorized.value),
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void _userNotificationCallback(user.UserNotification ty, Either<Uint8List, FlowyError> result) {
|
void _userNotificationCallback(user.UserNotification ty, Either<Uint8List, FlowyError> result) {
|
||||||
switch (ty) {
|
switch (ty) {
|
||||||
case user.UserNotification.UserUnauthorized:
|
case user.UserNotification.UserUnauthorized:
|
||||||
result.fold(
|
result.fold(
|
||||||
(payload) => _profileNotifier.value = left(UserProfile.fromBuffer(payload)),
|
(_) {},
|
||||||
(error) => _profileNotifier.value = right(error),
|
(error) => _authNotifier?.value = right(error),
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case user.UserNotification.UserProfileUpdated:
|
||||||
|
result.fold(
|
||||||
|
(payload) => _profileNotifier?.value = left(UserProfile.fromBuffer(payload)),
|
||||||
|
(error) => _profileNotifier?.value = right(error),
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -119,3 +74,81 @@ class UserListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typedef WorkspaceListNotifyValue = Either<List<Workspace>, FlowyError>;
|
||||||
|
typedef WorkspaceSettingNotifyValue = Either<CurrentWorkspaceSetting, FlowyError>;
|
||||||
|
|
||||||
|
class UserWorkspaceListener {
|
||||||
|
PublishNotifier<AuthNotifyValue>? _authNotifier = PublishNotifier();
|
||||||
|
PublishNotifier<WorkspaceListNotifyValue>? _workspacesChangedNotifier = PublishNotifier();
|
||||||
|
PublishNotifier<WorkspaceSettingNotifyValue>? _settingChangedNotifier = PublishNotifier();
|
||||||
|
|
||||||
|
FolderNotificationListener? _listener;
|
||||||
|
final UserProfile _userProfile;
|
||||||
|
|
||||||
|
UserWorkspaceListener({
|
||||||
|
required UserProfile userProfile,
|
||||||
|
}) : _userProfile = userProfile;
|
||||||
|
|
||||||
|
void start({
|
||||||
|
void Function(AuthNotifyValue)? onAuthChanged,
|
||||||
|
void Function(WorkspaceListNotifyValue)? onWorkspacesUpdated,
|
||||||
|
void Function(WorkspaceSettingNotifyValue)? onSettingUpdated,
|
||||||
|
}) {
|
||||||
|
if (onAuthChanged != null) {
|
||||||
|
_authNotifier?.addPublishListener(onAuthChanged);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (onWorkspacesUpdated != null) {
|
||||||
|
_workspacesChangedNotifier?.addPublishListener(onWorkspacesUpdated);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (onSettingUpdated != null) {
|
||||||
|
_settingChangedNotifier?.addPublishListener(onSettingUpdated);
|
||||||
|
}
|
||||||
|
|
||||||
|
_listener = FolderNotificationListener(
|
||||||
|
objectId: _userProfile.token,
|
||||||
|
handler: _handleObservableType,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _handleObservableType(FolderNotification ty, Either<Uint8List, FlowyError> result) {
|
||||||
|
switch (ty) {
|
||||||
|
case FolderNotification.UserCreateWorkspace:
|
||||||
|
case FolderNotification.UserDeleteWorkspace:
|
||||||
|
case FolderNotification.WorkspaceListUpdated:
|
||||||
|
result.fold(
|
||||||
|
(payload) => _workspacesChangedNotifier?.value = left(RepeatedWorkspace.fromBuffer(payload).items),
|
||||||
|
(error) => _workspacesChangedNotifier?.value = right(error),
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case FolderNotification.WorkspaceSetting:
|
||||||
|
result.fold(
|
||||||
|
(payload) => _settingChangedNotifier?.value = left(CurrentWorkspaceSetting.fromBuffer(payload)),
|
||||||
|
(error) => _settingChangedNotifier?.value = right(error),
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case FolderNotification.UserUnauthorized:
|
||||||
|
result.fold(
|
||||||
|
(_) {},
|
||||||
|
(error) => _authNotifier?.value = right(FlowyError.create()..code = ErrorCode.UserUnauthorized.value),
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> stop() async {
|
||||||
|
await _listener?.stop();
|
||||||
|
_workspacesChangedNotifier?.dispose();
|
||||||
|
_workspacesChangedNotifier = null;
|
||||||
|
|
||||||
|
_settingChangedNotifier?.dispose();
|
||||||
|
_settingChangedNotifier = null;
|
||||||
|
|
||||||
|
_authNotifier?.dispose();
|
||||||
|
_authNotifier = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -3,7 +3,7 @@ import 'dart:async';
|
|||||||
import 'package:dartz/dartz.dart';
|
import 'package:dartz/dartz.dart';
|
||||||
import 'package:flowy_sdk/dispatch/dispatch.dart';
|
import 'package:flowy_sdk/dispatch/dispatch.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-folder-data-model/workspace.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-folder/workspace.pb.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-user-data-model/user_profile.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-user-data-model/user_profile.pb.dart';
|
||||||
|
|
||||||
class UserService {
|
class UserService {
|
||||||
|
@ -8,7 +8,7 @@ import 'package:app_flowy/workspace/presentation/home/home_screen.dart';
|
|||||||
import 'package:flowy_infra/time/duration.dart';
|
import 'package:flowy_infra/time/duration.dart';
|
||||||
import 'package:flowy_infra_ui/widget/route/animation.dart';
|
import 'package:flowy_infra_ui/widget/route/animation.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-user-data-model/protobuf.dart' show UserProfile;
|
import 'package:flowy_sdk/protobuf/flowy-user-data-model/protobuf.dart' show UserProfile;
|
||||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/protobuf.dart';
|
import 'package:flowy_sdk/protobuf/flowy-folder/protobuf.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class AuthRouter {
|
class AuthRouter {
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import 'package:app_flowy/user/application/auth_service.dart';
|
import 'package:app_flowy/user/application/auth_service.dart';
|
||||||
import 'package:app_flowy/user/application/user_listener.dart';
|
|
||||||
import 'package:app_flowy/user/presentation/router.dart';
|
import 'package:app_flowy/user/presentation/router.dart';
|
||||||
import 'package:app_flowy/user/presentation/widgets/background.dart';
|
import 'package:app_flowy/user/presentation/widgets/background.dart';
|
||||||
import 'package:easy_localization/easy_localization.dart';
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
@ -10,7 +9,7 @@ import 'package:flowy_infra_ui/widget/rounded_button.dart';
|
|||||||
import 'package:flowy_infra_ui/widget/spacing.dart';
|
import 'package:flowy_infra_ui/widget/spacing.dart';
|
||||||
import 'package:flowy_sdk/log.dart';
|
import 'package:flowy_sdk/log.dart';
|
||||||
import 'package:flowy_sdk/dispatch/dispatch.dart';
|
import 'package:flowy_sdk/dispatch/dispatch.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/protobuf.dart';
|
import 'package:flowy_sdk/protobuf/flowy-folder/protobuf.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-user-data-model/user_profile.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-user-data-model/user_profile.pb.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
@ -34,8 +33,6 @@ class SkipLogInScreen extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _SkipLogInScreenState extends State<SkipLogInScreen> {
|
class _SkipLogInScreenState extends State<SkipLogInScreen> {
|
||||||
UserListener? userListener;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
|
@ -5,7 +5,7 @@ import 'package:flowy_infra/theme.dart';
|
|||||||
import 'package:flowy_infra_ui/style_widget/scrolling/styled_list.dart';
|
import 'package:flowy_infra_ui/style_widget/scrolling/styled_list.dart';
|
||||||
import 'package:flowy_infra_ui/style_widget/button.dart';
|
import 'package:flowy_infra_ui/style_widget/button.dart';
|
||||||
import 'package:flowy_infra_ui/widget/error_page.dart';
|
import 'package:flowy_infra_ui/widget/error_page.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/workspace.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-folder/workspace.pb.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-user-data-model/user_profile.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-user-data-model/user_profile.pb.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
@ -7,8 +7,8 @@ import 'package:app_flowy/workspace/application/app/app_service.dart';
|
|||||||
import 'package:app_flowy/workspace/presentation/home/menu/menu.dart';
|
import 'package:app_flowy/workspace/presentation/home/menu/menu.dart';
|
||||||
import 'package:expandable/expandable.dart';
|
import 'package:expandable/expandable.dart';
|
||||||
import 'package:flowy_sdk/log.dart';
|
import 'package:flowy_sdk/log.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/app.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-folder/app.pb.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/view.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
|
import 'package:app_flowy/core/folder_notification.dart';
|
||||||
import 'package:dartz/dartz.dart';
|
import 'package:dartz/dartz.dart';
|
||||||
import 'package:app_flowy/core/notification_helper.dart';
|
|
||||||
import 'package:flowy_sdk/log.dart';
|
import 'package:flowy_sdk/log.dart';
|
||||||
import 'package:flowy_sdk/protobuf/dart-notify/subject.pb.dart';
|
import 'package:flowy_sdk/protobuf/dart-notify/subject.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-folder-data-model/app.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-folder/app.pb.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/view.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-folder/dart_notification.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-folder/dart_notification.pb.dart';
|
||||||
import 'package:flowy_sdk/rust_stream.dart';
|
import 'package:flowy_sdk/rust_stream.dart';
|
||||||
|
|
||||||
|
@ -3,8 +3,8 @@ import 'dart:async';
|
|||||||
import 'package:dartz/dartz.dart';
|
import 'package:dartz/dartz.dart';
|
||||||
import 'package:flowy_sdk/dispatch/dispatch.dart';
|
import 'package:flowy_sdk/dispatch/dispatch.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-folder-data-model/app.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-folder/app.pb.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/view.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart';
|
||||||
|
|
||||||
import 'package:app_flowy/plugin/plugin.dart';
|
import 'package:app_flowy/plugin/plugin.dart';
|
||||||
|
|
||||||
|
@ -2,9 +2,9 @@ import 'dart:convert';
|
|||||||
import 'package:app_flowy/workspace/application/doc/doc_service.dart';
|
import 'package:app_flowy/workspace/application/doc/doc_service.dart';
|
||||||
import 'package:app_flowy/workspace/application/trash/trash_service.dart';
|
import 'package:app_flowy/workspace/application/trash/trash_service.dart';
|
||||||
import 'package:app_flowy/workspace/application/view/view_listener.dart';
|
import 'package:app_flowy/workspace/application/view/view_listener.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/trash.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-folder/trash.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-folder-data-model/view.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart';
|
||||||
import 'package:flutter_quill/flutter_quill.dart' show Document, Delta;
|
import 'package:flutter_quill/flutter_quill.dart' show Document, Delta;
|
||||||
import 'package:flowy_sdk/log.dart';
|
import 'package:flowy_sdk/log.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import 'package:dartz/dartz.dart';
|
import 'package:dartz/dartz.dart';
|
||||||
import 'package:flowy_sdk/dispatch/dispatch.dart';
|
import 'package:flowy_sdk/dispatch/dispatch.dart';
|
||||||
|
|
||||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/view.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-folder/view.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-sync/text_block.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-sync/text_block.pb.dart';
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ import 'package:app_flowy/startup/tasks/rust_sdk.dart';
|
|||||||
import 'package:app_flowy/workspace/application/doc/share_service.dart';
|
import 'package:app_flowy/workspace/application/doc/share_service.dart';
|
||||||
import 'package:app_flowy/workspace/application/markdown/delta_markdown.dart';
|
import 'package:app_flowy/workspace/application/markdown/delta_markdown.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-text-block/entities.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-text-block/entities.pb.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/view.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
|
||||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
|
import 'package:app_flowy/core/grid_notification.dart';
|
||||||
import 'package:app_flowy/core/notification_helper.dart';
|
|
||||||
import 'package:dartz/dartz.dart';
|
import 'package:dartz/dartz.dart';
|
||||||
import 'package:flowy_infra/notifier.dart';
|
import 'package:flowy_infra/notifier.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
|
import 'package:app_flowy/core/grid_notification.dart';
|
||||||
import 'package:dartz/dartz.dart';
|
import 'package:dartz/dartz.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-grid/dart_notification.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-grid/dart_notification.pb.dart';
|
||||||
import 'package:flowy_infra/notifier.dart';
|
import 'package:flowy_infra/notifier.dart';
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
import 'package:app_flowy/core/notification_helper.dart';
|
|
||||||
|
|
||||||
typedef UpdateFieldNotifiedValue = Either<Unit, FlowyError>;
|
typedef UpdateFieldNotifiedValue = Either<Unit, FlowyError>;
|
||||||
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
|
import 'package:app_flowy/core/grid_notification.dart';
|
||||||
import 'package:dartz/dartz.dart';
|
import 'package:dartz/dartz.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-grid/dart_notification.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-grid/dart_notification.pb.dart';
|
||||||
import 'package:flowy_infra/notifier.dart';
|
import 'package:flowy_infra/notifier.dart';
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
import 'package:app_flowy/core/notification_helper.dart';
|
|
||||||
import 'package:flowy_sdk/protobuf/flowy-grid/field_entities.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-grid/field_entities.pb.dart';
|
||||||
|
|
||||||
typedef UpdateFieldNotifiedValue = Either<Field, FlowyError>;
|
typedef UpdateFieldNotifiedValue = Either<Field, FlowyError>;
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
|
import 'package:app_flowy/core/grid_notification.dart';
|
||||||
import 'package:dartz/dartz.dart';
|
import 'package:dartz/dartz.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-grid/dart_notification.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-grid/dart_notification.pb.dart';
|
||||||
import 'package:flowy_infra/notifier.dart';
|
import 'package:flowy_infra/notifier.dart';
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
import 'package:app_flowy/core/notification_helper.dart';
|
|
||||||
import 'package:flowy_sdk/protobuf/flowy-grid/field_entities.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-grid/field_entities.pb.dart';
|
||||||
|
|
||||||
typedef UpdateFieldNotifiedValue = Either<GridFieldChangeset, FlowyError>;
|
typedef UpdateFieldNotifiedValue = Either<GridFieldChangeset, FlowyError>;
|
||||||
|
@ -3,7 +3,7 @@ import 'package:dartz/dartz.dart';
|
|||||||
import 'package:equatable/equatable.dart';
|
import 'package:equatable/equatable.dart';
|
||||||
import 'package:flowy_sdk/log.dart';
|
import 'package:flowy_sdk/log.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-folder-data-model/view.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-grid/protobuf.dart';
|
import 'package:flowy_sdk/protobuf/flowy-grid/protobuf.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||||
|
@ -5,7 +5,7 @@ import 'package:dartz/dartz.dart';
|
|||||||
import 'package:flowy_sdk/dispatch/dispatch.dart';
|
import 'package:flowy_sdk/dispatch/dispatch.dart';
|
||||||
import 'package:flowy_sdk/log.dart';
|
import 'package:flowy_sdk/log.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-folder-data-model/view.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-grid/block_entities.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-grid/block_entities.pb.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-grid/field_entities.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-grid/field_entities.pb.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-grid/grid_entities.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-grid/grid_entities.pb.dart';
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
|
import 'package:app_flowy/core/grid_notification.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-grid/block_entities.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-grid/block_entities.pb.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-grid/dart_notification.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-grid/dart_notification.pb.dart';
|
||||||
import 'package:flowy_infra/notifier.dart';
|
import 'package:flowy_infra/notifier.dart';
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
import 'package:app_flowy/core/notification_helper.dart';
|
|
||||||
import 'package:dartz/dartz.dart';
|
import 'package:dartz/dartz.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-grid/field_entities.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-grid/field_entities.pb.dart';
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ import 'package:app_flowy/workspace/application/edit_pannel/edit_context.dart';
|
|||||||
import 'package:flowy_sdk/log.dart';
|
import 'package:flowy_sdk/log.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-error-code/code.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-error-code/code.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-folder-data-model/workspace.pb.dart' show CurrentWorkspaceSetting;
|
import 'package:flowy_sdk/protobuf/flowy-folder/workspace.pb.dart' show CurrentWorkspaceSetting;
|
||||||
import 'package:flowy_sdk/protobuf/flowy-user-data-model/user_profile.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-user-data-model/user_profile.pb.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||||
@ -11,19 +11,17 @@ import 'package:dartz/dartz.dart';
|
|||||||
part 'home_bloc.freezed.dart';
|
part 'home_bloc.freezed.dart';
|
||||||
|
|
||||||
class HomeBloc extends Bloc<HomeEvent, HomeState> {
|
class HomeBloc extends Bloc<HomeEvent, HomeState> {
|
||||||
final UserListener _listener;
|
final UserWorkspaceListener _listener;
|
||||||
|
|
||||||
HomeBloc(UserProfile user, CurrentWorkspaceSetting workspaceSetting)
|
HomeBloc(UserProfile user, CurrentWorkspaceSetting workspaceSetting)
|
||||||
: _listener = UserListener(user: user),
|
: _listener = UserWorkspaceListener(userProfile: user),
|
||||||
super(HomeState.initial(workspaceSetting)) {
|
super(HomeState.initial(workspaceSetting)) {
|
||||||
on<HomeEvent>((event, emit) async {
|
on<HomeEvent>((event, emit) async {
|
||||||
await event.map(
|
await event.map(
|
||||||
initial: (_Initial value) {
|
initial: (_Initial value) {
|
||||||
_listener.start(
|
_listener.start(
|
||||||
onAuthChanged: (result) {
|
onAuthChanged: (result) => _authDidChanged(result),
|
||||||
_authDidChanged(result);
|
onSettingUpdated: (result) {
|
||||||
},
|
|
||||||
onWorkspaceSettingUpdated: (result) {
|
|
||||||
result.fold(
|
result.fold(
|
||||||
(setting) => add(HomeEvent.didReceiveWorkspaceSetting(setting)),
|
(setting) => add(HomeEvent.didReceiveWorkspaceSetting(setting)),
|
||||||
(r) => Log.error(r),
|
(r) => Log.error(r),
|
||||||
|
@ -4,7 +4,7 @@ import 'package:app_flowy/workspace/application/workspace/workspace_listener.dar
|
|||||||
import 'package:app_flowy/workspace/application/workspace/workspace_service.dart';
|
import 'package:app_flowy/workspace/application/workspace/workspace_service.dart';
|
||||||
import 'package:dartz/dartz.dart';
|
import 'package:dartz/dartz.dart';
|
||||||
import 'package:flowy_sdk/log.dart';
|
import 'package:flowy_sdk/log.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/app.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-folder/app.pb.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
|
||||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
@ -22,7 +22,7 @@ class MenuBloc extends Bloc<MenuEvent, MenuState> {
|
|||||||
on<MenuEvent>((event, emit) async {
|
on<MenuEvent>((event, emit) async {
|
||||||
await event.map(
|
await event.map(
|
||||||
initial: (e) async {
|
initial: (e) async {
|
||||||
listener.start(addAppCallback: _handleAppsOrFail);
|
listener.start(appsChanged: _handleAppsOrFail);
|
||||||
await _fetchApps(emit);
|
await _fetchApps(emit);
|
||||||
},
|
},
|
||||||
openPage: (e) async {
|
openPage: (e) async {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import 'package:app_flowy/user/application/user_listener.dart';
|
import 'package:app_flowy/user/application/user_listener.dart';
|
||||||
import 'package:app_flowy/user/application/user_service.dart';
|
import 'package:app_flowy/user/application/user_service.dart';
|
||||||
import 'package:flowy_sdk/log.dart';
|
import 'package:flowy_sdk/log.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/workspace.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-folder/workspace.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-user-data-model/user_profile.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-user-data-model/user_profile.pb.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
@ -12,29 +12,44 @@ part 'menu_user_bloc.freezed.dart';
|
|||||||
|
|
||||||
class MenuUserBloc extends Bloc<MenuUserEvent, MenuUserState> {
|
class MenuUserBloc extends Bloc<MenuUserEvent, MenuUserState> {
|
||||||
final UserService _userService;
|
final UserService _userService;
|
||||||
final UserListener userListener;
|
final UserListener _userListener;
|
||||||
|
final UserWorkspaceListener _userWorkspaceListener;
|
||||||
final UserProfile userProfile;
|
final UserProfile userProfile;
|
||||||
|
|
||||||
MenuUserBloc(this.userProfile, this.userListener)
|
MenuUserBloc(this.userProfile)
|
||||||
: _userService = UserService(userId: userProfile.id),
|
: _userListener = UserListener(userProfile: userProfile),
|
||||||
|
_userWorkspaceListener = UserWorkspaceListener(userProfile: userProfile),
|
||||||
|
_userService = UserService(userId: userProfile.id),
|
||||||
super(MenuUserState.initial(userProfile)) {
|
super(MenuUserState.initial(userProfile)) {
|
||||||
on<MenuUserEvent>((event, emit) async {
|
on<MenuUserEvent>((event, emit) async {
|
||||||
await event.map(
|
await event.when(
|
||||||
initial: (_) async {
|
initial: () async {
|
||||||
userListener.start(
|
_userListener.start(onProfileUpdated: _profileUpdated);
|
||||||
onProfileUpdated: _profileUpdated,
|
_userWorkspaceListener.start(onWorkspacesUpdated: _workspaceListUpdated);
|
||||||
onWorkspaceListUpdated: _workspaceListUpdated,
|
|
||||||
);
|
|
||||||
await _initUser();
|
await _initUser();
|
||||||
},
|
},
|
||||||
fetchWorkspaces: (_FetchWorkspaces value) async {},
|
fetchWorkspaces: () async {
|
||||||
|
//
|
||||||
|
},
|
||||||
|
didReceiveUserProfile: (UserProfile newUserProfile) {
|
||||||
|
emit(state.copyWith(userProfile: newUserProfile));
|
||||||
|
},
|
||||||
|
updateUserName: (String name) {
|
||||||
|
_userService.updateUserProfile(name: name).then((result) {
|
||||||
|
result.fold(
|
||||||
|
(l) => null,
|
||||||
|
(err) => Log.error(err),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
},
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> close() async {
|
Future<void> close() async {
|
||||||
await userListener.stop();
|
await _userListener.stop();
|
||||||
|
await _userWorkspaceListener.stop();
|
||||||
super.close();
|
super.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,19 +58,15 @@ class MenuUserBloc extends Bloc<MenuUserEvent, MenuUserState> {
|
|||||||
result.fold((l) => null, (error) => Log.error(error));
|
result.fold((l) => null, (error) => Log.error(error));
|
||||||
}
|
}
|
||||||
|
|
||||||
void _profileUpdated(Either<UserProfile, FlowyError> userOrFailed) {}
|
void _profileUpdated(Either<UserProfile, FlowyError> userProfileOrFailed) {
|
||||||
|
userProfileOrFailed.fold(
|
||||||
|
(newUserProfile) => add(MenuUserEvent.didReceiveUserProfile(newUserProfile)),
|
||||||
|
(err) => Log.error(err),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
void _workspaceListUpdated(Either<List<Workspace>, FlowyError> workspacesOrFailed) {
|
void _workspaceListUpdated(Either<List<Workspace>, FlowyError> workspacesOrFailed) {
|
||||||
// fetch workspaces
|
// Do nothing by now
|
||||||
// iUserImpl.fetchWorkspaces().then((result) {
|
|
||||||
// result.fold(
|
|
||||||
// (workspaces) async* {
|
|
||||||
// yield state.copyWith(workspaces: some(workspaces));
|
|
||||||
// },
|
|
||||||
// (error) async* {
|
|
||||||
// yield state.copyWith(successOrFailure: right(error.msg));
|
|
||||||
// },
|
|
||||||
// );
|
|
||||||
// });
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,18 +74,20 @@ class MenuUserBloc extends Bloc<MenuUserEvent, MenuUserState> {
|
|||||||
class MenuUserEvent with _$MenuUserEvent {
|
class MenuUserEvent with _$MenuUserEvent {
|
||||||
const factory MenuUserEvent.initial() = _Initial;
|
const factory MenuUserEvent.initial() = _Initial;
|
||||||
const factory MenuUserEvent.fetchWorkspaces() = _FetchWorkspaces;
|
const factory MenuUserEvent.fetchWorkspaces() = _FetchWorkspaces;
|
||||||
|
const factory MenuUserEvent.updateUserName(String name) = _UpdateUserName;
|
||||||
|
const factory MenuUserEvent.didReceiveUserProfile(UserProfile newUserProfile) = _DidReceiveUserProfile;
|
||||||
}
|
}
|
||||||
|
|
||||||
@freezed
|
@freezed
|
||||||
class MenuUserState with _$MenuUserState {
|
class MenuUserState with _$MenuUserState {
|
||||||
const factory MenuUserState({
|
const factory MenuUserState({
|
||||||
required UserProfile user,
|
required UserProfile userProfile,
|
||||||
required Option<List<Workspace>> workspaces,
|
required Option<List<Workspace>> workspaces,
|
||||||
required Either<Unit, String> successOrFailure,
|
required Either<Unit, String> successOrFailure,
|
||||||
}) = _MenuUserState;
|
}) = _MenuUserState;
|
||||||
|
|
||||||
factory MenuUserState.initial(UserProfile user) => MenuUserState(
|
factory MenuUserState.initial(UserProfile userProfile) => MenuUserState(
|
||||||
user: user,
|
userProfile: userProfile,
|
||||||
workspaces: none(),
|
workspaces: none(),
|
||||||
successOrFailure: left(unit),
|
successOrFailure: left(unit),
|
||||||
);
|
);
|
||||||
|
@ -3,7 +3,7 @@ import 'dart:async';
|
|||||||
import 'package:app_flowy/workspace/application/app/app_bloc.dart';
|
import 'package:app_flowy/workspace/application/app/app_bloc.dart';
|
||||||
import 'package:app_flowy/workspace/application/app/app_service.dart';
|
import 'package:app_flowy/workspace/application/app/app_service.dart';
|
||||||
import 'package:flowy_sdk/log.dart';
|
import 'package:flowy_sdk/log.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/view.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart';
|
||||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import 'package:dartz/dartz.dart';
|
import 'package:dartz/dartz.dart';
|
||||||
import 'package:flowy_sdk/log.dart';
|
import 'package:flowy_sdk/log.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/trash.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-folder/trash.pb.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
|
import 'package:app_flowy/core/folder_notification.dart';
|
||||||
import 'package:dartz/dartz.dart';
|
import 'package:dartz/dartz.dart';
|
||||||
import 'package:app_flowy/core/notification_helper.dart';
|
|
||||||
import 'package:flowy_sdk/protobuf/dart-notify/subject.pb.dart';
|
import 'package:flowy_sdk/protobuf/dart-notify/subject.pb.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-folder/dart_notification.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-folder/dart_notification.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-folder-data-model/trash.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-folder/trash.pb.dart';
|
||||||
import 'package:flowy_sdk/rust_stream.dart';
|
import 'package:flowy_sdk/rust_stream.dart';
|
||||||
|
|
||||||
typedef TrashUpdatedCallback = void Function(Either<List<Trash>, FlowyError> trashOrFailed);
|
typedef TrashUpdatedCallback = void Function(Either<List<Trash>, FlowyError> trashOrFailed);
|
||||||
|
@ -2,7 +2,7 @@ import 'dart:async';
|
|||||||
import 'package:dartz/dartz.dart';
|
import 'package:dartz/dartz.dart';
|
||||||
import 'package:flowy_sdk/dispatch/dispatch.dart';
|
import 'package:flowy_sdk/dispatch/dispatch.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-folder-data-model/trash.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-folder/trash.pb.dart';
|
||||||
|
|
||||||
class TrashService {
|
class TrashService {
|
||||||
Future<Either<RepeatedTrash, FlowyError>> readTrash() {
|
Future<Either<RepeatedTrash, FlowyError>> readTrash() {
|
||||||
@ -34,4 +34,3 @@ class TrashService {
|
|||||||
return FolderEventDeleteAllTrash().send();
|
return FolderEventDeleteAllTrash().send();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import 'package:app_flowy/workspace/application/view/view_listener.dart';
|
import 'package:app_flowy/workspace/application/view/view_listener.dart';
|
||||||
import 'package:app_flowy/workspace/application/view/view_service.dart';
|
import 'package:app_flowy/workspace/application/view/view_service.dart';
|
||||||
import 'package:dartz/dartz.dart';
|
import 'package:dartz/dartz.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/view.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import 'package:app_flowy/plugin/plugin.dart';
|
import 'package:app_flowy/plugin/plugin.dart';
|
||||||
import 'package:flowy_infra/image.dart';
|
import 'package:flowy_infra/image.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/view.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
enum FlowyPlugin {
|
enum FlowyPlugin {
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
import 'package:app_flowy/core/notification_helper.dart';
|
import 'package:app_flowy/core/folder_notification.dart';
|
||||||
import 'package:dartz/dartz.dart';
|
import 'package:dartz/dartz.dart';
|
||||||
import 'package:flowy_sdk/protobuf/dart-notify/subject.pb.dart';
|
import 'package:flowy_sdk/protobuf/dart-notify/subject.pb.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/view.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-folder/view.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-folder/dart_notification.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-folder/dart_notification.pb.dart';
|
||||||
import 'package:flowy_sdk/rust_stream.dart';
|
import 'package:flowy_sdk/rust_stream.dart';
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'package:dartz/dartz.dart';
|
import 'package:dartz/dartz.dart';
|
||||||
import 'package:flowy_sdk/dispatch/dispatch.dart';
|
import 'package:flowy_sdk/dispatch/dispatch.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/view.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
|
||||||
|
|
||||||
class ViewService {
|
class ViewService {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import 'package:app_flowy/user/application/user_listener.dart';
|
import 'package:app_flowy/user/application/user_listener.dart';
|
||||||
import 'package:app_flowy/user/application/user_service.dart';
|
import 'package:app_flowy/user/application/user_service.dart';
|
||||||
import 'package:flowy_sdk/log.dart';
|
import 'package:flowy_sdk/log.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/workspace.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-folder/workspace.pb.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
|
||||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
@ -11,13 +11,13 @@ part 'welcome_bloc.freezed.dart';
|
|||||||
|
|
||||||
class WelcomeBloc extends Bloc<WelcomeEvent, WelcomeState> {
|
class WelcomeBloc extends Bloc<WelcomeEvent, WelcomeState> {
|
||||||
final UserService userService;
|
final UserService userService;
|
||||||
final UserListener userListener;
|
final UserWorkspaceListener userWorkspaceListener;
|
||||||
WelcomeBloc({required this.userService, required this.userListener}) : super(WelcomeState.initial()) {
|
WelcomeBloc({required this.userService, required this.userWorkspaceListener}) : super(WelcomeState.initial()) {
|
||||||
on<WelcomeEvent>(
|
on<WelcomeEvent>(
|
||||||
(event, emit) async {
|
(event, emit) async {
|
||||||
await event.map(initial: (e) async {
|
await event.map(initial: (e) async {
|
||||||
userListener.start(
|
userWorkspaceListener.start(
|
||||||
onWorkspaceListUpdated: (result) => add(WelcomeEvent.workspacesReveived(result)),
|
onWorkspacesUpdated: (result) => add(WelcomeEvent.workspacesReveived(result)),
|
||||||
);
|
);
|
||||||
//
|
//
|
||||||
await _fetchWorkspaces(emit);
|
await _fetchWorkspaces(emit);
|
||||||
@ -37,7 +37,7 @@ class WelcomeBloc extends Bloc<WelcomeEvent, WelcomeState> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> close() async {
|
Future<void> close() async {
|
||||||
await userListener.stop();
|
await userWorkspaceListener.stop();
|
||||||
super.close();
|
super.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,97 +1,73 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
|
import 'package:app_flowy/core/folder_notification.dart';
|
||||||
import 'package:app_flowy/core/notification_helper.dart';
|
|
||||||
import 'package:dartz/dartz.dart';
|
import 'package:dartz/dartz.dart';
|
||||||
import 'package:flowy_sdk/log.dart';
|
import 'package:flowy_infra/notifier.dart';
|
||||||
import 'package:flowy_sdk/protobuf/dart-notify/subject.pb.dart';
|
|
||||||
import 'package:flowy_sdk/protobuf/flowy-user-data-model/protobuf.dart' show UserProfile;
|
import 'package:flowy_sdk/protobuf/flowy-user-data-model/protobuf.dart' show UserProfile;
|
||||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/app.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-folder/app.pb.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/workspace.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-folder/workspace.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-folder/dart_notification.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-folder/dart_notification.pb.dart';
|
||||||
import 'package:flowy_sdk/rust_stream.dart';
|
|
||||||
|
|
||||||
typedef WorkspaceAppsChangedCallback = void Function(Either<List<App>, FlowyError> appsOrFail);
|
typedef AppListNotifyValue = Either<List<App>, FlowyError>;
|
||||||
typedef WorkspaceUpdatedCallback = void Function(String name, String desc);
|
typedef WorkspaceNotifyValue = Either<Workspace, FlowyError>;
|
||||||
|
|
||||||
class WorkspaceListener {
|
class WorkspaceListener {
|
||||||
WorkspaceListenerService service;
|
PublishNotifier<AppListNotifyValue>? _appsChangedNotifier = PublishNotifier();
|
||||||
WorkspaceListener({
|
PublishNotifier<WorkspaceNotifyValue>? _workspaceUpdatedNotifier = PublishNotifier();
|
||||||
required this.service,
|
|
||||||
});
|
|
||||||
|
|
||||||
void start({WorkspaceAppsChangedCallback? addAppCallback, WorkspaceUpdatedCallback? updatedCallback}) {
|
FolderNotificationListener? _listener;
|
||||||
service.startListening(appsChanged: addAppCallback, update: updatedCallback);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> stop() async {
|
|
||||||
await service.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class WorkspaceListenerService {
|
|
||||||
StreamSubscription<SubscribeObject>? _subscription;
|
|
||||||
WorkspaceAppsChangedCallback? _appsChanged;
|
|
||||||
WorkspaceUpdatedCallback? _update;
|
|
||||||
FolderNotificationParser? _parser;
|
|
||||||
final UserProfile user;
|
final UserProfile user;
|
||||||
final String workspaceId;
|
final String workspaceId;
|
||||||
|
|
||||||
WorkspaceListenerService({
|
WorkspaceListener({
|
||||||
required this.user,
|
required this.user,
|
||||||
required this.workspaceId,
|
required this.workspaceId,
|
||||||
});
|
});
|
||||||
|
|
||||||
void startListening({
|
void start({
|
||||||
WorkspaceAppsChangedCallback? appsChanged,
|
void Function(AppListNotifyValue)? appsChanged,
|
||||||
WorkspaceUpdatedCallback? update,
|
void Function(WorkspaceNotifyValue)? onWorkspaceUpdated,
|
||||||
}) {
|
}) {
|
||||||
_appsChanged = appsChanged;
|
if (appsChanged != null) {
|
||||||
_update = update;
|
_appsChangedNotifier?.addPublishListener(appsChanged);
|
||||||
|
}
|
||||||
|
|
||||||
_parser = FolderNotificationParser(
|
if (onWorkspaceUpdated != null) {
|
||||||
id: workspaceId,
|
_workspaceUpdatedNotifier?.addPublishListener(onWorkspaceUpdated);
|
||||||
callback: (ty, result) {
|
}
|
||||||
_handleObservableType(ty, result);
|
|
||||||
},
|
_listener = FolderNotificationListener(
|
||||||
|
objectId: workspaceId,
|
||||||
|
handler: _handleObservableType,
|
||||||
);
|
);
|
||||||
|
|
||||||
_subscription = RustStreamReceiver.listen((observable) => _parser?.parse(observable));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void _handleObservableType(FolderNotification ty, Either<Uint8List, FlowyError> result) {
|
void _handleObservableType(FolderNotification ty, Either<Uint8List, FlowyError> result) {
|
||||||
switch (ty) {
|
switch (ty) {
|
||||||
case FolderNotification.WorkspaceUpdated:
|
case FolderNotification.WorkspaceUpdated:
|
||||||
if (_update != null) {
|
result.fold(
|
||||||
result.fold(
|
(payload) => _workspaceUpdatedNotifier?.value = left(Workspace.fromBuffer(payload)),
|
||||||
(payload) {
|
(error) => _workspaceUpdatedNotifier?.value = right(error),
|
||||||
final workspace = Workspace.fromBuffer(payload);
|
);
|
||||||
_update!(workspace.name, workspace.desc);
|
|
||||||
},
|
|
||||||
(error) => Log.error(error),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case FolderNotification.WorkspaceAppsChanged:
|
case FolderNotification.WorkspaceAppsChanged:
|
||||||
if (_appsChanged != null) {
|
result.fold(
|
||||||
result.fold(
|
(payload) => _appsChangedNotifier?.value = left(RepeatedApp.fromBuffer(payload).items),
|
||||||
(payload) => _appsChanged!(
|
(error) => _appsChangedNotifier?.value = right(error),
|
||||||
left(RepeatedApp.fromBuffer(payload).items),
|
);
|
||||||
),
|
|
||||||
(error) => _appsChanged!(right(error)),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> close() async {
|
Future<void> stop() async {
|
||||||
_parser = null;
|
await _listener?.stop();
|
||||||
await _subscription?.cancel();
|
_appsChangedNotifier?.dispose();
|
||||||
// _appsChanged = null;
|
_appsChangedNotifier = null;
|
||||||
// _update = null;
|
|
||||||
|
_workspaceUpdatedNotifier?.dispose();
|
||||||
|
_workspaceUpdatedNotifier = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,9 +4,9 @@ import 'package:dartz/dartz.dart';
|
|||||||
import 'package:easy_localization/easy_localization.dart';
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
import 'package:flowy_sdk/dispatch/dispatch.dart';
|
import 'package:flowy_sdk/dispatch/dispatch.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-folder-data-model/app.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-folder/app.pb.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/view.pb.dart' show MoveFolderItemPayload, MoveFolderItemType;
|
import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart' show MoveFolderItemPayload, MoveFolderItemType;
|
||||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/workspace.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-folder/workspace.pb.dart';
|
||||||
|
|
||||||
import 'package:app_flowy/generated/locale_keys.g.dart';
|
import 'package:app_flowy/generated/locale_keys.g.dart';
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ import 'package:app_flowy/startup/startup.dart';
|
|||||||
import 'package:flowy_sdk/log.dart';
|
import 'package:flowy_sdk/log.dart';
|
||||||
import 'package:flowy_infra_ui/style_widget/container.dart';
|
import 'package:flowy_infra_ui/style_widget/container.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-user-data-model/protobuf.dart' show UserProfile;
|
import 'package:flowy_sdk/protobuf/flowy-user-data-model/protobuf.dart' show UserProfile;
|
||||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/protobuf.dart';
|
import 'package:flowy_sdk/protobuf/flowy-folder/protobuf.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:styled_widget/styled_widget.dart';
|
import 'package:styled_widget/styled_widget.dart';
|
||||||
|
@ -83,6 +83,7 @@ class CreateItem extends StatelessWidget {
|
|||||||
return FlowyHover(
|
return FlowyHover(
|
||||||
style: config,
|
style: config,
|
||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
|
behavior: HitTestBehavior.opaque,
|
||||||
onTap: () => onSelected(pluginBuilder),
|
onTap: () => onSelected(pluginBuilder),
|
||||||
child: FlowyText.medium(
|
child: FlowyText.medium(
|
||||||
pluginBuilder.menuName,
|
pluginBuilder.menuName,
|
||||||
|
@ -5,7 +5,7 @@ import 'package:flowy_infra/icon_data.dart';
|
|||||||
import 'package:flowy_infra/theme.dart';
|
import 'package:flowy_infra/theme.dart';
|
||||||
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
|
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
|
||||||
import 'package:flowy_infra_ui/style_widget/text.dart';
|
import 'package:flowy_infra_ui/style_widget/text.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/app.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-folder/app.pb.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:app_flowy/workspace/application/app/app_bloc.dart';
|
import 'package:app_flowy/workspace/application/app/app_bloc.dart';
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import 'package:app_flowy/workspace/application/appearance.dart';
|
import 'package:app_flowy/workspace/application/appearance.dart';
|
||||||
import 'package:app_flowy/workspace/presentation/home/menu/menu.dart';
|
import 'package:app_flowy/workspace/presentation/home/menu/menu.dart';
|
||||||
import 'package:expandable/expandable.dart';
|
import 'package:expandable/expandable.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/app.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-folder/app.pb.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:app_flowy/startup/startup.dart';
|
import 'package:app_flowy/startup/startup.dart';
|
||||||
|
@ -9,7 +9,7 @@ import 'package:flowy_infra/theme.dart';
|
|||||||
import 'package:flowy_infra_ui/style_widget/hover.dart';
|
import 'package:flowy_infra_ui/style_widget/hover.dart';
|
||||||
import 'package:flowy_infra_ui/style_widget/text.dart';
|
import 'package:flowy_infra_ui/style_widget/text.dart';
|
||||||
import 'package:flowy_infra_ui/widget/spacing.dart';
|
import 'package:flowy_infra_ui/widget/spacing.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/view.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:styled_widget/styled_widget.dart';
|
import 'package:styled_widget/styled_widget.dart';
|
||||||
|
@ -11,8 +11,8 @@ import 'package:flowy_infra/theme.dart';
|
|||||||
import 'package:flowy_infra_ui/style_widget/scrolling/styled_list.dart';
|
import 'package:flowy_infra_ui/style_widget/scrolling/styled_list.dart';
|
||||||
import 'package:flowy_infra_ui/widget/spacing.dart';
|
import 'package:flowy_infra_ui/widget/spacing.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-user-data-model/protobuf.dart' show UserProfile;
|
import 'package:flowy_sdk/protobuf/flowy-user-data-model/protobuf.dart' show UserProfile;
|
||||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/view.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/workspace.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-folder/workspace.pb.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:styled_widget/styled_widget.dart';
|
import 'package:styled_widget/styled_widget.dart';
|
||||||
|
@ -58,9 +58,9 @@ class MenuUser extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _renderUserName(BuildContext context) {
|
Widget _renderUserName(BuildContext context) {
|
||||||
String name = context.read<MenuUserBloc>().state.user.name;
|
String name = context.read<MenuUserBloc>().state.userProfile.name;
|
||||||
if (name.isEmpty) {
|
if (name.isEmpty) {
|
||||||
name = context.read<MenuUserBloc>().state.user.email;
|
name = context.read<MenuUserBloc>().state.userProfile.email;
|
||||||
}
|
}
|
||||||
return FlowyText(name, fontSize: 12);
|
return FlowyText(name, fontSize: 12);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import 'package:app_flowy/workspace/presentation/home/home_stack.dart';
|
import 'package:app_flowy/workspace/presentation/home/home_stack.dart';
|
||||||
import 'package:app_flowy/workspace/presentation/plugins/widgets/left_bar_item.dart';
|
import 'package:app_flowy/workspace/presentation/plugins/widgets/left_bar_item.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/view.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart';
|
||||||
import 'package:app_flowy/plugin/plugin.dart';
|
import 'package:app_flowy/plugin/plugin.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// ignore_for_file: unused_field
|
// ignore_for_file: unused_field
|
||||||
|
|
||||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/view.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class BoardPage extends StatelessWidget {
|
class BoardPage extends StatelessWidget {
|
||||||
|
@ -20,7 +20,7 @@ import 'package:flowy_infra_ui/flowy_infra_ui.dart';
|
|||||||
import 'package:flowy_infra_ui/widget/rounded_button.dart';
|
import 'package:flowy_infra_ui/widget/rounded_button.dart';
|
||||||
import 'package:flowy_sdk/log.dart';
|
import 'package:flowy_sdk/log.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-folder-data-model/view.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-text-block/entities.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-text-block/entities.pb.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
@ -6,7 +6,7 @@ import 'package:flowy_infra_ui/style_widget/scrolling/styled_scroll_bar.dart';
|
|||||||
import 'package:flowy_infra_ui/widget/spacing.dart';
|
import 'package:flowy_infra_ui/widget/spacing.dart';
|
||||||
import 'package:flutter_quill/flutter_quill.dart' as quill;
|
import 'package:flutter_quill/flutter_quill.dart' as quill;
|
||||||
import 'package:flowy_infra_ui/widget/error_page.dart';
|
import 'package:flowy_infra_ui/widget/error_page.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/view.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
@ -3,7 +3,7 @@ import 'package:app_flowy/plugin/plugin.dart';
|
|||||||
import 'package:app_flowy/workspace/presentation/home/home_stack.dart';
|
import 'package:app_flowy/workspace/presentation/home/home_stack.dart';
|
||||||
import 'package:app_flowy/workspace/presentation/plugins/widgets/left_bar_item.dart';
|
import 'package:app_flowy/workspace/presentation/plugins/widgets/left_bar_item.dart';
|
||||||
import 'package:easy_localization/easy_localization.dart';
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/view.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'src/grid_page.dart';
|
import 'src/grid_page.dart';
|
||||||
|
@ -5,7 +5,7 @@ import 'package:flowy_infra_ui/style_widget/scrolling/styled_list.dart';
|
|||||||
import 'package:flowy_infra_ui/style_widget/scrolling/styled_scroll_bar.dart';
|
import 'package:flowy_infra_ui/style_widget/scrolling/styled_scroll_bar.dart';
|
||||||
import 'package:flowy_infra_ui/style_widget/scrolling/styled_scrollview.dart';
|
import 'package:flowy_infra_ui/style_widget/scrolling/styled_scrollview.dart';
|
||||||
import 'package:flowy_infra_ui/widget/error_page.dart';
|
import 'package:flowy_infra_ui/widget/error_page.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/view.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:linked_scroll_controller/linked_scroll_controller.dart';
|
import 'package:linked_scroll_controller/linked_scroll_controller.dart';
|
||||||
|
@ -3,7 +3,7 @@ import 'package:flowy_infra/theme.dart';
|
|||||||
import 'package:flowy_infra_ui/style_widget/icon_button.dart';
|
import 'package:flowy_infra_ui/style_widget/icon_button.dart';
|
||||||
import 'package:flowy_infra_ui/style_widget/text.dart';
|
import 'package:flowy_infra_ui/style_widget/text.dart';
|
||||||
import 'package:flowy_infra_ui/widget/spacing.dart';
|
import 'package:flowy_infra_ui/widget/spacing.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/trash.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-folder/trash.pb.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
import 'package:fixnum/fixnum.dart' as $fixnum;
|
import 'package:fixnum/fixnum.dart' as $fixnum;
|
||||||
|
@ -2,7 +2,7 @@ import 'package:app_flowy/workspace/application/view/view_listener.dart';
|
|||||||
import 'package:app_flowy/workspace/application/view/view_service.dart';
|
import 'package:app_flowy/workspace/application/view/view_service.dart';
|
||||||
import 'package:flowy_infra/theme.dart';
|
import 'package:flowy_infra/theme.dart';
|
||||||
import 'package:flowy_sdk/log.dart';
|
import 'package:flowy_sdk/log.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/view.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
|
||||||
|
@ -427,6 +427,7 @@
|
|||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
"@executable_path/../Frameworks",
|
"@executable_path/../Frameworks",
|
||||||
);
|
);
|
||||||
|
ONLY_ACTIVE_ARCH = YES;
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = com.appflowy.macos;
|
PRODUCT_BUNDLE_IDENTIFIER = com.appflowy.macos;
|
||||||
PRODUCT_NAME = AppFlowy;
|
PRODUCT_NAME = AppFlowy;
|
||||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||||
|
@ -6,7 +6,6 @@ import 'package:flowy_sdk/protobuf/dart-ffi/ffi_response.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-net/network_state.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-net/network_state.pb.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-user/event_map.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-user/event_map.pb.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-folder/event_map.pb.dart';
|
|
||||||
import 'package:isolates/isolates.dart';
|
import 'package:isolates/isolates.dart';
|
||||||
import 'package:isolates/ports.dart';
|
import 'package:isolates/ports.dart';
|
||||||
import 'package:ffi/ffi.dart';
|
import 'package:ffi/ffi.dart';
|
||||||
@ -17,7 +16,7 @@ import 'dart:typed_data';
|
|||||||
import 'package:flowy_sdk/ffi.dart' as ffi;
|
import 'package:flowy_sdk/ffi.dart' as ffi;
|
||||||
import 'package:flowy_sdk/protobuf/flowy-user-data-model/protobuf.dart';
|
import 'package:flowy_sdk/protobuf/flowy-user-data-model/protobuf.dart';
|
||||||
import 'package:flowy_sdk/protobuf/dart-ffi/protobuf.dart';
|
import 'package:flowy_sdk/protobuf/dart-ffi/protobuf.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/protobuf.dart';
|
import 'package:flowy_sdk/protobuf/flowy-folder/protobuf.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-text-block/protobuf.dart';
|
import 'package:flowy_sdk/protobuf/flowy-text-block/protobuf.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-grid/protobuf.dart';
|
import 'package:flowy_sdk/protobuf/flowy-grid/protobuf.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-sync/protobuf.dart';
|
import 'package:flowy_sdk/protobuf/flowy-sync/protobuf.dart';
|
||||||
|
1
frontend/rust-lib/Cargo.lock
generated
1
frontend/rust-lib/Cargo.lock
generated
@ -904,6 +904,7 @@ dependencies = [
|
|||||||
"strum_macros",
|
"strum_macros",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tracing",
|
"tracing",
|
||||||
|
"unicode-segmentation",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -34,6 +34,7 @@ serde = { version = "1.0", features = ["derive"] }
|
|||||||
tracing = { version = "0.1", features = ["log"] }
|
tracing = { version = "0.1", features = ["log"] }
|
||||||
bytes = { version = "1.0" }
|
bytes = { version = "1.0" }
|
||||||
|
|
||||||
|
unicode-segmentation = "1.8"
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
flowy-folder = { path = "../flowy-folder", features = ["flowy_unit_test"]}
|
flowy-folder = { path = "../flowy-folder", features = ["flowy_unit_test"]}
|
||||||
|
@ -1,20 +1,16 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
entities::view::RepeatedView,
|
entities::parser::{
|
||||||
errors::ErrorCode,
|
|
||||||
impl_def_and_def_mut,
|
|
||||||
parser::{
|
|
||||||
app::{AppColorStyle, AppIdentify, AppName},
|
app::{AppColorStyle, AppIdentify, AppName},
|
||||||
workspace::WorkspaceIdentify,
|
workspace::WorkspaceIdentify,
|
||||||
},
|
},
|
||||||
|
entities::view::RepeatedView,
|
||||||
|
errors::ErrorCode,
|
||||||
|
impl_def_and_def_mut,
|
||||||
};
|
};
|
||||||
use flowy_derive::ProtoBuf;
|
use flowy_derive::ProtoBuf;
|
||||||
use nanoid::nanoid;
|
use flowy_folder_data_model::revision::AppRevision;
|
||||||
|
|
||||||
use std::convert::TryInto;
|
use std::convert::TryInto;
|
||||||
|
|
||||||
pub fn gen_app_id() -> String {
|
|
||||||
nanoid!(10)
|
|
||||||
}
|
|
||||||
#[derive(Eq, PartialEq, ProtoBuf, Debug, Default, Clone)]
|
#[derive(Eq, PartialEq, ProtoBuf, Debug, Default, Clone)]
|
||||||
pub struct App {
|
pub struct App {
|
||||||
#[pb(index = 1)]
|
#[pb(index = 1)]
|
||||||
@ -42,6 +38,20 @@ pub struct App {
|
|||||||
pub create_time: i64,
|
pub create_time: i64,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl std::convert::From<AppRevision> for App {
|
||||||
|
fn from(app_serde: AppRevision) -> Self {
|
||||||
|
App {
|
||||||
|
id: app_serde.id,
|
||||||
|
workspace_id: app_serde.workspace_id,
|
||||||
|
name: app_serde.name,
|
||||||
|
desc: app_serde.desc,
|
||||||
|
belongings: app_serde.belongings.into(),
|
||||||
|
version: app_serde.version,
|
||||||
|
modified_time: app_serde.modified_time,
|
||||||
|
create_time: app_serde.create_time,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
#[derive(Eq, PartialEq, Debug, Default, ProtoBuf, Clone)]
|
#[derive(Eq, PartialEq, Debug, Default, ProtoBuf, Clone)]
|
||||||
pub struct RepeatedApp {
|
pub struct RepeatedApp {
|
||||||
#[pb(index = 1)]
|
#[pb(index = 1)]
|
||||||
@ -50,6 +60,12 @@ pub struct RepeatedApp {
|
|||||||
|
|
||||||
impl_def_and_def_mut!(RepeatedApp, App);
|
impl_def_and_def_mut!(RepeatedApp, App);
|
||||||
|
|
||||||
|
impl std::convert::From<Vec<AppRevision>> for RepeatedApp {
|
||||||
|
fn from(values: Vec<AppRevision>) -> Self {
|
||||||
|
let items = values.into_iter().map(|value| value.into()).collect::<Vec<App>>();
|
||||||
|
RepeatedApp { items }
|
||||||
|
}
|
||||||
|
}
|
||||||
#[derive(ProtoBuf, Default)]
|
#[derive(ProtoBuf, Default)]
|
||||||
pub struct CreateAppPayload {
|
pub struct CreateAppPayload {
|
||||||
#[pb(index = 1)]
|
#[pb(index = 1)]
|
@ -1,4 +1,5 @@
|
|||||||
pub mod app;
|
pub mod app;
|
||||||
|
mod parser;
|
||||||
pub mod trash;
|
pub mod trash;
|
||||||
pub mod view;
|
pub mod view;
|
||||||
mod view_info;
|
mod view_info;
|
@ -3,6 +3,7 @@ use unicode_segmentation::UnicodeSegmentation;
|
|||||||
pub struct AppDesc(pub String);
|
pub struct AppDesc(pub String);
|
||||||
|
|
||||||
impl AppDesc {
|
impl AppDesc {
|
||||||
|
#[allow(dead_code)]
|
||||||
pub fn parse(s: String) -> Result<AppDesc, String> {
|
pub fn parse(s: String) -> Result<AppDesc, String> {
|
||||||
if s.graphemes(true).count() > 1024 {
|
if s.graphemes(true).count() > 1024 {
|
||||||
return Err("Workspace description too long".to_string());
|
return Err("Workspace description too long".to_string());
|
@ -2,6 +2,7 @@
|
|||||||
pub struct TrashIdentify(pub String);
|
pub struct TrashIdentify(pub String);
|
||||||
|
|
||||||
impl TrashIdentify {
|
impl TrashIdentify {
|
||||||
|
#[allow(dead_code)]
|
||||||
pub fn parse(s: String) -> Result<TrashIdentify, String> {
|
pub fn parse(s: String) -> Result<TrashIdentify, String> {
|
||||||
if s.trim().is_empty() {
|
if s.trim().is_empty() {
|
||||||
return Err("Trash id can not be empty or whitespace".to_string());
|
return Err("Trash id can not be empty or whitespace".to_string());
|
||||||
@ -21,6 +22,7 @@ impl AsRef<str> for TrashIdentify {
|
|||||||
pub struct TrashIds(pub Vec<String>);
|
pub struct TrashIds(pub Vec<String>);
|
||||||
|
|
||||||
impl TrashIds {
|
impl TrashIds {
|
||||||
|
#[allow(dead_code)]
|
||||||
pub fn parse(ids: Vec<String>) -> Result<TrashIds, String> {
|
pub fn parse(ids: Vec<String>) -> Result<TrashIds, String> {
|
||||||
let mut trash_ids = vec![];
|
let mut trash_ids = vec![];
|
||||||
for id in ids {
|
for id in ids {
|
@ -1,13 +1,9 @@
|
|||||||
mod delta_data;
|
|
||||||
mod view_desc;
|
mod view_desc;
|
||||||
mod view_ext;
|
|
||||||
mod view_id;
|
mod view_id;
|
||||||
mod view_name;
|
mod view_name;
|
||||||
mod view_thumbnail;
|
mod view_thumbnail;
|
||||||
|
|
||||||
pub use delta_data::*;
|
|
||||||
pub use view_desc::*;
|
pub use view_desc::*;
|
||||||
pub use view_ext::*;
|
|
||||||
pub use view_id::*;
|
pub use view_id::*;
|
||||||
pub use view_name::*;
|
pub use view_name::*;
|
||||||
pub use view_thumbnail::*;
|
pub use view_thumbnail::*;
|
@ -1,6 +1,6 @@
|
|||||||
use crate::impl_def_and_def_mut;
|
use crate::impl_def_and_def_mut;
|
||||||
use crate::revision::TrashRevision;
|
|
||||||
use flowy_derive::{ProtoBuf, ProtoBuf_Enum};
|
use flowy_derive::{ProtoBuf, ProtoBuf_Enum};
|
||||||
|
use flowy_folder_data_model::revision::{TrashRevision, TrashTypeRevision};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::fmt::Formatter;
|
use std::fmt::Formatter;
|
||||||
|
|
||||||
@ -22,6 +22,29 @@ pub struct Trash {
|
|||||||
pub ty: TrashType,
|
pub ty: TrashType,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl std::convert::From<TrashRevision> for Trash {
|
||||||
|
fn from(trash_rev: TrashRevision) -> Self {
|
||||||
|
Trash {
|
||||||
|
id: trash_rev.id,
|
||||||
|
name: trash_rev.name,
|
||||||
|
modified_time: trash_rev.modified_time,
|
||||||
|
create_time: trash_rev.create_time,
|
||||||
|
ty: trash_rev.ty.into(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl std::convert::From<Trash> for TrashRevision {
|
||||||
|
fn from(trash: Trash) -> Self {
|
||||||
|
TrashRevision {
|
||||||
|
id: trash.id,
|
||||||
|
name: trash.name,
|
||||||
|
modified_time: trash.modified_time,
|
||||||
|
create_time: trash.create_time,
|
||||||
|
ty: trash.ty.into(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
#[derive(PartialEq, Debug, Default, ProtoBuf, Clone)]
|
#[derive(PartialEq, Debug, Default, ProtoBuf, Clone)]
|
||||||
pub struct RepeatedTrash {
|
pub struct RepeatedTrash {
|
||||||
#[pb(index = 1)]
|
#[pb(index = 1)]
|
||||||
@ -29,10 +52,16 @@ pub struct RepeatedTrash {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl_def_and_def_mut!(RepeatedTrash, Trash);
|
impl_def_and_def_mut!(RepeatedTrash, Trash);
|
||||||
|
impl std::convert::From<Vec<TrashRevision>> for RepeatedTrash {
|
||||||
|
fn from(trash_revs: Vec<TrashRevision>) -> Self {
|
||||||
|
let items: Vec<Trash> = trash_revs.into_iter().map(|trash_rev| trash_rev.into()).collect();
|
||||||
|
RepeatedTrash { items }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Eq, PartialEq, Debug, ProtoBuf_Enum, Clone, Serialize, Deserialize)]
|
#[derive(Eq, PartialEq, Debug, ProtoBuf_Enum, Clone, Serialize, Deserialize)]
|
||||||
pub enum TrashType {
|
pub enum TrashType {
|
||||||
Unknown = 0,
|
TrashUnknown = 0,
|
||||||
TrashView = 1,
|
TrashView = 1,
|
||||||
TrashApp = 2,
|
TrashApp = 2,
|
||||||
}
|
}
|
||||||
@ -42,7 +71,7 @@ impl std::convert::TryFrom<i32> for TrashType {
|
|||||||
|
|
||||||
fn try_from(value: i32) -> Result<Self, Self::Error> {
|
fn try_from(value: i32) -> Result<Self, Self::Error> {
|
||||||
match value {
|
match value {
|
||||||
0 => Ok(TrashType::Unknown),
|
0 => Ok(TrashType::TrashUnknown),
|
||||||
1 => Ok(TrashType::TrashView),
|
1 => Ok(TrashType::TrashView),
|
||||||
2 => Ok(TrashType::TrashApp),
|
2 => Ok(TrashType::TrashApp),
|
||||||
_ => Err(format!("Invalid trash type: {}", value)),
|
_ => Err(format!("Invalid trash type: {}", value)),
|
||||||
@ -50,9 +79,29 @@ impl std::convert::TryFrom<i32> for TrashType {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl std::convert::From<TrashTypeRevision> for TrashType {
|
||||||
|
fn from(rev: TrashTypeRevision) -> Self {
|
||||||
|
match rev {
|
||||||
|
TrashTypeRevision::Unknown => TrashType::TrashUnknown,
|
||||||
|
TrashTypeRevision::TrashView => TrashType::TrashView,
|
||||||
|
TrashTypeRevision::TrashApp => TrashType::TrashApp,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl std::convert::From<TrashType> for TrashTypeRevision {
|
||||||
|
fn from(rev: TrashType) -> Self {
|
||||||
|
match rev {
|
||||||
|
TrashType::TrashUnknown => TrashTypeRevision::Unknown,
|
||||||
|
TrashType::TrashView => TrashTypeRevision::TrashView,
|
||||||
|
TrashType::TrashApp => TrashTypeRevision::TrashApp,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl std::default::Default for TrashType {
|
impl std::default::Default for TrashType {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
TrashType::Unknown
|
TrashType::TrashUnknown
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,7 +145,10 @@ impl std::convert::From<Vec<TrashRevision>> for RepeatedTrashId {
|
|||||||
fn from(trash: Vec<TrashRevision>) -> Self {
|
fn from(trash: Vec<TrashRevision>) -> Self {
|
||||||
let items = trash
|
let items = trash
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|t| TrashId { id: t.id, ty: t.ty })
|
.map(|t| TrashId {
|
||||||
|
id: t.id,
|
||||||
|
ty: t.ty.into(),
|
||||||
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
RepeatedTrashId {
|
RepeatedTrashId {
|
||||||
@ -120,3 +172,12 @@ impl std::fmt::Display for TrashId {
|
|||||||
f.write_str(&format!("{:?}:{}", self.ty, self.id))
|
f.write_str(&format!("{:?}:{}", self.ty, self.id))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl std::convert::From<&TrashRevision> for TrashId {
|
||||||
|
fn from(trash: &TrashRevision) -> Self {
|
||||||
|
TrashId {
|
||||||
|
id: trash.id.clone(),
|
||||||
|
ty: trash.ty.clone().into(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,20 +1,15 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
errors::ErrorCode,
|
entities::parser::{
|
||||||
impl_def_and_def_mut,
|
|
||||||
parser::{
|
|
||||||
app::AppIdentify,
|
app::AppIdentify,
|
||||||
view::{ViewDesc, ViewIdentify, ViewName, ViewThumbnail},
|
view::{ViewDesc, ViewIdentify, ViewName, ViewThumbnail},
|
||||||
},
|
},
|
||||||
|
errors::ErrorCode,
|
||||||
|
impl_def_and_def_mut,
|
||||||
};
|
};
|
||||||
use flowy_derive::{ProtoBuf, ProtoBuf_Enum};
|
use flowy_derive::{ProtoBuf, ProtoBuf_Enum};
|
||||||
use nanoid::nanoid;
|
use flowy_folder_data_model::revision::{gen_view_id, ViewDataTypeRevision, ViewRevision};
|
||||||
use serde_repr::*;
|
|
||||||
use std::convert::TryInto;
|
use std::convert::TryInto;
|
||||||
|
|
||||||
pub fn gen_view_id() -> String {
|
|
||||||
nanoid!(10)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Eq, PartialEq, ProtoBuf, Debug, Default, Clone)]
|
#[derive(Eq, PartialEq, ProtoBuf, Debug, Default, Clone)]
|
||||||
pub struct View {
|
pub struct View {
|
||||||
#[pb(index = 1)]
|
#[pb(index = 1)]
|
||||||
@ -39,8 +34,21 @@ pub struct View {
|
|||||||
pub plugin_type: i32,
|
pub plugin_type: i32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Eq, PartialEq, Hash, Debug, ProtoBuf_Enum, Clone, Serialize_repr, Deserialize_repr)]
|
impl std::convert::From<ViewRevision> for View {
|
||||||
#[repr(u8)]
|
fn from(rev: ViewRevision) -> Self {
|
||||||
|
View {
|
||||||
|
id: rev.id,
|
||||||
|
belong_to_id: rev.belong_to_id,
|
||||||
|
name: rev.name,
|
||||||
|
data_type: rev.data_type.into(),
|
||||||
|
modified_time: rev.modified_time,
|
||||||
|
create_time: rev.create_time,
|
||||||
|
plugin_type: rev.plugin_type,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Eq, PartialEq, Hash, Debug, ProtoBuf_Enum, Clone)]
|
||||||
pub enum ViewDataType {
|
pub enum ViewDataType {
|
||||||
TextBlock = 0,
|
TextBlock = 0,
|
||||||
Grid = 1,
|
Grid = 1,
|
||||||
@ -48,19 +56,24 @@ pub enum ViewDataType {
|
|||||||
|
|
||||||
impl std::default::Default for ViewDataType {
|
impl std::default::Default for ViewDataType {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
ViewDataType::TextBlock
|
ViewDataTypeRevision::default().into()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::convert::From<i32> for ViewDataType {
|
impl std::convert::From<ViewDataTypeRevision> for ViewDataType {
|
||||||
fn from(val: i32) -> Self {
|
fn from(rev: ViewDataTypeRevision) -> Self {
|
||||||
match val {
|
match rev {
|
||||||
0 => ViewDataType::TextBlock,
|
ViewDataTypeRevision::TextBlock => ViewDataType::TextBlock,
|
||||||
1 => ViewDataType::Grid,
|
ViewDataTypeRevision::Grid => ViewDataType::Grid,
|
||||||
_ => {
|
}
|
||||||
log::error!("Invalid view type: {}", val);
|
}
|
||||||
ViewDataType::TextBlock
|
}
|
||||||
}
|
|
||||||
|
impl std::convert::From<ViewDataType> for ViewDataTypeRevision {
|
||||||
|
fn from(ty: ViewDataType) -> Self {
|
||||||
|
match ty {
|
||||||
|
ViewDataType::TextBlock => ViewDataTypeRevision::TextBlock,
|
||||||
|
ViewDataType::Grid => ViewDataTypeRevision::Grid,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -73,6 +86,12 @@ pub struct RepeatedView {
|
|||||||
|
|
||||||
impl_def_and_def_mut!(RepeatedView, View);
|
impl_def_and_def_mut!(RepeatedView, View);
|
||||||
|
|
||||||
|
impl std::convert::From<Vec<ViewRevision>> for RepeatedView {
|
||||||
|
fn from(values: Vec<ViewRevision>) -> Self {
|
||||||
|
let items = values.into_iter().map(|value| value.into()).collect::<Vec<View>>();
|
||||||
|
RepeatedView { items }
|
||||||
|
}
|
||||||
|
}
|
||||||
#[derive(Default, ProtoBuf)]
|
#[derive(Default, ProtoBuf)]
|
||||||
pub struct RepeatedViewId {
|
pub struct RepeatedViewId {
|
||||||
#[pb(index = 1)]
|
#[pb(index = 1)]
|
@ -1,17 +1,13 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
|
entities::parser::workspace::{WorkspaceDesc, WorkspaceIdentify, WorkspaceName},
|
||||||
entities::{app::RepeatedApp, view::View},
|
entities::{app::RepeatedApp, view::View},
|
||||||
errors::*,
|
errors::*,
|
||||||
impl_def_and_def_mut,
|
impl_def_and_def_mut,
|
||||||
parser::workspace::{WorkspaceDesc, WorkspaceIdentify, WorkspaceName},
|
|
||||||
};
|
};
|
||||||
use flowy_derive::ProtoBuf;
|
use flowy_derive::ProtoBuf;
|
||||||
use nanoid::nanoid;
|
use flowy_folder_data_model::revision::WorkspaceRevision;
|
||||||
|
|
||||||
use std::convert::TryInto;
|
use std::convert::TryInto;
|
||||||
|
|
||||||
pub fn gen_workspace_id() -> String {
|
|
||||||
nanoid!(10)
|
|
||||||
}
|
|
||||||
#[derive(Eq, PartialEq, ProtoBuf, Default, Debug, Clone)]
|
#[derive(Eq, PartialEq, ProtoBuf, Default, Debug, Clone)]
|
||||||
pub struct Workspace {
|
pub struct Workspace {
|
||||||
#[pb(index = 1)]
|
#[pb(index = 1)]
|
||||||
@ -33,6 +29,18 @@ pub struct Workspace {
|
|||||||
pub create_time: i64,
|
pub create_time: i64,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl std::convert::From<WorkspaceRevision> for Workspace {
|
||||||
|
fn from(workspace_serde: WorkspaceRevision) -> Self {
|
||||||
|
Workspace {
|
||||||
|
id: workspace_serde.id,
|
||||||
|
name: workspace_serde.name,
|
||||||
|
desc: workspace_serde.desc,
|
||||||
|
apps: workspace_serde.apps.into(),
|
||||||
|
modified_time: workspace_serde.modified_time,
|
||||||
|
create_time: workspace_serde.create_time,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
#[derive(PartialEq, Debug, Default, ProtoBuf)]
|
#[derive(PartialEq, Debug, Default, ProtoBuf)]
|
||||||
pub struct RepeatedWorkspace {
|
pub struct RepeatedWorkspace {
|
||||||
#[pb(index = 1)]
|
#[pb(index = 1)]
|
@ -1,4 +1,4 @@
|
|||||||
pub use flowy_folder_data_model::entities;
|
pub mod entities;
|
||||||
pub mod event_map;
|
pub mod event_map;
|
||||||
pub mod services;
|
pub mod services;
|
||||||
|
|
||||||
@ -14,8 +14,6 @@ pub mod protobuf;
|
|||||||
mod util;
|
mod util;
|
||||||
|
|
||||||
pub mod prelude {
|
pub mod prelude {
|
||||||
pub use flowy_folder_data_model::entities::{app::*, trash::*, view::*, workspace::*};
|
|
||||||
|
|
||||||
pub use crate::{errors::*, event_map::*};
|
pub use crate::{errors::*, event_map::*};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
use crate::entities::view::ViewDataType;
|
||||||
use crate::{
|
use crate::{
|
||||||
dart_notification::{send_dart_notification, FolderNotification},
|
dart_notification::{send_dart_notification, FolderNotification},
|
||||||
entities::workspace::RepeatedWorkspace,
|
entities::workspace::RepeatedWorkspace,
|
||||||
@ -10,7 +11,6 @@ use crate::{
|
|||||||
};
|
};
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use flowy_error::FlowyError;
|
use flowy_error::FlowyError;
|
||||||
use flowy_folder_data_model::entities::view::ViewDataType;
|
|
||||||
use flowy_folder_data_model::user_default;
|
use flowy_folder_data_model::user_default;
|
||||||
use flowy_revision::disk::SQLiteTextBlockRevisionPersistence;
|
use flowy_revision::disk::SQLiteTextBlockRevisionPersistence;
|
||||||
use flowy_revision::{RevisionManager, RevisionPersistence, RevisionWebSocket};
|
use flowy_revision::{RevisionManager, RevisionPersistence, RevisionWebSocket};
|
||||||
|
@ -1,14 +1,11 @@
|
|||||||
use crate::{
|
use crate::errors::FlowyError;
|
||||||
entities::trash::{Trash, TrashType},
|
|
||||||
errors::FlowyError,
|
|
||||||
};
|
|
||||||
use diesel::sql_types::Integer;
|
use diesel::sql_types::Integer;
|
||||||
use flowy_database::{
|
use flowy_database::{
|
||||||
prelude::*,
|
prelude::*,
|
||||||
schema::{trash_table, trash_table::dsl},
|
schema::{trash_table, trash_table::dsl},
|
||||||
SqliteConnection,
|
SqliteConnection,
|
||||||
};
|
};
|
||||||
use flowy_folder_data_model::revision::TrashRevision;
|
use flowy_folder_data_model::revision::{TrashRevision, TrashTypeRevision};
|
||||||
|
|
||||||
pub struct TrashTableSql();
|
pub struct TrashTableSql();
|
||||||
impl TrashTableSql {
|
impl TrashTableSql {
|
||||||
@ -64,18 +61,18 @@ pub(crate) struct TrashTable {
|
|||||||
pub create_time: i64,
|
pub create_time: i64,
|
||||||
pub ty: SqlTrashType,
|
pub ty: SqlTrashType,
|
||||||
}
|
}
|
||||||
impl std::convert::From<TrashTable> for Trash {
|
// impl std::convert::From<TrashTable> for Trash {
|
||||||
fn from(table: TrashTable) -> Self {
|
// fn from(table: TrashTable) -> Self {
|
||||||
Trash {
|
// Trash {
|
||||||
id: table.id,
|
// id: table.id,
|
||||||
name: table.name,
|
// name: table.name,
|
||||||
modified_time: table.modified_time,
|
// modified_time: table.modified_time,
|
||||||
create_time: table.create_time,
|
// create_time: table.create_time,
|
||||||
ty: table.ty.into(),
|
// ty: table.ty.into(),
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
impl std::convert::From<TrashTable> for TrashRevision {
|
impl std::convert::From<TrashTable> for TrashRevision {
|
||||||
fn from(trash: TrashTable) -> Self {
|
fn from(trash: TrashTable) -> Self {
|
||||||
TrashRevision {
|
TrashRevision {
|
||||||
@ -141,22 +138,22 @@ impl std::convert::From<i32> for SqlTrashType {
|
|||||||
|
|
||||||
impl_sql_integer_expression!(SqlTrashType);
|
impl_sql_integer_expression!(SqlTrashType);
|
||||||
|
|
||||||
impl std::convert::From<SqlTrashType> for TrashType {
|
impl std::convert::From<SqlTrashType> for TrashTypeRevision {
|
||||||
fn from(ty: SqlTrashType) -> Self {
|
fn from(ty: SqlTrashType) -> Self {
|
||||||
match ty {
|
match ty {
|
||||||
SqlTrashType::Unknown => TrashType::Unknown,
|
SqlTrashType::Unknown => TrashTypeRevision::Unknown,
|
||||||
SqlTrashType::View => TrashType::TrashView,
|
SqlTrashType::View => TrashTypeRevision::TrashView,
|
||||||
SqlTrashType::App => TrashType::TrashApp,
|
SqlTrashType::App => TrashTypeRevision::TrashApp,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::convert::From<TrashType> for SqlTrashType {
|
impl std::convert::From<TrashTypeRevision> for SqlTrashType {
|
||||||
fn from(ty: TrashType) -> Self {
|
fn from(ty: TrashTypeRevision) -> Self {
|
||||||
match ty {
|
match ty {
|
||||||
TrashType::Unknown => SqlTrashType::Unknown,
|
TrashTypeRevision::Unknown => SqlTrashType::Unknown,
|
||||||
TrashType::TrashView => SqlTrashType::View,
|
TrashTypeRevision::TrashView => SqlTrashType::View,
|
||||||
TrashType::TrashApp => SqlTrashType::App,
|
TrashTypeRevision::TrashApp => SqlTrashType::App,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
entities::{
|
entities::{
|
||||||
trash::{Trash, TrashType},
|
trash::{Trash, TrashType},
|
||||||
view::{UpdateViewParams, ViewDataType},
|
view::UpdateViewParams,
|
||||||
},
|
},
|
||||||
errors::FlowyError,
|
errors::FlowyError,
|
||||||
services::persistence::version_1::app_sql::AppTable,
|
services::persistence::version_1::app_sql::AppTable,
|
||||||
@ -13,7 +13,7 @@ use flowy_database::{
|
|||||||
SqliteConnection,
|
SqliteConnection,
|
||||||
};
|
};
|
||||||
|
|
||||||
use flowy_folder_data_model::revision::ViewRevision;
|
use flowy_folder_data_model::revision::{ViewDataTypeRevision, ViewRevision};
|
||||||
use lib_infra::util::timestamp;
|
use lib_infra::util::timestamp;
|
||||||
|
|
||||||
pub struct ViewTableSql();
|
pub struct ViewTableSql();
|
||||||
@ -87,8 +87,8 @@ pub(crate) struct ViewTable {
|
|||||||
impl ViewTable {
|
impl ViewTable {
|
||||||
pub fn new(view_rev: ViewRevision) -> Self {
|
pub fn new(view_rev: ViewRevision) -> Self {
|
||||||
let data_type = match view_rev.data_type {
|
let data_type = match view_rev.data_type {
|
||||||
ViewDataType::TextBlock => SqlViewDataType::Block,
|
ViewDataTypeRevision::TextBlock => SqlViewDataType::Block,
|
||||||
ViewDataType::Grid => SqlViewDataType::Grid,
|
ViewDataTypeRevision::Grid => SqlViewDataType::Grid,
|
||||||
};
|
};
|
||||||
|
|
||||||
ViewTable {
|
ViewTable {
|
||||||
@ -110,8 +110,8 @@ impl ViewTable {
|
|||||||
impl std::convert::From<ViewTable> for ViewRevision {
|
impl std::convert::From<ViewTable> for ViewRevision {
|
||||||
fn from(table: ViewTable) -> Self {
|
fn from(table: ViewTable) -> Self {
|
||||||
let data_type = match table.view_type {
|
let data_type = match table.view_type {
|
||||||
SqlViewDataType::Block => ViewDataType::TextBlock,
|
SqlViewDataType::Block => ViewDataTypeRevision::TextBlock,
|
||||||
SqlViewDataType::Grid => ViewDataType::Grid,
|
SqlViewDataType::Grid => ViewDataTypeRevision::Grid,
|
||||||
};
|
};
|
||||||
|
|
||||||
ViewRevision {
|
ViewRevision {
|
||||||
|
@ -51,7 +51,7 @@ impl TrashController {
|
|||||||
|
|
||||||
let identifier = TrashId {
|
let identifier = TrashId {
|
||||||
id: trash.id,
|
id: trash.id,
|
||||||
ty: trash.ty,
|
ty: trash.ty.into(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let _ = self.delete_trash_on_server(RepeatedTrashId {
|
let _ = self.delete_trash_on_server(RepeatedTrashId {
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
pub use crate::entities::view::ViewDataType;
|
||||||
|
use crate::entities::ViewInfo;
|
||||||
use crate::manager::{ViewDataProcessor, ViewDataProcessorMap};
|
use crate::manager::{ViewDataProcessor, ViewDataProcessorMap};
|
||||||
use crate::{
|
use crate::{
|
||||||
dart_notification::{send_dart_notification, FolderNotification},
|
dart_notification::{send_dart_notification, FolderNotification},
|
||||||
@ -14,9 +16,7 @@ use crate::{
|
|||||||
};
|
};
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use flowy_database::kv::KV;
|
use flowy_database::kv::KV;
|
||||||
use flowy_folder_data_model::entities::view::{gen_view_id, ViewDataType};
|
use flowy_folder_data_model::revision::{gen_view_id, ViewRevision};
|
||||||
use flowy_folder_data_model::entities::ViewInfo;
|
|
||||||
use flowy_folder_data_model::revision::ViewRevision;
|
|
||||||
use flowy_sync::entities::text_block::TextBlockId;
|
use flowy_sync::entities::text_block::TextBlockId;
|
||||||
use futures::{FutureExt, StreamExt};
|
use futures::{FutureExt, StreamExt};
|
||||||
use std::{collections::HashSet, sync::Arc};
|
use std::{collections::HashSet, sync::Arc};
|
||||||
@ -58,7 +58,7 @@ impl ViewController {
|
|||||||
&self,
|
&self,
|
||||||
mut params: CreateViewParams,
|
mut params: CreateViewParams,
|
||||||
) -> Result<ViewRevision, FlowyError> {
|
) -> Result<ViewRevision, FlowyError> {
|
||||||
let processor = self.get_data_processor(¶ms.data_type)?;
|
let processor = self.get_data_processor(params.data_type.clone())?;
|
||||||
let user_id = self.user.user_id()?;
|
let user_id = self.user.user_id()?;
|
||||||
if params.data.is_empty() {
|
if params.data.is_empty() {
|
||||||
let view_data = processor.create_default_view(&user_id, ¶ms.view_id).await?;
|
let view_data = processor.create_default_view(&user_id, ¶ms.view_id).await?;
|
||||||
@ -88,7 +88,7 @@ impl ViewController {
|
|||||||
return Err(FlowyError::internal().context("The content of the view should not be empty"));
|
return Err(FlowyError::internal().context("The content of the view should not be empty"));
|
||||||
}
|
}
|
||||||
let user_id = self.user.user_id()?;
|
let user_id = self.user.user_id()?;
|
||||||
let processor = self.get_data_processor(&data_type)?;
|
let processor = self.get_data_processor(data_type)?;
|
||||||
let _ = processor.create_container(&user_id, view_id, delta_data).await?;
|
let _ = processor.create_container(&user_id, view_id, delta_data).await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -140,7 +140,7 @@ impl ViewController {
|
|||||||
belong_to_id: view_rev.belong_to_id,
|
belong_to_id: view_rev.belong_to_id,
|
||||||
name: view_rev.name,
|
name: view_rev.name,
|
||||||
desc: view_rev.desc,
|
desc: view_rev.desc,
|
||||||
data_type: view_rev.data_type,
|
data_type: view_rev.data_type.into(),
|
||||||
belongings: RepeatedView { items },
|
belongings: RepeatedView { items },
|
||||||
ext_data: view_rev.ext_data,
|
ext_data: view_rev.ext_data,
|
||||||
};
|
};
|
||||||
@ -209,14 +209,14 @@ impl ViewController {
|
|||||||
.begin_transaction(|transaction| transaction.read_view(view_id))
|
.begin_transaction(|transaction| transaction.read_view(view_id))
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
let processor = self.get_data_processor(&view_rev.data_type)?;
|
let processor = self.get_data_processor(view_rev.data_type.clone())?;
|
||||||
let delta_bytes = processor.get_delta_data(view_id).await?;
|
let delta_bytes = processor.get_delta_data(view_id).await?;
|
||||||
let duplicate_params = CreateViewParams {
|
let duplicate_params = CreateViewParams {
|
||||||
belong_to_id: view_rev.belong_to_id.clone(),
|
belong_to_id: view_rev.belong_to_id.clone(),
|
||||||
name: format!("{} (copy)", &view_rev.name),
|
name: format!("{} (copy)", &view_rev.name),
|
||||||
desc: view_rev.desc,
|
desc: view_rev.desc,
|
||||||
thumbnail: view_rev.thumbnail,
|
thumbnail: view_rev.thumbnail,
|
||||||
data_type: view_rev.data_type,
|
data_type: view_rev.data_type.into(),
|
||||||
data: delta_bytes.to_vec(),
|
data: delta_bytes.to_vec(),
|
||||||
view_id: gen_view_id(),
|
view_id: gen_view_id(),
|
||||||
plugin_type: view_rev.plugin_type,
|
plugin_type: view_rev.plugin_type,
|
||||||
@ -360,12 +360,16 @@ impl ViewController {
|
|||||||
.persistence
|
.persistence
|
||||||
.begin_transaction(|transaction| transaction.read_view(view_id))
|
.begin_transaction(|transaction| transaction.read_view(view_id))
|
||||||
.await?;
|
.await?;
|
||||||
self.get_data_processor(&view.data_type)
|
self.get_data_processor(view.data_type)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn get_data_processor(&self, data_type: &ViewDataType) -> FlowyResult<Arc<dyn ViewDataProcessor + Send + Sync>> {
|
fn get_data_processor<T: Into<ViewDataType>>(
|
||||||
match self.data_processors.get(data_type) {
|
&self,
|
||||||
|
data_type: T,
|
||||||
|
) -> FlowyResult<Arc<dyn ViewDataProcessor + Send + Sync>> {
|
||||||
|
let data_type = data_type.into();
|
||||||
|
match self.data_processors.get(&data_type) {
|
||||||
None => Err(FlowyError::internal().context(format!(
|
None => Err(FlowyError::internal().context(format!(
|
||||||
"Get data processor failed. Unknown view data type: {:?}",
|
"Get data processor failed. Unknown view data type: {:?}",
|
||||||
data_type
|
data_type
|
||||||
@ -429,7 +433,8 @@ async fn handle_trash_event(
|
|||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
for view in views {
|
for view in views {
|
||||||
match get_data_processor(data_processors.clone(), &view.data_type) {
|
let data_type = view.data_type.clone().into();
|
||||||
|
match get_data_processor(data_processors.clone(), &data_type) {
|
||||||
Ok(processor) => {
|
Ok(processor) => {
|
||||||
let _ = processor.close_container(&view.id).await?;
|
let _ = processor.close_container(&view.id).await?;
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
use crate::entities::view::{MoveFolderItemParams, MoveFolderItemPayload, MoveFolderItemType};
|
||||||
|
use crate::entities::ViewInfo;
|
||||||
use crate::manager::FolderManager;
|
use crate::manager::FolderManager;
|
||||||
use crate::services::{notify_workspace_setting_did_change, AppController};
|
use crate::services::{notify_workspace_setting_did_change, AppController};
|
||||||
use crate::{
|
use crate::{
|
||||||
@ -10,8 +12,6 @@ use crate::{
|
|||||||
errors::FlowyError,
|
errors::FlowyError,
|
||||||
services::{TrashController, ViewController},
|
services::{TrashController, ViewController},
|
||||||
};
|
};
|
||||||
use flowy_folder_data_model::entities::view::{MoveFolderItemParams, MoveFolderItemPayload, MoveFolderItemType};
|
|
||||||
use flowy_folder_data_model::entities::ViewInfo;
|
|
||||||
use flowy_folder_data_model::revision::TrashRevision;
|
use flowy_folder_data_model::revision::TrashRevision;
|
||||||
use lib_dispatch::prelude::{data_result, AppData, Data, DataResult};
|
use lib_dispatch::prelude::{data_result, AppData, Data, DataResult};
|
||||||
use std::{convert::TryInto, sync::Arc};
|
use std::{convert::TryInto, sync::Arc};
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
use crate::entities::workspace::*;
|
||||||
use crate::manager::FolderManager;
|
use crate::manager::FolderManager;
|
||||||
use crate::{
|
use crate::{
|
||||||
dart_notification::*,
|
dart_notification::*,
|
||||||
@ -9,7 +10,6 @@ use crate::{
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
use flowy_database::kv::KV;
|
use flowy_database::kv::KV;
|
||||||
use flowy_folder_data_model::entities::workspace::*;
|
|
||||||
use flowy_folder_data_model::revision::{AppRevision, WorkspaceRevision};
|
use flowy_folder_data_model::revision::{AppRevision, WorkspaceRevision};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
|
use crate::entities::{
|
||||||
|
app::RepeatedApp,
|
||||||
|
view::View,
|
||||||
|
workspace::{CurrentWorkspaceSetting, RepeatedWorkspace, WorkspaceId, *},
|
||||||
|
};
|
||||||
use crate::{
|
use crate::{
|
||||||
dart_notification::{send_dart_notification, FolderNotification},
|
dart_notification::{send_dart_notification, FolderNotification},
|
||||||
errors::FlowyError,
|
errors::FlowyError,
|
||||||
manager::FolderManager,
|
manager::FolderManager,
|
||||||
services::{get_current_workspace, read_local_workspace_apps, WorkspaceController},
|
services::{get_current_workspace, read_local_workspace_apps, WorkspaceController},
|
||||||
};
|
};
|
||||||
use flowy_folder_data_model::entities::{
|
|
||||||
app::RepeatedApp,
|
|
||||||
view::View,
|
|
||||||
workspace::{CurrentWorkspaceSetting, RepeatedWorkspace, WorkspaceId, *},
|
|
||||||
};
|
|
||||||
use lib_dispatch::prelude::{data_result, AppData, Data, DataResult};
|
use lib_dispatch::prelude::{data_result, AppData, Data, DataResult};
|
||||||
use std::{convert::TryInto, sync::Arc};
|
use std::{convert::TryInto, sync::Arc};
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use crate::script::{invalid_workspace_name_test_case, FolderScript::*, FolderTest};
|
use crate::script::{invalid_workspace_name_test_case, FolderScript::*, FolderTest};
|
||||||
|
use flowy_folder::entities::view::ViewDataType;
|
||||||
use flowy_folder::entities::workspace::CreateWorkspacePayload;
|
use flowy_folder::entities::workspace::CreateWorkspacePayload;
|
||||||
use flowy_folder_data_model::entities::view::ViewDataType;
|
|
||||||
|
|
||||||
use flowy_revision::disk::RevisionState;
|
use flowy_revision::disk::RevisionState;
|
||||||
use flowy_test::{event_builder::*, FlowySDKTest};
|
use flowy_test::{event_builder::*, FlowySDKTest};
|
||||||
|
@ -1,19 +1,19 @@
|
|||||||
use flowy_folder::event_map::FolderEvent::*;
|
use flowy_folder::entities::view::{RepeatedViewId, ViewId};
|
||||||
use flowy_folder::{errors::ErrorCode, services::folder_editor::FolderEditor};
|
use flowy_folder::entities::workspace::WorkspaceId;
|
||||||
use flowy_folder_data_model::entities::view::{RepeatedViewId, ViewId};
|
use flowy_folder::entities::{
|
||||||
use flowy_folder_data_model::entities::workspace::WorkspaceId;
|
|
||||||
use flowy_folder_data_model::entities::{
|
|
||||||
app::{App, RepeatedApp},
|
app::{App, RepeatedApp},
|
||||||
trash::Trash,
|
trash::Trash,
|
||||||
view::{RepeatedView, View, ViewDataType},
|
view::{RepeatedView, View, ViewDataType},
|
||||||
workspace::Workspace,
|
workspace::Workspace,
|
||||||
};
|
};
|
||||||
use flowy_folder_data_model::entities::{
|
use flowy_folder::entities::{
|
||||||
app::{AppId, CreateAppPayload, UpdateAppPayload},
|
app::{AppId, CreateAppPayload, UpdateAppPayload},
|
||||||
trash::{RepeatedTrash, TrashId, TrashType},
|
trash::{RepeatedTrash, TrashId, TrashType},
|
||||||
view::{CreateViewPayload, UpdateViewPayload},
|
view::{CreateViewPayload, UpdateViewPayload},
|
||||||
workspace::{CreateWorkspacePayload, RepeatedWorkspace},
|
workspace::{CreateWorkspacePayload, RepeatedWorkspace},
|
||||||
};
|
};
|
||||||
|
use flowy_folder::event_map::FolderEvent::*;
|
||||||
|
use flowy_folder::{errors::ErrorCode, services::folder_editor::FolderEditor};
|
||||||
|
|
||||||
use flowy_revision::disk::RevisionState;
|
use flowy_revision::disk::RevisionState;
|
||||||
use flowy_revision::REVISION_WRITE_INTERVAL_IN_MILLIS;
|
use flowy_revision::REVISION_WRITE_INTERVAL_IN_MILLIS;
|
||||||
@ -205,7 +205,7 @@ impl FolderTest {
|
|||||||
restore_view_from_trash(sdk, &self.view.id).await;
|
restore_view_from_trash(sdk, &self.view.id).await;
|
||||||
}
|
}
|
||||||
FolderScript::ReadTrash => {
|
FolderScript::ReadTrash => {
|
||||||
let trash = read_trash(sdk).await;
|
let mut trash = read_trash(sdk).await;
|
||||||
self.trash = trash.into_inner();
|
self.trash = trash.into_inner();
|
||||||
}
|
}
|
||||||
FolderScript::DeleteAllTrash => {
|
FolderScript::DeleteAllTrash => {
|
||||||
@ -264,7 +264,7 @@ pub async fn create_workspace(sdk: &FlowySDKTest, name: &str, desc: &str) -> Wor
|
|||||||
|
|
||||||
pub async fn read_workspace(sdk: &FlowySDKTest, workspace_id: Option<String>) -> Vec<Workspace> {
|
pub async fn read_workspace(sdk: &FlowySDKTest, workspace_id: Option<String>) -> Vec<Workspace> {
|
||||||
let request = WorkspaceId { value: workspace_id };
|
let request = WorkspaceId { value: workspace_id };
|
||||||
let repeated_workspace = FolderEventBuilder::new(sdk.clone())
|
let mut repeated_workspace = FolderEventBuilder::new(sdk.clone())
|
||||||
.event(ReadWorkspaces)
|
.event(ReadWorkspaces)
|
||||||
.payload(request.clone())
|
.payload(request.clone())
|
||||||
.async_send()
|
.async_send()
|
||||||
|
@ -3,7 +3,7 @@ use crate::{
|
|||||||
request::{HttpRequestBuilder, ResponseMiddleware},
|
request::{HttpRequestBuilder, ResponseMiddleware},
|
||||||
};
|
};
|
||||||
use flowy_error::FlowyError;
|
use flowy_error::FlowyError;
|
||||||
use flowy_folder_data_model::entities::{
|
use flowy_folder::entities::{
|
||||||
trash::RepeatedTrashId,
|
trash::RepeatedTrashId,
|
||||||
view::{CreateViewParams, RepeatedViewId, UpdateViewParams, ViewId},
|
view::{CreateViewParams, RepeatedViewId, UpdateViewParams, ViewId},
|
||||||
workspace::{CreateWorkspaceParams, UpdateWorkspaceParams, WorkspaceId},
|
workspace::{CreateWorkspaceParams, UpdateWorkspaceParams, WorkspaceId},
|
||||||
|
@ -252,15 +252,15 @@ impl RevisionUser for LocalRevisionUser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
use flowy_folder_data_model::entities::app::gen_app_id;
|
use flowy_folder::entities::{
|
||||||
use flowy_folder_data_model::entities::workspace::gen_workspace_id;
|
|
||||||
use flowy_folder_data_model::entities::{
|
|
||||||
app::{AppId, CreateAppParams, UpdateAppParams},
|
app::{AppId, CreateAppParams, UpdateAppParams},
|
||||||
trash::RepeatedTrashId,
|
trash::RepeatedTrashId,
|
||||||
view::{CreateViewParams, RepeatedViewId, UpdateViewParams, ViewId},
|
view::{CreateViewParams, RepeatedViewId, UpdateViewParams, ViewId},
|
||||||
workspace::{CreateWorkspaceParams, UpdateWorkspaceParams, WorkspaceId},
|
workspace::{CreateWorkspaceParams, UpdateWorkspaceParams, WorkspaceId},
|
||||||
};
|
};
|
||||||
use flowy_folder_data_model::revision::{AppRevision, TrashRevision, ViewRevision, WorkspaceRevision};
|
use flowy_folder_data_model::revision::{
|
||||||
|
gen_app_id, gen_workspace_id, AppRevision, TrashRevision, ViewRevision, WorkspaceRevision,
|
||||||
|
};
|
||||||
use flowy_text_block::BlockCloudService;
|
use flowy_text_block::BlockCloudService;
|
||||||
use flowy_user::event_map::UserCloudService;
|
use flowy_user::event_map::UserCloudService;
|
||||||
use flowy_user_data_model::entities::{
|
use flowy_user_data_model::entities::{
|
||||||
@ -308,7 +308,7 @@ impl FolderCouldServiceV1 for LocalServer {
|
|||||||
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,
|
||||||
data_type: params.data_type,
|
data_type: params.data_type.into(),
|
||||||
version: 0,
|
version: 0,
|
||||||
belongings: vec![],
|
belongings: vec![],
|
||||||
modified_time: time,
|
modified_time: time,
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use flowy_database::ConnectionPool;
|
use flowy_database::ConnectionPool;
|
||||||
|
use flowy_folder::entities::ViewDataType;
|
||||||
use flowy_folder::manager::{ViewDataProcessor, ViewDataProcessorMap};
|
use flowy_folder::manager::{ViewDataProcessor, ViewDataProcessorMap};
|
||||||
use flowy_folder::prelude::ViewDataType;
|
|
||||||
use flowy_folder::{
|
use flowy_folder::{
|
||||||
errors::{internal_error, FlowyError},
|
errors::{internal_error, FlowyError},
|
||||||
event_map::{FolderCouldServiceV1, WorkspaceDatabase, WorkspaceUser},
|
event_map::{FolderCouldServiceV1, WorkspaceDatabase, WorkspaceUser},
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
use flowy_folder::prelude::WorkspaceId;
|
use flowy_folder::entities::WorkspaceId;
|
||||||
use flowy_folder::{
|
use flowy_folder::{
|
||||||
entities::{
|
entities::{
|
||||||
app::*,
|
app::*,
|
||||||
|
@ -20,7 +20,7 @@ pub async fn check_user_handler(session: AppData<Arc<UserSession>>) -> DataResul
|
|||||||
|
|
||||||
#[tracing::instrument(level = "debug", skip(session))]
|
#[tracing::instrument(level = "debug", skip(session))]
|
||||||
pub async fn get_user_profile_handler(session: AppData<Arc<UserSession>>) -> DataResult<UserProfile, FlowyError> {
|
pub async fn get_user_profile_handler(session: AppData<Arc<UserSession>>) -> DataResult<UserProfile, FlowyError> {
|
||||||
let user_profile = session.user_profile().await?;
|
let user_profile = session.get_user_profile().await?;
|
||||||
data_result(user_profile)
|
data_result(user_profile)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ impl UserSession {
|
|||||||
#[tracing::instrument(level = "debug", skip(self))]
|
#[tracing::instrument(level = "debug", skip(self))]
|
||||||
pub async fn sign_in(&self, params: SignInParams) -> Result<UserProfile, FlowyError> {
|
pub async fn sign_in(&self, params: SignInParams) -> Result<UserProfile, FlowyError> {
|
||||||
if self.is_user_login(¶ms.email) {
|
if self.is_user_login(¶ms.email) {
|
||||||
self.user_profile().await
|
self.get_user_profile().await
|
||||||
} else {
|
} else {
|
||||||
let resp = self.cloud_service.sign_in(params).await?;
|
let resp = self.cloud_service.sign_in(params).await?;
|
||||||
let session: Session = resp.clone().into();
|
let session: Session = resp.clone().into();
|
||||||
@ -97,7 +97,7 @@ impl UserSession {
|
|||||||
#[tracing::instrument(level = "debug", skip(self))]
|
#[tracing::instrument(level = "debug", skip(self))]
|
||||||
pub async fn sign_up(&self, params: SignUpParams) -> Result<UserProfile, FlowyError> {
|
pub async fn sign_up(&self, params: SignUpParams) -> Result<UserProfile, FlowyError> {
|
||||||
if self.is_user_login(¶ms.email) {
|
if self.is_user_login(¶ms.email) {
|
||||||
self.user_profile().await
|
self.get_user_profile().await
|
||||||
} else {
|
} else {
|
||||||
let resp = self.cloud_service.sign_up(params).await?;
|
let resp = self.cloud_service.sign_up(params).await?;
|
||||||
let session: Session = resp.clone().into();
|
let session: Session = resp.clone().into();
|
||||||
@ -131,6 +131,10 @@ impl UserSession {
|
|||||||
let changeset = UserTableChangeset::new(params.clone());
|
let changeset = UserTableChangeset::new(params.clone());
|
||||||
diesel_update_table!(user_table, changeset, &*self.db_connection()?);
|
diesel_update_table!(user_table, changeset, &*self.db_connection()?);
|
||||||
|
|
||||||
|
let user_profile = self.get_user_profile().await?;
|
||||||
|
dart_notify(&session.token, UserNotification::UserProfileUpdated)
|
||||||
|
.payload(user_profile)
|
||||||
|
.send();
|
||||||
let _ = self.update_user_on_server(&session.token, params).await?;
|
let _ = self.update_user_on_server(&session.token, params).await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -150,7 +154,7 @@ impl UserSession {
|
|||||||
Ok(user.into())
|
Ok(user.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn user_profile(&self) -> Result<UserProfile, FlowyError> {
|
pub async fn get_user_profile(&self) -> Result<UserProfile, FlowyError> {
|
||||||
let (user_id, token) = self.get_session()?.into_part();
|
let (user_id, token) = self.get_session()?.into_part();
|
||||||
let user = dsl::user_table
|
let user = dsl::user_table
|
||||||
.filter(user_table::id.eq(&user_id))
|
.filter(user_table::id.eq(&user_id))
|
||||||
@ -179,23 +183,23 @@ impl UserSession {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl UserSession {
|
impl UserSession {
|
||||||
fn read_user_profile_on_server(&self, token: &str) -> Result<(), FlowyError> {
|
fn read_user_profile_on_server(&self, _token: &str) -> Result<(), FlowyError> {
|
||||||
let server = self.cloud_service.clone();
|
// let server = self.cloud_service.clone();
|
||||||
let token = token.to_owned();
|
// let token = token.to_owned();
|
||||||
tokio::spawn(async move {
|
// tokio::spawn(async move {
|
||||||
match server.get_user(&token).await {
|
// match server.get_user(&token).await {
|
||||||
Ok(profile) => {
|
// Ok(profile) => {
|
||||||
dart_notify(&token, UserNotification::UserProfileUpdated)
|
// dart_notify(&token, UserNotification::UserProfileUpdated)
|
||||||
.payload(profile)
|
// .payload(profile)
|
||||||
.send();
|
// .send();
|
||||||
}
|
// }
|
||||||
Err(e) => {
|
// Err(e) => {
|
||||||
dart_notify(&token, UserNotification::UserProfileUpdated)
|
// dart_notify(&token, UserNotification::UserProfileUpdated)
|
||||||
.error(e)
|
// .error(e)
|
||||||
.send();
|
// .send();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,2 +0,0 @@
|
|||||||
# Check out the FlowyConfig (located in flowy_toml.rs) for more details.
|
|
||||||
proto_input = ["src/entities",]
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user