change icon's color when new notification #55
This commit is contained in:
parent
22b39b3c53
commit
06a9e4abff
|
@ -1,15 +1,18 @@
|
|||
import { Component, OnInit, Input } from '@angular/core';
|
||||
import { Component, OnInit, OnDestroy, Input } from '@angular/core';
|
||||
import { faAt, faUserPlus } from "@fortawesome/free-solid-svg-icons";
|
||||
import { faBell, faEnvelope, faUser, faStar } from "@fortawesome/free-regular-svg-icons";
|
||||
import { Subscription } from 'rxjs';
|
||||
|
||||
import { AccountWrapper } from '../../../models/account.models';
|
||||
import { UserNotificationServiceService, UserNotification } from '../../../services/user-notification-service.service';
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'app-manage-account',
|
||||
templateUrl: './manage-account.component.html',
|
||||
styleUrls: ['./manage-account.component.scss']
|
||||
})
|
||||
export class ManageAccountComponent implements OnInit {
|
||||
export class ManageAccountComponent implements OnInit, OnDestroy {
|
||||
faAt = faAt;
|
||||
faBell = faBell;
|
||||
faEnvelope = faEnvelope;
|
||||
|
@ -21,11 +24,38 @@ export class ManageAccountComponent implements OnInit {
|
|||
hasNotifications = false;
|
||||
hasMentions = false;
|
||||
|
||||
@Input() account: AccountWrapper;
|
||||
@Input('account')
|
||||
set account(acc: AccountWrapper) {
|
||||
console.warn('account');
|
||||
this._account = acc;
|
||||
this.checkNotifications();
|
||||
}
|
||||
get account(): AccountWrapper {
|
||||
return this._account;
|
||||
}
|
||||
|
||||
constructor() { }
|
||||
private userNotificationServiceSub: Subscription;
|
||||
private _account: AccountWrapper;
|
||||
|
||||
constructor(
|
||||
private readonly userNotificationService: UserNotificationServiceService) { }
|
||||
|
||||
ngOnInit() {
|
||||
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this.userNotificationServiceSub.unsubscribe();
|
||||
}
|
||||
|
||||
private checkNotifications(){
|
||||
this.userNotificationServiceSub = this.userNotificationService.userNotifications.subscribe((userNotifications: UserNotification[]) => {
|
||||
const userNotification = userNotifications.find(x => x.account.id === this.account.info.id);
|
||||
if(userNotification){
|
||||
this.hasNotifications = userNotification.hasNewNotifications;
|
||||
this.hasMentions = userNotification.hasNewMentions;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
loadSubPanel(subpanel: string): boolean {
|
||||
|
|
|
@ -27,7 +27,7 @@ export class UserNotificationServiceService {
|
|||
let promises: Promise<any>[] = [];
|
||||
|
||||
accounts.forEach(account => {
|
||||
let getNotificationPromise = this.mastodonService.getNotifications(account)
|
||||
let getNotificationPromise = this.mastodonService.getNotifications(account, null, null, null, 30)
|
||||
.then((notifications: Notification[]) => {
|
||||
this.processNotifications(account, notifications);
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue