diff --git a/projects/components/src/lib/core/notifications/notifications.component.html b/projects/components/src/lib/core/notifications/notifications.component.html index b36d691c..663406a1 100644 --- a/projects/components/src/lib/core/notifications/notifications.component.html +++ b/projects/components/src/lib/core/notifications/notifications.component.html @@ -1,6 +1,6 @@
- +
{{notification.title}} diff --git a/projects/components/src/lib/core/notifications/notifications.component.scss b/projects/components/src/lib/core/notifications/notifications.component.scss index 3e0e7307..e65f77c2 100644 --- a/projects/components/src/lib/core/notifications/notifications.component.scss +++ b/projects/components/src/lib/core/notifications/notifications.component.scss @@ -7,7 +7,6 @@ padding: 0.5rem; } .info { - flex: 0; padding: 0.5rem; } } diff --git a/projects/components/src/lib/core/notifications/notifications.module.ts b/projects/components/src/lib/core/notifications/notifications.module.ts index 1d88fa8c..326e711a 100644 --- a/projects/components/src/lib/core/notifications/notifications.module.ts +++ b/projects/components/src/lib/core/notifications/notifications.module.ts @@ -6,6 +6,7 @@ import { MaterialModule } from '../../shared/modules/material.module'; @NgModule({ declarations: [NotificationsComponent], + exports: [NotificationsComponent], imports: [CommonModule, MaterialModule] }) export class NotificationsModule {} diff --git a/projects/components/src/public-api.ts b/projects/components/src/public-api.ts index c0464fd4..56d973af 100644 --- a/projects/components/src/public-api.ts +++ b/projects/components/src/public-api.ts @@ -30,3 +30,5 @@ export * from './lib/activity-time-chart/activity-time-chart.module'; export * from './lib/clan-active-population/clan-active-population.module'; export * from './lib/member-callout/member-callout.module'; export * from './lib/member-callout/member-callout.component'; +export * from './lib/core/notifications/notifications.module'; +export * from './lib/core/notifications/notifications.component'; diff --git a/projects/data/src/lib/clan-db/clan-member-activity/clan-member-activity.service.ts b/projects/data/src/lib/clan-db/clan-member-activity/clan-member-activity.service.ts index 1589c77c..68b18288 100644 --- a/projects/data/src/lib/clan-db/clan-member-activity/clan-member-activity.service.ts +++ b/projects/data/src/lib/clan-db/clan-member-activity/clan-member-activity.service.ts @@ -70,7 +70,9 @@ export class ClanMemberActivityService extends BaseMemberActivityService { }, 3), tap((x) => { complete++; - progress(complete); + if (progress) { + progress(complete); + } }), toArray() ); diff --git a/src/app/clan/clan.component.html b/src/app/clan/clan.component.html index fdce1b11..509186e7 100644 --- a/src/app/clan/clan.component.html +++ b/src/app/clan/clan.component.html @@ -1,4 +1,5 @@
+ @@ -6,7 +7,8 @@ - -
- -
+ + +
+ +
diff --git a/src/app/clan/clan.component.ts b/src/app/clan/clan.component.ts index da4ea6ba..d8d480e0 100644 --- a/src/app/clan/clan.component.ts +++ b/src/app/clan/clan.component.ts @@ -16,6 +16,7 @@ import * as memberProfileActions from './store/member-profiles/member-profiles.a import * as routerStore from '../root-store/router/router.selectors'; import { actionSettingsChangeClan, actionSettingsChangeTheme } from '../root-store/settings/settings.actions'; +import { getAllNotifications } from './store/notifications/notifications.selectors'; // import { Clan } from 'bungie-parse'; import { Store, select } from '@ngrx/store'; @@ -51,6 +52,7 @@ export class ClanComponent implements OnInit, OnDestroy { clanId = this.activatedRoute.params.pipe(map((x) => x.id, distinctUntilChanged())); clanDetails$: Observable = this.store.pipe(select(clanDetailSelectors.getClanDetail)); + notifications$ = this.store.pipe(select(getAllNotifications)); private destroyed = new Subject(); ngOnInit() {} diff --git a/src/app/clan/clan.module.ts b/src/app/clan/clan.module.ts index e56946ac..f517c425 100644 --- a/src/app/clan/clan.module.ts +++ b/src/app/clan/clan.module.ts @@ -18,6 +18,7 @@ import { ClanDbModule } from '@destiny/data'; import { AboutModule } from '../about/about.module'; import { MatDialogModule } from '@angular/material/dialog'; import { DirectivesModule } from '../shared/directives/directives.module'; +import { NotificationsModule } from '@destiny/components'; @NgModule({ declarations: [ClanComponent], @@ -33,6 +34,7 @@ import { DirectivesModule } from '../shared/directives/directives.module'; MatDialogModule, AboutModule, DirectivesModule, + NotificationsModule, // ClanRosterModule, // BungieParseModule, StoreModule.forFeature('clan', clanState.reducers), diff --git a/src/app/clan/store/member-activities/member-activities.effects.ts b/src/app/clan/store/member-activities/member-activities.effects.ts index e9b6694a..c03aea21 100644 --- a/src/app/clan/store/member-activities/member-activities.effects.ts +++ b/src/app/clan/store/member-activities/member-activities.effects.ts @@ -37,6 +37,7 @@ import { Observable } from 'rxjs'; import { loadMemberProfileSuccess } from '../member-profiles/member-profiles.actions'; import { getAllMembers, getMemberProfileEntities } from '../member-profiles/member-profiles.selectors'; import { nowPlusMinutes } from 'projects/data/src/lib/utility/date-utils'; +import { addNotification, removeNotification, updateNotification } from '../notifications/notifications.actions'; @Injectable() export class MemberActivityEffects { @@ -86,9 +87,31 @@ export class MemberActivityEffects { ofType(memberActivityActions.refreshMemberActivities), withLatestFrom(this.store.select(clanIdSelectors.getClanIdState)), switchMap(([action, clanId]) => { - return this.memberActivityService.updateAllActivityCache(clanId, action.member).pipe( + this.store.dispatch( + addNotification({ + notification: { id: 'memberActivity', title: 'Updating Member Activities', data: { progress: 0 } } + }) + ); + const progress = (progressCount) => { + this.store.dispatch( + updateNotification({ + notification: { + id: 'memberActivity', + title: 'Updating Member Activities', + data: { progress: progressCount } + } + }) + ); + }; + + return this.memberActivityService.updateAllActivityCache(clanId, action.member, progress).pipe( switchMap(() => { window.localStorage.setItem('lastActivityUpdate-' + clanId, new Date().toString()); + this.store.dispatch( + removeNotification({ + notification: { id: 'memberActivity', title: 'Updating Member Activities', data: { progress: 100 } } + }) + ); return this.memberActivityService.getAllActivitiesFromCache2(clanId, action.member); }) ); diff --git a/src/app/clan/store/member-profiles/member-profiles.effects.ts b/src/app/clan/store/member-profiles/member-profiles.effects.ts index d7bbd646..cb8bb705 100644 --- a/src/app/clan/store/member-profiles/member-profiles.effects.ts +++ b/src/app/clan/store/member-profiles/member-profiles.effects.ts @@ -58,7 +58,9 @@ export class MemberProfileEffects { switchMap(({ clanId, clanMembers }) => { // clanMembers = clanMembers.slice(0, 10); let progress = 0; - this.store.dispatch(addNotification({ notification: { id: 'memberProfile', data: { progress } } })); + this.store.dispatch( + addNotification({ notification: { id: 'memberProfile', title: 'Updating Profiles', data: { progress } } }) + ); return this.profileService.getSerializedProfiles(clanId.toString(), clanMembers).pipe( // tap((x) => { @@ -71,13 +73,19 @@ export class MemberProfileEffects { */ mergeMap((members) => { progress += members.length; - this.store.dispatch(updateNotification({ notification: { id: 'memberProfile', data: { progress } } })); + this.store.dispatch( + updateNotification({ + notification: { id: 'memberProfile', title: 'Updating Profiles', data: { progress } } + }) + ); this.store.dispatch(memberProfileActions.loadMemberProfiles({ memberProfiles: members })); return members; }), toArray(), map((x) => { - this.store.dispatch(removeNotification({ notification: { id: 'memberProfile', data: 'done' } })); + this.store.dispatch( + removeNotification({ notification: { id: 'memberProfile', title: 'Updating Profiles', data: 'done' } }) + ); return memberProfileActions.loadMemberProfileSuccess(); }) ); diff --git a/src/app/clan/store/notifications/notifications.selectors.ts b/src/app/clan/store/notifications/notifications.selectors.ts index 88bbc61f..e967f18e 100644 --- a/src/app/clan/store/notifications/notifications.selectors.ts +++ b/src/app/clan/store/notifications/notifications.selectors.ts @@ -7,8 +7,8 @@ import { NotificationState, NotificationAdapter } from './notifications.state'; export const getNotificationEntityState = createSelector(getClanState, (state) => state.notifications); export const { - selectIds: getMemberIds, - selectEntities: getMemberProfileEntities, - selectAll: getAllMembers, - selectTotal: getTotalMembers + selectIds: getNotificationIds, + selectEntities: getNotificationEntities, + selectAll: getAllNotifications, + selectTotal: getTotalNotificaitons } = NotificationAdapter.getSelectors(getNotificationEntityState); diff --git a/src/app/clan/store/notifications/notifications.state.ts b/src/app/clan/store/notifications/notifications.state.ts index 993cfb88..4f179d7e 100644 --- a/src/app/clan/store/notifications/notifications.state.ts +++ b/src/app/clan/store/notifications/notifications.state.ts @@ -1,6 +1,7 @@ import { createEntityAdapter, EntityAdapter, EntityState } from '@ngrx/entity'; export interface Notification { id: string; + title: string; data: any; }