-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
38 changed files
with
1,417 additions
and
357 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
frontend/appflowy_flutter/lib/plugins/ai_chat/application/chat_ai_message_bloc.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import 'package:appflowy_backend/protobuf/flowy-document/protobuf.dart'; | ||
import 'package:appflowy_backend/protobuf/flowy-user/protobuf.dart'; | ||
import 'package:flutter_bloc/flutter_bloc.dart'; | ||
import 'package:flutter_chat_types/flutter_chat_types.dart'; | ||
import 'package:freezed_annotation/freezed_annotation.dart'; | ||
|
||
part 'chat_ai_message_bloc.freezed.dart'; | ||
|
||
class ChatAIMessageBloc extends Bloc<ChatAIMessageEvent, ChatAIMessageState> { | ||
ChatAIMessageBloc({ | ||
required Message message, | ||
}) : super(ChatAIMessageState.initial(message)) { | ||
on<ChatAIMessageEvent>( | ||
(event, emit) async { | ||
await event.when( | ||
initial: () async {}, | ||
update: (userProfile, deviceId, states) {}, | ||
); | ||
}, | ||
); | ||
} | ||
} | ||
|
||
@freezed | ||
class ChatAIMessageEvent with _$ChatAIMessageEvent { | ||
const factory ChatAIMessageEvent.initial() = Initial; | ||
const factory ChatAIMessageEvent.update( | ||
UserProfilePB userProfile, | ||
String deviceId, | ||
DocumentAwarenessStatesPB states, | ||
) = Update; | ||
} | ||
|
||
@freezed | ||
class ChatAIMessageState with _$ChatAIMessageState { | ||
const factory ChatAIMessageState({ | ||
required Message message, | ||
}) = _ChatAIMessageState; | ||
|
||
factory ChatAIMessageState.initial(Message message) => | ||
ChatAIMessageState(message: message); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.