1
0
mirror of https://github.com/NicolasConstant/sengi synced 2025-02-08 16:08:40 +01:00

added move notification support

This commit is contained in:
Nicolas Constant 2020-12-21 23:12:47 -05:00
parent 8c76056747
commit 8b849a6650
No known key found for this signature in database
GPG Key ID: 1E9F677FB01A5688
9 changed files with 31 additions and 8 deletions

View File

@ -83,7 +83,7 @@ export class MentionsComponent extends TimelineBase {
protected getNextStatuses(): Promise<Status[]> {
console.warn('MENTIONS get next status');
return this.mastodonService.getNotifications(this.account, ['follow', 'favourite', 'reblog', 'poll'], this.lastId)
return this.mastodonService.getNotifications(this.account, ['follow', 'favourite', 'reblog', 'poll', 'move'], this.lastId)
.then((result: Notification[]) => {
const statuses = result.map(x => x.status);

View File

@ -50,6 +50,25 @@
</a>
</div>
<div *ngIf="notification.type === 'move'">
<div class="stream__notification--icon" title="{{notification.account.acct}}">
<fa-icon class="followed" [icon]="faTruckMoving"></fa-icon>
</div>
<div class="stream__notification--label">
<a href class="stream__link" title="{{notification.account.acct}}"
(click)="openAccount(notification.account)" (auxclick)="openUrl(notification.account.url)"
innerHTML="{{ notification.account | accountEmoji }}"></a>
migrated to
</div>
<a href (click)="openAccount(notification.target)" (auxclick)="openUrl(notification.target.url)"
class="follow-account" title="{{notification.target.acct}}">
<img class="follow-account__avatar" src="{{ notification.target.avatar }}" />
<span class="follow-account__display-name" innerHTML="{{ notification.target | accountEmoji }}"></span>
<span class="follow-account__acct">@{{ notification.target.acct }}</span>
</a>
</div>
<app-status *ngIf="notification.status && notification.type !== 'mention'" class="stream__status" [statusWrapper]="notification.status"
[notificationAccount]="notification.account" [notificationType]="notification.type"
(browseAccountEvent)="browseAccount($event)" (browseHashtagEvent)="browseHashtag($event)"

View File

@ -1,5 +1,5 @@
import { Component, Input } from '@angular/core';
import { faUserPlus, faUserClock, faCheck, faTimes } from "@fortawesome/free-solid-svg-icons";
import { faUserPlus, faUserClock, faCheck, faTimes, faTruckMoving } from "@fortawesome/free-solid-svg-icons";
import { NotificationWrapper } from '../notifications.component';
import { ToolsService } from '../../../../../services/tools.service';
@ -18,6 +18,7 @@ export class NotificationComponent extends BrowseBase {
faUserClock = faUserClock;
faCheck = faCheck;
faTimes = faTimes;
faTruckMoving = faTruckMoving;
@Input() notification: NotificationWrapper;

View File

@ -156,6 +156,7 @@ export class NotificationWrapper {
break;
}
this.account = notification.account;
this.target = notification.target;
this.wrapperId = `${this.type}-${notification.id}`;
this.notification = notification;
this.provider = provider;
@ -165,6 +166,7 @@ export class NotificationWrapper {
notification: Notification;
wrapperId: string;
account: Account;
target: Account;
status: StatusWrapper;
type: 'mention' | 'reblog' | 'favourite' | 'follow' | 'poll' | 'follow_request';
type: 'mention' | 'reblog' | 'favourite' | 'follow' | 'poll' | 'follow_request' | 'move';
}

View File

@ -237,7 +237,7 @@ export class StreamNotificationsComponent extends BrowseBase {
this.isMentionsLoading = true;
this.mastodonService.getNotifications(this.account, ['follow', 'favourite', 'reblog', 'poll', 'follow_request'], this.lastMentionId)
this.mastodonService.getNotifications(this.account, ['follow', 'favourite', 'reblog', 'poll', 'follow_request', 'move'], this.lastMentionId)
.then((result: Notification[]) => {
if (result.length === 0) {
this.mentionsMaxReached = true;

View File

@ -252,7 +252,7 @@ export class MastodonWrapperService {
});
}
getNotifications(account: AccountInfo, excludeTypes: ('follow' | 'favourite' | 'reblog' | 'mention' | 'poll' | 'follow_request')[] = null, maxId: string = null, sinceId: string = null, limit: number = 15): Promise<Notification[]> {
getNotifications(account: AccountInfo, excludeTypes: ('follow' | 'favourite' | 'reblog' | 'mention' | 'poll' | 'follow_request' | 'move')[] = null, maxId: string = null, sinceId: string = null, limit: number = 15): Promise<Notification[]> {
return this.refreshAccountIfNeeded(account)
.then((refreshedAccount: AccountInfo) => {
return this.mastodonService.getNotifications(refreshedAccount, excludeTypes, maxId, sinceId, limit);

View File

@ -311,7 +311,7 @@ export class MastodonService {
return this.httpClient.put<Attachment>(route, input, { headers: headers }).toPromise();
}
getNotifications(account: AccountInfo, excludeTypes: ('follow' | 'favourite' | 'reblog' | 'mention' | 'poll' | 'follow_request')[] = null, maxId: string = null, sinceId: string = null, limit: number = 15): Promise<Notification[]> {
getNotifications(account: AccountInfo, excludeTypes: ('follow' | 'favourite' | 'reblog' | 'mention' | 'poll' | 'follow_request' | 'move')[] = null, maxId: string = null, sinceId: string = null, limit: number = 15): Promise<Notification[]> {
let route = `https://${account.instance}${this.apiRoutes.getNotifications}?limit=${limit}`;
if (maxId) {

View File

@ -130,10 +130,11 @@ export interface Mention {
export interface Notification {
id: string;
type: 'mention' | 'reblog' | 'favourite' | 'follow' | 'poll' | 'follow_request';
type: 'mention' | 'reblog' | 'favourite' | 'follow' | 'poll' | 'follow_request' | 'move';
created_at: string;
account: Account;
status?: Status;
target?: Account; //for move Pleroma's notification
}
export interface Relationship {

View File

@ -58,7 +58,7 @@ export class UserNotificationService {
}
private startFetchingNotifications(account: AccountInfo) {
let getMentionsPromise = this.mastodonService.getNotifications(account, ['favourite', 'follow', 'reblog', 'poll', 'follow_request'], null, null, 10)
let getMentionsPromise = this.mastodonService.getNotifications(account, ['favourite', 'follow', 'reblog', 'poll', 'follow_request', 'move'], null, null, 10)
.then((notifications: Notification[]) => {
this.processMentionsAndNotifications(account, notifications, NotificationTypeEnum.UserMention);
})