removeCard<T> function

ThunkAction<SwipeFeedState<T>> removeCard<T>()

Removes a card only after being swiped

Implementation

ThunkAction<SwipeFeedState<T>> removeCard<T>(){
  return (Store<SwipeFeedState<T>> store) async {
    List<Tuple2<T?, Store<SwipeFeedCardState>>> items = store.state.items;
    if(items.length >= 2) {
      if(items[1].item1 == null){
        items[1].item2.dispatch(SetSwipeFeedCardState(SwipeCardHideState(!store.state.connectivity ? store.state.connectivityError : store.state.noMoreItems)));
      }
      else{
        items[1].item2.dispatch(SetSwipeFeedCardState(SwipeCardShowState()));
      }
    }

    // Duration it takes for card to make it off the screen
    // This is after the card has been swipped away
    items.removeAt(0);
    store.dispatch(SetItemsEvent(items));
    if(store.state.items.length <= SwipeFeedState.LOAD_MORE_LIMIT){
      store.dispatch(loadMore<T>());
    }
  };
}