mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
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:
parent
9306d4a4ee
commit
cca5005541
@ -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,
|
||||
],
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user