fix: remove current page link option in page reference (#3600)

* fix: remove current page link option in page reference

* fix: removed context and added view id as parameter
This commit is contained in:
Narayan 2023-10-04 15:19:22 +05:30 committed by GitHub
parent 9306d4a4ee
commit cca5005541
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 4 deletions

View File

@ -57,7 +57,9 @@ class _AppFlowyEditorPageState extends State<AppFlowyEditorPage> {
late final InlineActionsService inlineActionsService = InlineActionsService(
context: context,
handlers: [
InlinePageReferenceService().inlinePageReferenceDelegate,
InlinePageReferenceService(
currentViewId: documentBloc.view.id,
).inlinePageReferenceDelegate,
DateReferenceService(context).dateReferenceDelegate,
ReminderReferenceService(context).reminderReferenceDelegate,
],

View File

@ -9,11 +9,12 @@ import 'package:appflowy_editor/appflowy_editor.dart';
import 'package:easy_localization/easy_localization.dart';
class InlinePageReferenceService {
InlinePageReferenceService() {
InlinePageReferenceService({required this.currentViewId}) {
init();
}
final Completer _initCompleter = Completer<void>();
final String currentViewId;
late final ViewBackendService service;
List<InlineActionsMenuItem> _items = [];
@ -22,7 +23,7 @@ class InlinePageReferenceService {
Future<void> init() async {
service = ViewBackendService();
_generatePageItems().then((value) {
_generatePageItems(currentViewId).then((value) {
_items = value;
_filtered = value;
_initCompleter.complete();
@ -59,7 +60,9 @@ class InlinePageReferenceService {
);
}
Future<List<InlineActionsMenuItem>> _generatePageItems() async {
Future<List<InlineActionsMenuItem>> _generatePageItems(
String currentViewId,
) async {
final views = await service.fetchViews();
if (views.isEmpty) {
return [];
@ -69,6 +72,10 @@ class InlinePageReferenceService {
views.sort(((a, b) => b.createTime.compareTo(a.createTime)));
for (final view in views) {
if (view.id == currentViewId) {
continue;
}
final pageSelectionMenuItem = InlineActionsMenuItem(
keywords: [view.name.toLowerCase()],
label: view.name,