Skip to content

Commit

Permalink
chore: update test
Browse files Browse the repository at this point in the history
  • Loading branch information
appflowy committed May 30, 2024
1 parent 7524df6 commit a77804e
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 37 deletions.
67 changes: 34 additions & 33 deletions frontend/appflowy_flutter/lib/plugins/ai_chat/chat_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ class _AIChatPageState extends State<AIChatPage> {
state.loadingPreviousStatus.when(
loading: () => Log.debug("loading"),
finish: () {
Log.debug("loading more messages");
blocContext
.read<ChatBloc>()
.add(const ChatEvent.loadPrevMessage());
Expand All @@ -117,41 +116,43 @@ class _AIChatPageState extends State<AIChatPage> {
);
}

ChatPopupMenu buildBubble(Message message, Widget child) {
Widget buildBubble(Message message, Widget child) {
final isAuthor = message.author.id == _user.id;
const borderRadius = BorderRadius.all(Radius.circular(20));
if (isMobile) {}

return ChatPopupMenu(
onAction: (action) {
switch (action) {
case ChatMessageAction.copy:
if (message is TextMessage) {
Clipboard.setData(
ClipboardData(text: message.text),
);
showMessageToast(
LocaleKeys.grid_row_copyProperty.tr(),
);
}
break;
}
},
builder: (context) {
return DecoratedBox(
decoration: BoxDecoration(
borderRadius: borderRadius,
color: !isAuthor || message.type == types.MessageType.image
? AFThemeExtension.of(context).tint1
: Theme.of(context).colorScheme.primary,
),
child: ClipRRect(
borderRadius: borderRadius,
child: Container(child: child),
),
);
},
final decoratedChild = DecoratedBox(
decoration: BoxDecoration(
borderRadius: borderRadius,
color: !isAuthor || message.type == types.MessageType.image
? AFThemeExtension.of(context).tint1
: Theme.of(context).colorScheme.primary,
),
child: ClipRRect(
borderRadius: borderRadius,
child: Container(child: child),
),
);

if (isMobile) {
return ChatPopupMenu(
onAction: (action) {
switch (action) {
case ChatMessageAction.copy:
if (message is TextMessage) {
Clipboard.setData(
ClipboardData(text: message.text),
);
showMessageToast(
LocaleKeys.grid_row_copyProperty.tr(),
);
}
break;
}
},
builder: (context) => decoratedChild,
);
} else {
return decoratedChild;
}
}

AFDefaultChatTheme buildTheme(BuildContext context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ async fn af_cloud_load_remote_system_message_test() {
// Load first five messages
let rx = test
.notification_sender
.subscribe::<ChatMessageListPB>(&chat_id, ChatNotification::DidLoadLatestChatMessage);
.subscribe::<ChatMessageListPB>(&chat_id, ChatNotification::DidLoadPrevChatMessage);
test
.load_prev_message(&chat_id, 5, Some(next_back_five.messages[4].message_id))
.await;
Expand Down
6 changes: 3 additions & 3 deletions frontend/rust-lib/flowy-chat/src/chat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,9 +333,6 @@ fn stream_send_chat_messages(
},
}
}

// Mark chat as finished
send_notification(&chat_id, ChatNotification::FinishAnswerQuestion).send();
},
Err(err) => {
error!("Failed to send chat message: {}", err);
Expand Down Expand Up @@ -376,6 +373,9 @@ fn stream_send_chat_messages(
})
.collect::<Vec<_>>();
insert_chat_messages(conn, &records)?;

// Mark chat as finished
send_notification(&chat_id, ChatNotification::FinishAnswerQuestion).send();
Ok(())
}) {
error!("Failed to save chat messages: {}", err);
Expand Down

0 comments on commit a77804e

Please sign in to comment.