import { snackbarActions, SnackbarKind } from "../snackbar/snackbar-actions";
import { ServiceRepository } from "services/services";
import { progressIndicatorActions } from "store/progress-indicator/progress-indicator-actions";
-import { loadFavorites} from "store/side-panel-tree/side-panel-tree-actions";
+import { loadFavoritesTree} from "store/side-panel-tree/side-panel-tree-actions";
export const favoritesActions = unionize({
TOGGLE_FAVORITE: ofType<{ resourceUuid: string }>(),
kind: SnackbarKind.SUCCESS
}));
dispatch(progressIndicatorActions.STOP_WORKING("toggleFavorite"));
- dispatch<any>(loadFavorites())
+ dispatch<any>(loadFavoritesTree())
})
.catch((e: any) => {
dispatch(progressIndicatorActions.STOP_WORKING("toggleFavorite"));
const treePicker = getTreePicker(SIDE_PANEL_TREE)(getState().treePicker);
const node = treePicker ? getNode(projectUuid)(treePicker) : undefined;
if (projectUuid === SidePanelTreeCategory.PUBLIC_FAVORITES) {
- await dispatch<any>(loadPublicFavorites);
+ await dispatch<any>(loadPublicFavoritesTree());
} else if (projectUuid === SidePanelTreeCategory.FAVORITES) {
- await dispatch<any>(loadFavorites());
+ await dispatch<any>(loadFavoritesTree());
} else if (node || projectUuid !== '') {
await dispatch<any>(loadProject(projectUuid));
}
dispatch(resourcesActions.SET_RESOURCES(items));
};
-export const loadFavorites =()=> async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+export const loadFavoritesTree = () => async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
dispatch(treePickerActions.LOAD_TREE_PICKER_NODE({ id: SidePanelTreeCategory.FAVORITES, pickerId: SIDE_PANEL_TREE }));
const params = {
filters: new FilterBuilder()
- .addEqual("link_class", LinkClass.STAR)
+ .addEqual('link_class', LinkClass.STAR)
.addEqual('tail_uuid', getUserUuid(getState()))
.addEqual('tail_kind', ResourceKind.USER)
.getFilters(),
- order: new OrderBuilder<ProjectResource>()
- .addDesc('createdAt')
- .getOrder(),
- limit: 50
- }
+ order: new OrderBuilder<ProjectResource>().addDesc('createdAt').getOrder(),
+ limit: 50,
+ };
const { items } = await services.linkService.list(params);
- dispatch(treePickerActions.LOAD_TREE_PICKER_NODE_SUCCESS({
- id: SidePanelTreeCategory.FAVORITES,
- pickerId: SIDE_PANEL_TREE,
- nodes: items.map(item => initTreeNode({ id: item.headUuid, value: item })),
- }));
+ dispatch(
+ treePickerActions.LOAD_TREE_PICKER_NODE_SUCCESS({
+ id: SidePanelTreeCategory.FAVORITES,
+ pickerId: SIDE_PANEL_TREE,
+ nodes: items.map(item => initTreeNode({ id: item.headUuid, value: item })),
+ })
+ );
dispatch(resourcesActions.SET_RESOURCES(items));
};
-const loadPublicFavorites = async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+export const loadPublicFavoritesTree = () => async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
dispatch(treePickerActions.LOAD_TREE_PICKER_NODE({ id: SidePanelTreeCategory.PUBLIC_FAVORITES, pickerId: SIDE_PANEL_TREE }));
const uuidPrefix = getState().auth.config.uuidPrefix;
.addEqual('owner_uuid', publicProjectUuid)
.addIsA('head_uuid', typeFilters)
.getFilters(),
- order: new OrderBuilder<ProjectResource>()
- .addDesc('createdAt')
- .getOrder(),
- limit: TREE_NODE_LIMIT
+ order: new OrderBuilder<ProjectResource>().addDesc('createdAt').getOrder(),
+ limit: TREE_NODE_LIMIT,
};
const { items } = await services.linkService.list(params);
- dispatch(treePickerActions.LOAD_TREE_PICKER_NODE_SUCCESS({
- id: SidePanelTreeCategory.PUBLIC_FAVORITES,
- pickerId: SIDE_PANEL_TREE,
- nodes: items.map(item => initTreeNode({ id: item.headUuid, value: item })),
- }));
+ dispatch(
+ treePickerActions.LOAD_TREE_PICKER_NODE_SUCCESS({
+ id: SidePanelTreeCategory.PUBLIC_FAVORITES,
+ pickerId: SIDE_PANEL_TREE,
+ nodes: items.map(item => initTreeNode({ id: item.headUuid, value: item })),
+ })
+ );
dispatch(resourcesActions.SET_RESOURCES(items));
};