Merge branch '19177-sharing-urls-ui-config'. Closes #19177
[arvados-workbench2.git] / 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;