|
|
@ -1,5 +1,5 @@ |
|
|
|
import { Injectable } from '@angular/core'; |
|
|
|
import { Injectable } from '@angular/core'; |
|
|
|
import { applyTransaction, ID, transaction } from '@datorama/akita'; |
|
|
|
import { applyTransaction, ID } from '@datorama/akita'; |
|
|
|
import { Observable } from 'rxjs'; |
|
|
|
import { Observable } from 'rxjs'; |
|
|
|
import { APIV3Service } from 'core-app/core/apiv3/api-v3.service'; |
|
|
|
import { APIV3Service } from 'core-app/core/apiv3/api-v3.service'; |
|
|
|
import { map, switchMap, tap } from 'rxjs/operators'; |
|
|
|
import { map, switchMap, tap } from 'rxjs/operators'; |
|
|
@ -36,7 +36,7 @@ export class InAppNotificationsService { |
|
|
|
(events) => { |
|
|
|
(events) => { |
|
|
|
applyTransaction(() => { |
|
|
|
applyTransaction(() => { |
|
|
|
this.store.set(events._embedded.elements); |
|
|
|
this.store.set(events._embedded.elements); |
|
|
|
this.store.update({ count: events.total, notShowing: events.total - events.count }); |
|
|
|
this.store.update({ notShowing: events.total - events.count }); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
}, |
|
|
|
(error) => { |
|
|
|
(error) => { |
|
|
@ -55,27 +55,17 @@ export class InAppNotificationsService { |
|
|
|
.unread({ pageSize: 0 }) |
|
|
|
.unread({ pageSize: 0 }) |
|
|
|
.pipe( |
|
|
|
.pipe( |
|
|
|
map((events) => events.total), |
|
|
|
map((events) => events.total), |
|
|
|
tap((count) => this.store.update({ count })), |
|
|
|
tap((unreadCount) => { |
|
|
|
|
|
|
|
this.store.update({ unreadCount }); |
|
|
|
|
|
|
|
}), |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@transaction() |
|
|
|
|
|
|
|
add(inAppNotification:InAppNotification):void { |
|
|
|
|
|
|
|
this.store.add(inAppNotification); |
|
|
|
|
|
|
|
this.store.update((state) => ({ ...state, count: state.count + 1 })); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
update(id:ID, inAppNotification:Partial<InAppNotification>):void { |
|
|
|
update(id:ID, inAppNotification:Partial<InAppNotification>):void { |
|
|
|
this.store.update(id, inAppNotification); |
|
|
|
this.store.update(id, inAppNotification); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@transaction() |
|
|
|
setActiveFacet(facet:string):void { |
|
|
|
remove(id:ID):void { |
|
|
|
|
|
|
|
this.store.remove(id); |
|
|
|
|
|
|
|
this.store.update((state) => ({ ...state, count: state.count + 1 })); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setActiveFacet(facet:string) { |
|
|
|
|
|
|
|
this.store.update((state) => ({ ...state, activeFacet: facet })); |
|
|
|
this.store.update((state) => ({ ...state, activeFacet: facet })); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -89,7 +79,7 @@ export class InAppNotificationsService { |
|
|
|
.subscribe(() => { |
|
|
|
.subscribe(() => { |
|
|
|
applyTransaction(() => { |
|
|
|
applyTransaction(() => { |
|
|
|
this.store.update(null, { readIAN: true }); |
|
|
|
this.store.update(null, { readIAN: true }); |
|
|
|
this.store.update({ count: 0 }); |
|
|
|
this.store.update({ unreadCount: 0 }); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
@ -100,7 +90,7 @@ export class InAppNotificationsService { |
|
|
|
return href && HalResource.matchFromLink(href, 'work_packages'); |
|
|
|
return href && HalResource.matchFromLink(href, 'work_packages'); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
this |
|
|
|
void this |
|
|
|
.apiV3Service |
|
|
|
.apiV3Service |
|
|
|
.work_packages |
|
|
|
.work_packages |
|
|
|
.requireAll(_.compact(wpIds)); |
|
|
|
.requireAll(_.compact(wpIds)); |
|
|
@ -140,7 +130,7 @@ export class InAppNotificationsService { |
|
|
|
}, |
|
|
|
}, |
|
|
|
); |
|
|
|
); |
|
|
|
this.store.update( |
|
|
|
this.store.update( |
|
|
|
({ count }) => ({ count: count - 1 }), |
|
|
|
({ unreadCount }) => ({ unreadCount: unreadCount - 1 }), |
|
|
|
); |
|
|
|
); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|