Add refreshing panel list after toggle favorite
[arvados-workbench2.git] / src / store / favorites / favorites-actions.ts
index 225c9b35c36ce934721c1c10f5cb2883a15e4594..4a176e303c40823ffed69d9e9776a15805724c8a 100644 (file)
@@ -17,7 +17,7 @@ export const favoritesActions = unionize({
 export type FavoritesAction = UnionOf<typeof favoritesActions>;
 
 export const toggleFavorite = (resource: { uuid: string; name: string }) =>
-    (dispatch: Dispatch, getState: () => RootState) => {
+    (dispatch: Dispatch, getState: () => RootState): Promise<any> => {
         const userUuid = getState().auth.user!.uuid;
         dispatch(favoritesActions.TOGGLE_FAVORITE({ resourceUuid: resource.uuid }));
         const isFavorite = checkFavorite(resource.uuid, getState().favorites);
@@ -25,7 +25,7 @@ export const toggleFavorite = (resource: { uuid: string; name: string }) =>
             ? favoriteService.delete({ userUuid, resourceUuid: resource.uuid })
             : favoriteService.create({ userUuid, resource });
 
-        promise
+        return promise
             .then(fav => {
                 dispatch(favoritesActions.UPDATE_FAVORITES({ [resource.uuid]: !isFavorite }));
             });