fix: empty view id

This commit is contained in:
Nathan 2025-04-21 22:10:52 +08:00
parent 4e2990e599
commit b0c2b04a2d
5 changed files with 13 additions and 4 deletions

View file

@ -145,7 +145,7 @@ class _MobileHomePageState extends State<MobileHomePage> {
void _onLatestViewChange() async {
final id = getIt<MenuSharedState>().latestOpenView?.id;
if (id == null) {
if (id == null || id.isEmpty) {
return;
}
await FolderEventSetLatestView(ViewIdPB(value: id)).send();

View file

@ -36,7 +36,7 @@ class BlankPagePlugin extends Plugin {
PluginWidgetBuilder get widgetBuilder => BlankPagePluginWidgetBuilder();
@override
PluginId get id => "BlankStack";
PluginId get id => "";
@override
PluginType get pluginType => PluginType.blank;

View file

@ -404,7 +404,7 @@ class ViewBloc extends Bloc<ViewEvent, ViewState> {
});
}
if (update.updateChildViews.isNotEmpty) {
if (update.updateChildViews.isNotEmpty && update.parentViewId.isNotEmpty) {
final view = await ViewBackendService.getView(update.parentViewId);
final childViews = view.fold((l) => l.childViews, (r) => []);
bool isSameOrder = true;

View file

@ -111,6 +111,12 @@ class ViewBackendService {
static Future<FlowyResult<List<ViewPB>, FlowyError>> getChildViews({
required String viewId,
}) {
if (viewId.isEmpty) {
return Future.value(
FlowyResult<List<ViewPB>, FlowyError>.success(<ViewPB>[]),
);
}
final payload = ViewIdPB.create()..value = viewId;
return FolderEventGetView(payload).send().then((result) {
@ -262,6 +268,9 @@ class ViewBackendService {
static Future<FlowyResult<ViewPB, FlowyError>> getView(
String viewId,
) async {
if (viewId.isEmpty) {
Log.error('ViewId is empty');
}
final payload = ViewIdPB.create()..value = viewId;
return FolderEventGetView(payload).send();
}

View file

@ -631,7 +631,7 @@ class PageNotifier extends ChangeNotifier {
}
// Set the plugin view as the latest view.
if (setLatest) {
if (setLatest && newPlugin.id.isNotEmpty) {
FolderEventSetLatestView(ViewIdPB(value: newPlugin.id)).send();
}