mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2025-08-05 15:29:59 +00:00

* refactor: rename structs * chore: read database id from view * chore: fix open database error because of create a database view for database id * chore: fix tests * chore: rename datbase id to view id in flutter * refactor: move grid and board to database view folder * refactor: rename functions * refactor: move calender to datbase view folder * refactor: rename app_flowy to appflowy_flutter * chore: reanming * chore: fix freeze gen * chore: remove todos * refactor: view process events * chore: add link database test * chore: just open view if there is opened database
45 lines
1.2 KiB
Dart
45 lines
1.2 KiB
Dart
import 'package:appflowy/user/domain/auth_state.dart';
|
|
import 'package:appflowy_backend/dispatch/dispatch.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
|
|
|
part 'splash_bloc.freezed.dart';
|
|
|
|
class SplashBloc extends Bloc<SplashEvent, SplashState> {
|
|
SplashBloc() : super(SplashState.initial()) {
|
|
on<SplashEvent>((event, emit) async {
|
|
await event.map(
|
|
getUser: (val) async {
|
|
final result = await UserEventCheckUser().send();
|
|
final authState = result.fold(
|
|
(userProfile) {
|
|
return AuthState.authenticated(userProfile);
|
|
},
|
|
(error) {
|
|
return AuthState.unauthenticated(error);
|
|
},
|
|
);
|
|
|
|
emit(state.copyWith(auth: authState));
|
|
},
|
|
);
|
|
});
|
|
}
|
|
}
|
|
|
|
@freezed
|
|
class SplashEvent with _$SplashEvent {
|
|
const factory SplashEvent.getUser() = _GetUser;
|
|
}
|
|
|
|
@freezed
|
|
class SplashState with _$SplashState {
|
|
const factory SplashState({
|
|
required AuthState auth,
|
|
}) = _SplashState;
|
|
|
|
factory SplashState.initial() => const SplashState(
|
|
auth: AuthState.initial(),
|
|
);
|
|
}
|