mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-31 17:38:28 +00:00
changes after review
This commit is contained in:
@@ -23,14 +23,10 @@ import { RepoClient } from './../../repo-client';
|
|||||||
export class FavoritesApi extends RepoApi {
|
export class FavoritesApi extends RepoApi {
|
||||||
|
|
||||||
addFavorite(api: RepoClient, nodeType: string, name: string): Promise<any> {
|
addFavorite(api: RepoClient, nodeType: string, name: string): Promise<any> {
|
||||||
let data = [];
|
|
||||||
|
|
||||||
return api.nodes.getNodeByPath(name)
|
return api.nodes.getNodeByPath(name)
|
||||||
.then((response: any): string => {
|
.then((response) => {
|
||||||
return response.data.entry.id;
|
const { id } = response.data.entry;
|
||||||
})
|
return ([{
|
||||||
.then((id: string) => {
|
|
||||||
data = data.concat([{
|
|
||||||
target: {
|
target: {
|
||||||
[nodeType]: {
|
[nodeType]: {
|
||||||
guid: id
|
guid: id
|
||||||
@@ -38,7 +34,7 @@ export class FavoritesApi extends RepoApi {
|
|||||||
}
|
}
|
||||||
}]);
|
}]);
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then((data) => {
|
||||||
return this.post(`/people/-me-/favorites`, { data });
|
return this.post(`/people/-me-/favorites`, { data });
|
||||||
})
|
})
|
||||||
.catch(this.handleError);
|
.catch(this.handleError);
|
||||||
@@ -46,8 +42,8 @@ export class FavoritesApi extends RepoApi {
|
|||||||
|
|
||||||
getFavorite(api: RepoClient, name: string): Promise<any> {
|
getFavorite(api: RepoClient, name: string): Promise<any> {
|
||||||
return api.nodes.getNodeByPath(name)
|
return api.nodes.getNodeByPath(name)
|
||||||
.then((resp: any) => {
|
.then((response) => {
|
||||||
const { id } = resp.data.entry;
|
const { id } = response.data.entry;
|
||||||
return this.get(`/people/-me-/favorites/${id}`);
|
return this.get(`/people/-me-/favorites/${id}`);
|
||||||
})
|
})
|
||||||
.catch((response) => Promise.resolve(response));
|
.catch((response) => Promise.resolve(response));
|
||||||
@@ -55,10 +51,8 @@ export class FavoritesApi extends RepoApi {
|
|||||||
|
|
||||||
removeFavorite(api: RepoClient, nodeType: string, name: string): Promise<any> {
|
removeFavorite(api: RepoClient, nodeType: string, name: string): Promise<any> {
|
||||||
return api.nodes.getNodeByPath(name)
|
return api.nodes.getNodeByPath(name)
|
||||||
.then((response: any): string => {
|
.then((response) => {
|
||||||
return response.data.entry.id;
|
const { id } = response.data.entry;
|
||||||
})
|
|
||||||
.then((id: string) => {
|
|
||||||
return this.delete(`/people/-me-/favorites/${id}`);
|
return this.delete(`/people/-me-/favorites/${id}`);
|
||||||
})
|
})
|
||||||
.catch(this.handleError);
|
.catch(this.handleError);
|
||||||
|
Reference in New Issue
Block a user