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';
|
2021-08-31 11:32:51 +08:00
|
|
|
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() {
|
|
|
|
return repo.fetchWorkspaces();
|
2021-07-26 11:51:39 +08:00
|
|
|
}
|
|
|
|
}
|
2021-07-30 08:43:10 +08:00
|
|
|
|
|
|
|
class IUserWatchImpl extends IUserWatch {
|
|
|
|
UserWatchRepo repo;
|
|
|
|
IUserWatchImpl({
|
|
|
|
required this.repo,
|
|
|
|
});
|
|
|
|
@override
|
|
|
|
void startWatching(
|
|
|
|
{UserCreateWorkspaceCallback? createWorkspaceCallback,
|
|
|
|
UserDeleteWorkspaceCallback? deleteWorkspaceCallback}) {
|
|
|
|
repo.startWatching(
|
|
|
|
createWorkspace: createWorkspaceCallback,
|
|
|
|
deleteWorkspace: deleteWorkspaceCallback);
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Future<void> stopWatching() async {
|
|
|
|
await repo.close();
|
|
|
|
}
|
|
|
|
}
|