diff --git a/package.json b/package.json index 628b71e0..2d308824 100755 --- a/package.json +++ b/package.json @@ -48,9 +48,9 @@ "@angular/platform-browser": "4.3.0", "@angular/platform-browser-dynamic": "4.3.0", "@angular/router": "4.3.0", - "angularfire2": "4.0.0-rc.1", + "angularfire2": "5.0.0-rc.3", "core-js": "2.4.1", - "firebase": "4.1.3", + "firebase": "4.6.0", "reflect-metadata": "0.1.10", "rxjs": "5.4.2", "tslib": "1.7.1", diff --git a/src/health/shared/services/meals/meals.service.ts b/src/health/shared/services/meals/meals.service.ts index f9209fdf..82a3dc19 100644 --- a/src/health/shared/services/meals/meals.service.ts +++ b/src/health/shared/services/meals/meals.service.ts @@ -22,8 +22,16 @@ export interface Meal { @Injectable() export class MealsService { - meals$: Observable = this.db.list(`meals/${this.uid}`) - .do(next => this.store.set('meals', next)); + meals$: Observable = this.db.list(`meals/${this.uid}`) + .snapshotChanges() + .map(actions => { + return actions.map(action => { + const data = action.payload.val(); + const $key = action.payload.key; + return {$key, ...data}; + }); + }) + .do(next => this.store.set('meals', next)); constructor( private store: Store, diff --git a/src/health/shared/services/schedule/schedule.service.ts b/src/health/shared/services/schedule/schedule.service.ts index 601bc21f..87eeee01 100644 --- a/src/health/shared/services/schedule/schedule.service.ts +++ b/src/health/shared/services/schedule/schedule.service.ts @@ -135,13 +135,10 @@ export class ScheduleService { } private getSchedule(startAt: number, endAt: number) { - return this.db.list(`schedule/${this.uid}`, { - query: { - orderByChild: 'timestamp', - startAt, - endAt - } - }); + return this.db.list(`schedule/${this.uid}`, + ref => ref.orderByChild('timestamp') + .startAt(startAt) + .endAt(endAt)).valueChanges(); } } \ No newline at end of file diff --git a/src/health/shared/services/workouts/workouts.service.ts b/src/health/shared/services/workouts/workouts.service.ts index 27143de6..32ebbe16 100644 --- a/src/health/shared/services/workouts/workouts.service.ts +++ b/src/health/shared/services/workouts/workouts.service.ts @@ -24,8 +24,16 @@ export interface Workout { @Injectable() export class WorkoutsService { - workouts$: Observable = this.db.list(`workouts/${this.uid}`) - .do(next => this.store.set('workouts', next)); + workouts$: Observable = this.db.list(`workouts/${this.uid}`) + .snapshotChanges() + .map(actions => { + return actions.map(action => { + const data = action.payload.val(); + const $key = action.payload.key; + return {$key, ...data}; + }); + }) + .do(next => this.store.set('workouts', next)); constructor( private store: Store,