Skip to content

Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.

fix: launch review issues 0.7.8 (#6983)

Richard Shiue25f9bee96359
diff --git a/frontend/appflowy_flutter/lib/plugins/ai_chat/application/chat_input_control_cubit.dart b/frontend/appflowy_flutter/lib/plugins/ai_chat/application/chat_input_control_cubit.dart
index c663699e2c..1dfa75755a 100644
--- a/frontend/appflowy_flutter/lib/plugins/ai_chat/application/chat_input_control_cubit.dart
+++ b/frontend/appflowy_flutter/lib/plugins/ai_chat/application/chat_input_control_cubit.dart
@@ -44,9 +44,11 @@ class ChatInputControlCubit extends Cubit<ChatInputControlState> {
void refreshViews() async {
final newViews = await ViewBackendService.getAllViews().fold(
- (result) => result.items
- .where((v) => v.layout.isDocumentView && v.parentViewId.isNotEmpty)
- .toList(),
+ (result) {
+ return result.items
+ .where((v) => v.layout.isDocumentView && v.parentViewId != v.id)
+ .toList();
+ },
(err) {
Log.error(err);
return <ViewPB>[];
diff --git a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_input/chat_mention_page_bottom_sheet.dart b/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_input/chat_mention_page_bottom_sheet.dart
index d12ca5abd6..cb2e7248d4 100644
--- a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_input/chat_mention_page_bottom_sheet.dart
+++ b/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_input/chat_mention_page_bottom_sheet.dart
@@ -2,7 +2,6 @@ import 'package:appflowy/generated/locale_keys.g.dart';
import 'package:appflowy/mobile/presentation/base/flowy_search_text_field.dart';
import 'package:appflowy/mobile/presentation/bottom_sheet/show_mobile_bottom_sheet.dart';
import 'package:appflowy/plugins/base/drag_handler.dart';
-import 'package:appflowy/workspace/application/view/view_ext.dart';
import 'package:appflowy/workspace/application/view/view_service.dart';
import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';
import 'package:easy_localization/easy_localization.dart';
@@ -13,10 +12,8 @@ import 'chat_mention_page_menu.dart';
Future<ViewPB?> showPageSelectorSheet(
BuildContext context, {
- bool Function(ViewPB view)? filter,
+ required bool Function(ViewPB view) filter,
}) async {
- filter ??= (v) => !v.isSpace && v.parentViewId.isNotEmpty;
-
return showMobileBottomSheet<ViewPB>(
context,
backgroundColor: Theme.of(context).colorScheme.surface,
diff --git a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_input/chat_mention_page_menu.dart b/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_input/chat_mention_page_menu.dart
index 10ce04f256..180879b2b7 100644
--- a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_input/chat_mention_page_menu.dart
+++ b/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_input/chat_mention_page_menu.dart
@@ -15,7 +15,7 @@ import 'package:scroll_to_index/scroll_to_index.dart';
const double _itemHeight = 44.0;
const double _noPageHeight = 20.0;
const double _fixedWidth = 360.0;
-const double _maxHeight = 600.0;
+const double _maxHeight = 328.0;
class ChatInputAnchor {
ChatInputAnchor(this.anchorKey, this.layerLink);
@@ -154,8 +154,10 @@ class ChatMentionPageList extends StatefulWidget {
}
class _ChatMentionPageListState extends State<ChatMentionPageList> {
- final autoScrollController = AutoScrollController(
+ final autoScrollController = SimpleAutoScrollController(
suggestedRowHeight: _itemHeight,
+ beginGetter: (rect) => rect.top + 8.0,
+ endGetter: (rect) => rect.bottom - 8.0,
);
@override
@@ -169,8 +171,8 @@ class _ChatMentionPageListState extends State<ChatMentionPageList> {
return BlocConsumer<ChatInputControlCubit, ChatInputControlState>(
listenWhen: (previous, current) {
return previous.maybeWhen(
- ready: (pVisibleViews, pFocusedViewIndex) => current.maybeWhen(
- ready: (cIsibleViews, cFocusedViewIndex) =>
+ ready: (_, pFocusedViewIndex) => current.maybeWhen(
+ ready: (_, cFocusedViewIndex) =>
pFocusedViewIndex != cFocusedViewIndex,
orElse: () => false,
),
@@ -226,8 +228,6 @@ class _ChatMentionPageListState extends State<ChatMentionPageList> {
return ListView.builder(
shrinkWrap: true,
- cacheExtent: 1,
- addAutomaticKeepAlives: false,
controller: autoScrollController,
padding: const EdgeInsets.all(8.0),
itemCount: views.length,
@@ -344,8 +344,7 @@ class MentionViewTitleAndAncestors extends StatelessWidget {
@override
Widget build(BuildContext context) {
return BlocProvider(
- create: (_) =>
- ViewTitleBarBloc(view: view)..add(const ViewTitleBarEvent.initial()),
+ create: (_) => ViewTitleBarBloc(view: view),
child: BlocBuilder<ViewTitleBarBloc, ViewTitleBarState>(
builder: (context, state) {
final nonEmptyName = view.name.isEmpty
diff --git a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_input/desktop_ai_prompt_input.dart b/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_input/desktop_ai_prompt_input.dart
index c31b7f37ca..b37d2e10d2 100644
--- a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_input/desktop_ai_prompt_input.dart
+++ b/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_input/desktop_ai_prompt_input.dart
@@ -519,6 +519,9 @@ class _PromptBottomActions extends StatelessWidget {
iconSize: DesktopAIPromptSizes.actionBarIconSize,
buttonSize: DesktopAIPromptSizes.actionBarButtonSize,
onTap: () {
+ if (overlayController.isShowing) {
+ return;
+ }
if (!focusNode.hasFocus) {
focusNode.requestFocus();
}
diff --git a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_input/mobile_ai_prompt_input.dart b/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_input/mobile_ai_prompt_input.dart
index f7a657bc18..28b81b7659 100644
--- a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_input/mobile_ai_prompt_input.dart
+++ b/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_input/mobile_ai_prompt_input.dart
@@ -198,7 +198,7 @@ class _MobileAIPromptInputState extends State<MobileAIPromptInput> {
context,
filter: (view) =>
view.layout.isDocumentView &&
- view.parentViewId.isNotEmpty &&
+ view.parentViewId != view.id &&
!inputControlCubit.selectedViewIds.contains(view.id),
);
if (selectedView != null) {
diff --git a/frontend/appflowy_flutter/lib/workspace/application/view_title/view_title_bar_bloc.dart b/frontend/appflowy_flutter/lib/workspace/application/view_title/view_title_bar_bloc.dart
index 12e22a4d1d..1530c96d32 100644
--- a/frontend/appflowy_flutter/lib/workspace/application/view_title/view_title_bar_bloc.dart
+++ b/frontend/appflowy_flutter/lib/workspace/application/view_title/view_title_bar_bloc.dart
@@ -10,27 +10,9 @@ part 'view_title_bar_bloc.freezed.dart';
class ViewTitleBarBloc extends Bloc<ViewTitleBarEvent, ViewTitleBarState> {
ViewTitleBarBloc({required this.view}) : super(ViewTitleBarState.initial()) {
- trashService = TrashService();
- viewListener = ViewListener(viewId: view.id)
- ..start(
- onViewChildViewsUpdated: (_) => add(const ViewTitleBarEvent.reload()),
- );
- trashListener = TrashListener()
- ..start(
- trashUpdated: (trashOrFailed) {
- final trash = trashOrFailed.toNullable();
- if (trash != null) {
- add(ViewTitleBarEvent.trashUpdated(trash: trash));
- }
- },
- );
-
on<ViewTitleBarEvent>(
(event, emit) async {
await event.when(
- initial: () async {
- add(const ViewTitleBarEvent.reload());
- },
reload: () async {
final List<ViewPB> ancestors =
await ViewBackendService.getViewAncestors(view.id).fold(
@@ -53,6 +35,29 @@ class ViewTitleBarBloc extends Bloc<ViewTitleBarEvent, ViewTitleBarState> {
);
},
);
+
+ trashService = TrashService();
+ viewListener = ViewListener(viewId: view.id)
+ ..start(
+ onViewChildViewsUpdated: (_) {
+ if (!isClosed) {
+ add(const ViewTitleBarEvent.reload());
+ }
+ },
+ );
+ trashListener = TrashListener()
+ ..start(
+ trashUpdated: (trashOrFailed) {
+ final trash = trashOrFailed.toNullable();
+ if (trash != null && !isClosed) {
+ add(ViewTitleBarEvent.trashUpdated(trash: trash));
+ }
+ },
+ );
+
+ if (!isClosed) {
+ add(const ViewTitleBarEvent.reload());
+ }
}
final ViewPB view;
@@ -70,7 +75,6 @@ class ViewTitleBarBloc extends Bloc<ViewTitleBarEvent, ViewTitleBarState> {
@freezed
class ViewTitleBarEvent with _$ViewTitleBarEvent {
- const factory ViewTitleBarEvent.initial() = Initial;
const factory ViewTitleBarEvent.reload() = Reload;
const factory ViewTitleBarEvent.trashUpdated({
required List<TrashPB> trash,
diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/widgets/view_title_bar.dart b/frontend/appflowy_flutter/lib/workspace/presentation/widgets/view_title_bar.dart
index b7691f4239..63b498c2f2 100644
--- a/frontend/appflowy_flutter/lib/workspace/presentation/widgets/view_title_bar.dart
+++ b/frontend/appflowy_flutter/lib/workspace/presentation/widgets/view_title_bar.dart
@@ -28,8 +28,7 @@ class ViewTitleBar extends StatelessWidget {
@override
Widget build(BuildContext context) {
return BlocProvider(
- create: (_) =>
- ViewTitleBarBloc(view: view)..add(const ViewTitleBarEvent.initial()),
+ create: (_) => ViewTitleBarBloc(view: view),
child: BlocBuilder<ViewTitleBarBloc, ViewTitleBarState>(
builder: (context, state) {
final ancestors = state.ancestors;