starting notification retrieval

This commit is contained in:
Nicolas Constant 2019-11-17 00:57:58 -05:00
parent 7a001a7f67
commit 756deb56f4
No known key found for this signature in database
GPG Key ID: 1E9F677FB01A5688
2 changed files with 53 additions and 4 deletions

View File

@ -1,4 +1,10 @@
import { Component, OnInit } from '@angular/core';
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
import { Observable } from 'rxjs';
import { Notification } from '../../../services/models/mastodon.interfaces';
import { StreamElement } from '../../../states/streams.state';
import { OpenThreadEvent, ToolsService } from '../../../services/tools.service';
import { MastodonService } from '../../../services/mastodon.service';
@Component({
selector: 'app-stream-notifications',
@ -8,9 +14,43 @@ import { Component, OnInit } from '@angular/core';
export class StreamNotificationsComponent implements OnInit {
displayingAll = true;
constructor() { }
notifications: Notification[] = [];
mentions: Notification[] = [];
@Input() streamElement: StreamElement;
@Input() goToTop: Observable<void>;
@Output() browseAccountEvent = new EventEmitter<string>();
@Output() browseHashtagEvent = new EventEmitter<string>();
@Output() browseThreadEvent = new EventEmitter<OpenThreadEvent>();
constructor(
private readonly mastodonService: MastodonService,
private readonly toolsService: ToolsService) { }
ngOnInit() {
this.loadNotifications();
}
loadNotifications(): any {
const account = this.toolsService.getAccountById(this.streamElement.accountId);
let getMentionsPromise = this.mastodonService.getNotifications(account, ['favourite', 'follow', 'reblog', 'poll'], null, null, 10)
.then((notifications: Notification[]) => {
this.mentions = notifications;
})
.catch(err => {
});
let getNotificationPromise = this.mastodonService.getNotifications(account, null, null, null, 10)
.then((notifications: Notification[]) => {
this.notifications = notifications;
})
.catch(err => {
});
throw new Error("Method not implemented.");
}
select(value: 'all' | 'mentions'): boolean {
@ -21,4 +61,8 @@ export class StreamNotificationsComponent implements OnInit {
}
return false;
}
onScroll() {
}
}

View File

@ -68,6 +68,11 @@ export class ToolsService {
return regAccounts.filter(x => x.isSelected);
}
getAccountById(accountId: string): AccountInfo {
let regAccounts = <AccountInfo[]>this.store.snapshot().registeredaccounts.accounts;
return regAccounts.find(x => x.id === accountId);
}
getAccountSettings(account: AccountInfo): AccountSettings {
let accountsSettings = <AccountSettings[]>this.store.snapshot().globalsettings.settings.accountSettings;
let accountSettings = accountsSettings.find(x => x.accountId === account.id);