mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2025-07-24 01:18:56 +00:00

* fix: create a new document * fix: the banner don't show after deleteing the page * fix: inserting a divider through the slash menu the cursor should stay active in the next line * fix: the overlay doesn't dismiss after selecting a page * fix: typo * fix: delete the page in document if it has been deleted * chore: l10n * chore: rename events * ci: rm install_diesel in ci * fix: cover color not working * ci: fix tauri build --------- Co-authored-by: nathan <nathan@appflowy.io>
106 lines
2.6 KiB
Dart
106 lines
2.6 KiB
Dart
import 'dart:async';
|
|
|
|
import 'package:appflowy_backend/protobuf/flowy-user/protobuf.dart';
|
|
import 'package:dartz/dartz.dart';
|
|
import 'package:appflowy_backend/dispatch/dispatch.dart';
|
|
import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';
|
|
import 'package:appflowy_backend/protobuf/flowy-folder2/workspace.pb.dart';
|
|
import 'package:fixnum/fixnum.dart';
|
|
|
|
class UserBackendService {
|
|
UserBackendService({
|
|
required this.userId,
|
|
});
|
|
|
|
final Int64 userId;
|
|
|
|
static Future<Either<FlowyError, UserProfilePB>>
|
|
getCurrentUserProfile() async {
|
|
final result = await UserEventGetUserProfile().send();
|
|
return result.swap();
|
|
}
|
|
|
|
Future<Either<Unit, FlowyError>> updateUserProfile({
|
|
String? name,
|
|
String? password,
|
|
String? email,
|
|
String? iconUrl,
|
|
String? openAIKey,
|
|
}) {
|
|
var payload = UpdateUserProfilePayloadPB.create()..id = userId;
|
|
|
|
if (name != null) {
|
|
payload.name = name;
|
|
}
|
|
|
|
if (password != null) {
|
|
payload.password = password;
|
|
}
|
|
|
|
if (email != null) {
|
|
payload.email = email;
|
|
}
|
|
|
|
if (iconUrl != null) {
|
|
payload.iconUrl = iconUrl;
|
|
}
|
|
|
|
if (openAIKey != null) {
|
|
payload.openaiKey = openAIKey;
|
|
}
|
|
|
|
return UserEventUpdateUserProfile(payload).send();
|
|
}
|
|
|
|
Future<Either<Unit, FlowyError>> deleteWorkspace({
|
|
required String workspaceId,
|
|
}) {
|
|
throw UnimplementedError();
|
|
}
|
|
|
|
Future<Either<Unit, FlowyError>> signOut(AuthTypePB authType) {
|
|
final payload = SignOutPB()..authType = authType;
|
|
return UserEventSignOut(payload).send();
|
|
}
|
|
|
|
Future<Either<Unit, FlowyError>> initUser() async {
|
|
return UserEventInitUser().send();
|
|
}
|
|
|
|
Future<Either<List<WorkspacePB>, FlowyError>> getWorkspaces() {
|
|
final request = WorkspaceIdPB.create();
|
|
|
|
return FolderEventReadAllWorkspaces(request).send().then((result) {
|
|
return result.fold(
|
|
(workspaces) => left(workspaces.items),
|
|
(error) => right(error),
|
|
);
|
|
});
|
|
}
|
|
|
|
Future<Either<WorkspacePB, FlowyError>> openWorkspace(String workspaceId) {
|
|
final request = WorkspaceIdPB.create()..value = workspaceId;
|
|
return FolderEventOpenWorkspace(request).send().then((result) {
|
|
return result.fold(
|
|
(workspace) => left(workspace),
|
|
(error) => right(error),
|
|
);
|
|
});
|
|
}
|
|
|
|
Future<Either<WorkspacePB, FlowyError>> createWorkspace(
|
|
String name,
|
|
String desc,
|
|
) {
|
|
final request = CreateWorkspacePayloadPB.create()
|
|
..name = name
|
|
..desc = desc;
|
|
return FolderEventCreateWorkspace(request).send().then((result) {
|
|
return result.fold(
|
|
(workspace) => left(workspace),
|
|
(error) => right(error),
|
|
);
|
|
});
|
|
}
|
|
}
|