diff --git a/src/app/budgets/add-edit-budget/add-edit-budget.component.ts b/src/app/budgets/add-edit-budget/add-edit-budget.component.ts index 957e5ab..6fd7510 100644 --- a/src/app/budgets/add-edit-budget/add-edit-budget.component.ts +++ b/src/app/budgets/add-edit-budget/add-edit-budget.component.ts @@ -57,7 +57,7 @@ export class AddEditBudgetComponent { // TODO: Implement a search box with suggestions to add users searchUsers(username: string) { - this.twigsService.getUsersByUsername(username).subscribe(users => { + this.twigsService.getUsersByUsername(username).then(users => { this.searchedUsers = users; }); } diff --git a/src/app/shared/twigs.http.service.ts b/src/app/shared/twigs.http.service.ts index 6ca3898..c03cba8 100644 --- a/src/app/shared/twigs.http.service.ts +++ b/src/app/shared/twigs.http.service.ts @@ -302,10 +302,8 @@ export class TwigsHttpService implements TwigsService { return this.request(url, HttpMethod.GET) } - getUsersByUsername(username: string): Observable { - return new Observable(subscriber => { - subscriber.error("Not yet implemented") - }); + getUsersByUsername(username: string): Promise { + return Promise.reject("Not yet implemented") } private async request(url: URL, method: HttpMethod, body?: any): Promise { diff --git a/src/app/shared/twigs.local.service.ts b/src/app/shared/twigs.local.service.ts index 276cc26..fc6e18d 100644 --- a/src/app/shared/twigs.local.service.ts +++ b/src/app/shared/twigs.local.service.ts @@ -311,15 +311,11 @@ export class TwigsLocalService implements TwigsService { // Users getProfile(id: string): Promise { - return new Promise((resolve, reject) => { - reject("Not yet implemented") - }); + return Promise.reject("Not yet implemented"); } - getUsersByUsername(username: string): Observable { - return new Observable(subscriber => { - subscriber.next(this.users.filter(user => user.username.indexOf(username) > -1 )); - }); + getUsersByUsername(username: string): Promise { + return Promise.resolve(this.users.filter(user => user.username.indexOf(username) > -1)) } private updateValues(old: object, changes: object, keys: string[]) { diff --git a/src/app/shared/twigs.service.ts b/src/app/shared/twigs.service.ts index 554c5b8..4804ba6 100644 --- a/src/app/shared/twigs.service.ts +++ b/src/app/shared/twigs.service.ts @@ -55,7 +55,7 @@ export interface TwigsService { deleteTransaction(id: string): Observable; getProfile(id: string): Promise; - getUsersByUsername(username: string): Observable; + getUsersByUsername(username: string): Promise; } export let TWIGS_SERVICE = new InjectionToken('twigs.service');