removeItemIfNotFirst<T> function

ThunkAction<SwipeFeedState<T>> removeItemIfNotFirst<T>(
  1. T item,
  2. String compare(
    1. T
    )
)

Implementation

ThunkAction<SwipeFeedState<T>> removeItemIfNotFirst<T>(T item, String Function(T) compare){
  return (Store<SwipeFeedState<T>> store) async {
    int index = store.state.items.indexWhere((element) => element.item1 != null && compare(item) == compare(element.item1!));
    if(store.state.items.isNotEmpty){
      if(index != -1){
        List<Tuple2<T?, Store<SwipeFeedCardState>>> items = store.state.items;
        items.removeAt(index);
        store.dispatch(SetItemsEvent(items));
      }
    }
  };
}