From a6130a27c2b82cf7cddfa2cad93d43ca1e838863 Mon Sep 17 00:00:00 2001 From: Richard Shiue <71320345+richardshiue@users.noreply.github.com> Date: Mon, 12 Sep 2022 00:33:46 +0800 Subject: [PATCH] fix: prevent grid header from creating identical options --- .../field/type_option/multi_select_type_option.dart | 6 +++++- .../field/type_option/single_select_type_option.dart | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/frontend/app_flowy/lib/plugins/grid/application/field/type_option/multi_select_type_option.dart b/frontend/app_flowy/lib/plugins/grid/application/field/type_option/multi_select_type_option.dart index 7a54c43c3d..7fd50e5364 100644 --- a/frontend/app_flowy/lib/plugins/grid/application/field/type_option/multi_select_type_option.dart +++ b/frontend/app_flowy/lib/plugins/grid/application/field/type_option/multi_select_type_option.dart @@ -51,7 +51,11 @@ class MultiSelectAction with ISelectOptionAction { (option) { typeOption.freeze(); typeOption = typeOption.rebuild((typeOption) { - typeOption.options.insert(0, option); + final exists = typeOption.options + .any((element) => element.name == option.name); + if (!exists) { + typeOption.options.insert(0, option); + } }); return typeOption.options; diff --git a/frontend/app_flowy/lib/plugins/grid/application/field/type_option/single_select_type_option.dart b/frontend/app_flowy/lib/plugins/grid/application/field/type_option/single_select_type_option.dart index 8ba03c0bc7..5cc50dad61 100644 --- a/frontend/app_flowy/lib/plugins/grid/application/field/type_option/single_select_type_option.dart +++ b/frontend/app_flowy/lib/plugins/grid/application/field/type_option/single_select_type_option.dart @@ -48,7 +48,11 @@ class SingleSelectAction with ISelectOptionAction { (option) { typeOption.freeze(); typeOption = typeOption.rebuild((typeOption) { - typeOption.options.insert(0, option); + final exists = typeOption.options + .any((element) => element.name == option.name); + if (!exists) { + typeOption.options.insert(0, option); + } }); return typeOption.options;