21316: Merge commit '1416f698b72de4b09350d9c2fb25c1405c3247bc' into 21316-left-panel...
[arvados.git] / services / workbench2 / src / store / favorites / favorites-reducer.ts
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import { FavoritesAction, favoritesActions } from "./favorites-actions";
6
7 export type FavoritesState = Record<string, boolean>;
8
9 export const favoritesReducer = (state: FavoritesState = {}, action: FavoritesAction) => 
10     favoritesActions.match(action, {
11         UPDATE_FAVORITES: favorites => ({...state, ...favorites}),
12         default: () => state
13     });
14
15 export const checkFavorite = (uuid: string, state: FavoritesState) => state[uuid] === true;