import { Injectable } from "@angular/core" ; import * as _ from "lodash" ; import { SyncedActivityModel } from "@elevate/shared/models" ; import { BaseDao } from "../base.dao" ; import { StorageLocationModel } from "../../data-store/storage-location.model" ; @ Injectable ( ) export class ActivityDao extends BaseDao < SyncedActivityModel > { public static readonly STORAGE_LOCATION : StorageLocationModel = new StorageLocationModel ( "syncedActivities" ) ; public static readonly DEFAULT_STORAGE_VALUE : SyncedActivityModel [ ] = [ ] ; public getStorageLocation ( ) { return ActivityDao . STORAGE_LOCATION ; } public getDefaultStorageValue ( ) { return ActivityDao . DEFAULT_STORAGE_VALUE ; } param { number [ ] } activitiesToDelete returns { Promise < SyncedActivityModel [ ] > } public removeByIds ( activitiesToDelete ) { return this . fetch ( ) . then ( ( models ) => { const modelsToBeSaved = _ . filter ( models , ( syncedActivityModel ) => { return ( _ . indexOf ( activitiesToDelete , syncedActivityModel . id ) === - 1 ) ; } ) ; return ( < Promise < SyncedActivityModel [ ] > > this . save ( modelsToBeSaved ) ) ; } ) ; } }