starting notification retrieval
This commit is contained in:
parent
7a001a7f67
commit
756deb56f4
|
@ -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({
|
@Component({
|
||||||
selector: 'app-stream-notifications',
|
selector: 'app-stream-notifications',
|
||||||
|
@ -8,9 +14,43 @@ import { Component, OnInit } from '@angular/core';
|
||||||
export class StreamNotificationsComponent implements OnInit {
|
export class StreamNotificationsComponent implements OnInit {
|
||||||
displayingAll = true;
|
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() {
|
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 {
|
select(value: 'all' | 'mentions'): boolean {
|
||||||
|
@ -21,4 +61,8 @@ export class StreamNotificationsComponent implements OnInit {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onScroll() {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ import { AppInfo, RegisteredAppsStateModel } from '../states/registered-apps.sta
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
})
|
})
|
||||||
export class ToolsService {
|
export class ToolsService {
|
||||||
private accountAvatar: { [id: string]: string; } = {};
|
private accountAvatar: { [id: string]: string; } = {};
|
||||||
private instanceInfos: { [id: string]: InstanceInfo } = {};
|
private instanceInfos: { [id: string]: InstanceInfo } = {};
|
||||||
|
|
||||||
|
@ -68,6 +68,11 @@ export class ToolsService {
|
||||||
return regAccounts.filter(x => x.isSelected);
|
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 {
|
getAccountSettings(account: AccountInfo): AccountSettings {
|
||||||
let accountsSettings = <AccountSettings[]>this.store.snapshot().globalsettings.settings.accountSettings;
|
let accountsSettings = <AccountSettings[]>this.store.snapshot().globalsettings.settings.accountSettings;
|
||||||
let accountSettings = accountsSettings.find(x => x.accountId === account.id);
|
let accountSettings = accountsSettings.find(x => x.accountId === account.id);
|
||||||
|
@ -118,7 +123,7 @@ export class ToolsService {
|
||||||
);
|
);
|
||||||
return foundAccount;
|
return foundAccount;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getStatusUsableByAccount(account: AccountInfo, originalStatus: StatusWrapper): Promise<Status> {
|
getStatusUsableByAccount(account: AccountInfo, originalStatus: StatusWrapper): Promise<Status> {
|
||||||
const isProvider = originalStatus.provider.id === account.id;
|
const isProvider = originalStatus.provider.id === account.id;
|
||||||
|
|
Loading…
Reference in New Issue