mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
feat: hide ref database view (#2682)
This commit is contained in:
@ -17,6 +17,14 @@ class DatabaseViewBackendService {
|
||||
required this.viewId,
|
||||
});
|
||||
|
||||
/// Returns the datbaase id associated with the view.
|
||||
Future<Either<String, FlowyError>> getDatabaseId() async {
|
||||
final payload = DatabaseViewIdPB(value: viewId);
|
||||
return DatabaseEventGetDatabaseId(payload)
|
||||
.send()
|
||||
.then((value) => value.leftMap((l) => l.value));
|
||||
}
|
||||
|
||||
Future<Either<DatabasePB, FlowyError>> openGrid() async {
|
||||
await FolderEventSetLatestView(ViewIdPB(value: viewId)).send();
|
||||
|
||||
|
@ -25,12 +25,12 @@ extension InsertDatabase on EditorState {
|
||||
return;
|
||||
}
|
||||
|
||||
// get the database that the view is associated with
|
||||
final database = await DatabaseViewBackendService(viewId: childView.id)
|
||||
.openGrid()
|
||||
// get the database id that the view is associated with
|
||||
final databaseId = await DatabaseViewBackendService(viewId: childView.id)
|
||||
.getDatabaseId()
|
||||
.then((value) => value.swap().toOption().toNullable());
|
||||
|
||||
if (database == null) {
|
||||
if (databaseId == null) {
|
||||
throw StateError(
|
||||
'The database associated with ${childView.id} could not be found while attempting to create a referenced ${childView.layout.name}.',
|
||||
);
|
||||
@ -38,10 +38,10 @@ extension InsertDatabase on EditorState {
|
||||
|
||||
final prefix = _referencedDatabasePrefix(childView.layout);
|
||||
final ref = await ViewBackendService.createDatabaseReferenceView(
|
||||
parentViewId: parentView.id,
|
||||
parentViewId: childView.id,
|
||||
name: "$prefix ${childView.name}",
|
||||
layoutType: childView.layout,
|
||||
databaseId: database.id,
|
||||
databaseId: databaseId,
|
||||
).then((value) => value.swap().toOption().toNullable());
|
||||
|
||||
// TODO(a-wallen): Show error dialog here.
|
||||
@ -55,7 +55,7 @@ extension InsertDatabase on EditorState {
|
||||
Node(
|
||||
type: _convertPageType(childView),
|
||||
attributes: {
|
||||
DatabaseBlockKeys.parentID: parentView.id,
|
||||
DatabaseBlockKeys.parentID: childView.id,
|
||||
DatabaseBlockKeys.viewID: ref.id,
|
||||
},
|
||||
),
|
||||
|
Reference in New Issue
Block a user