Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | 11x 11x 11x 11x 11x 36x 11x 11x 13x 11x 11x 11x 2x 15x 11x 11x 11x 4x 11x | import { createSelector, createSelectorFactory, resultMemoize } from '@ngrx/store'; import { uniq } from 'lodash-es'; import { isArrayEqual } from 'ish-core/utils/functions'; import { Wishlist } from '../../models/wishlist/wishlist.model'; import { getWishlistsState } from '../wishlists-store'; import { WishlistState, initialState, wishlistsAdapter } from './wishlist.reducer'; const getWishlistState = createSelector(getWishlistsState, state => (state ? state.wishlists : initialState)); const { selectEntities, selectAll } = wishlistsAdapter.getSelectors(getWishlistState); export const getAllWishlists = selectAll; export const getWishlistsLoading = createSelector(getWishlistState, state => state.loading); export const getWishlistsError = createSelector(getWishlistState, state => state.error); export const getSelectedWishlistId = createSelector(getWishlistState, state => state.selected); export const getSelectedWishlistDetails = createSelector( selectEntities, getSelectedWishlistId, (entities, id): Wishlist => id && entities[id] ); export const getWishlistDetails = (id: string) => createSelector(selectEntities, entities => entities[id]); export const getPreferredWishlist = createSelector(getAllWishlists, entities => entities.find(e => e.preferred)); /** * Gets all unique items from all wishlists * Returns an array of the wishlist item product SKUs */ export const getAllWishlistsItemsSkus = createSelectorFactory<object, string[]>(projector => resultMemoize(projector, isArrayEqual) )(getAllWishlists, (wishlists: Wishlist[]): string[] => uniq(wishlists.map(wishlist => wishlist.items.map(items => items.sku)).flat()) ); export const getSharedWishlist = createSelector(getWishlistState, (state: WishlistState) => state.sharedWishlist); |