55 lines
1.4 KiB
Dart
Raw Normal View History

2021-07-26 11:51:39 +08:00
import 'package:dartz/dartz.dart';
import 'package:app_flowy/workspace/domain/i_user.dart';
import 'package:app_flowy/workspace/infrastructure/repos/user_repo.dart';
import 'package:flowy_sdk/protobuf/flowy-workspace/errors.pb.dart';
2021-07-26 11:51:39 +08:00
export 'package:app_flowy/workspace/domain/i_user.dart';
export 'package:app_flowy/workspace/infrastructure/repos/user_repo.dart';
class IUserImpl extends IUser {
UserRepo repo;
IUserImpl({
required this.repo,
});
@override
Future<Either<Unit, WorkspaceError>> deleteWorkspace(String workspaceId) {
2021-07-26 13:51:41 +08:00
return repo.deleteWorkspace(workspaceId: workspaceId);
2021-07-26 11:51:39 +08:00
}
@override
2021-09-04 16:53:58 +08:00
Future<Either<UserProfile, UserError>> fetchUserProfile(String userId) {
return repo.fetchUserProfile(userId: userId);
2021-07-26 11:51:39 +08:00
}
@override
Future<Either<Unit, UserError>> signOut() {
2021-07-26 13:51:41 +08:00
return repo.signOut();
}
@override
2021-09-04 16:53:58 +08:00
UserProfile get user => repo.user;
2021-07-26 13:51:41 +08:00
@override
Future<Either<List<Workspace>, WorkspaceError>> fetchWorkspaces() {
2021-09-07 17:12:03 +08:00
return repo.getWorkspaces();
2021-07-26 11:51:39 +08:00
}
}
2021-07-30 08:43:10 +08:00
2021-09-07 17:12:03 +08:00
class IUserWorkspaceListWatchImpl extends IUserWorkspaceListWatch {
2021-07-30 08:43:10 +08:00
UserWatchRepo repo;
2021-09-07 17:12:03 +08:00
IUserWorkspaceListWatchImpl({
2021-07-30 08:43:10 +08:00
required this.repo,
});
@override
2021-09-07 17:12:03 +08:00
void startWatching({
WorkspaceListUpdatedCallback? workspaceListUpdatedCallback,
}) {
repo.startWatching(workspaceListUpdated: workspaceListUpdatedCallback);
2021-07-30 08:43:10 +08:00
}
@override
Future<void> stopWatching() async {
await repo.close();
}
}