Merge branch '21705-go-deps'
[arvados.git] / services / workbench2 / src / store / public-favorites / public-favorites-reducer.ts
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import { PublicFavoritesAction, publicFavoritesActions } from "./public-favorites-actions";
6
7 export type PublicFavoritesState = Record<string, boolean>;
8
9 export const publicFavoritesReducer = (state: PublicFavoritesState = {}, action: PublicFavoritesAction) =>
10     publicFavoritesActions.match(action, {
11         UPDATE_PUBLIC_FAVORITES: publicFavorites => ({ ...state, ...publicFavorites }),
12         default: () => state
13     });
14
15 export const checkPublicFavorite = (uuid: string, state: PublicFavoritesState) => state[uuid] === true;