Merge pull request #328 from NicolasConstant/develop

0.33.0 PR
This commit is contained in:
Nicolas Constant 2020-10-06 01:39:01 +02:00 committed by GitHub
commit 7d42737c27
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 189 additions and 20 deletions

View File

@ -1,15 +1,28 @@
const { join } = require("path");
const { app, Menu, MenuItem, BrowserWindow, shell } = require("electron");
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let win;
const globalAny = global;
if (process.env.NODE_ENV !== 'development') {
globalAny.__static = require('path').join(__dirname, '/assets/icons').replace(/\\/g, '\\\\');
}
function createWindow() {
// Create the browser window.
// Set icon
let icon = join(globalAny.__static, '/png/512x512.png');
if (process.platform === "win32") {
icon = join(globalAny.__static, '/win/icon.ico');
}
// Create the browser window
win = new BrowserWindow({
width: 377,
height: 800,
title: "Sengi",
icon: icon,
backgroundColor: "#131925",
useContentSize: true,
webPreferences: {

View File

@ -1,6 +1,6 @@
{
"name": "sengi",
"version": "0.32.0",
"version": "0.33.0",
"license": "AGPL-3.0-or-later",
"main": "main-electron.js",
"description": "A multi-account desktop client for Mastodon and Pleroma",

View File

@ -1,4 +1,35 @@
<div class="notification">
<div *ngIf="notification.type === 'follow_request' && !followRequestProcessed">
<div class="stream__notification--icon" title="{{notification.account.acct}}">
<fa-icon class="followed" [icon]="faUserClock"></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>
submitted a follow request
</div>
<a href (click)="openAccount(notification.account)" (auxclick)="openUrl(notification.account.url)"
class="follow-account" title="{{notification.account.acct}}">
<img class="follow-account__avatar" src="{{ notification.account.avatar }}" />
<span class="follow-account__display-name" innerHTML="{{ notification.account | accountEmoji }}"></span>
<span class="follow-account__acct">@{{ notification.account.acct }}</span>
</a>
<div class="follow_request">
<a href title="Authorize" class="follow_request__link follow_request__link--check"
(click)="acceptFollowRequest()">
<fa-icon class="follow_request__icon" [icon]="faCheck"></fa-icon>
</a>
<a href title="Reject" class="follow_request__link follow_request__link--cross"
(click)="refuseFollowRequest()">
<fa-icon class="follow_request__icon" [icon]="faTimes"></fa-icon>
</a>
</div>
</div>
<div *ngIf="notification.type === 'follow'">
<div class="stream__notification--icon" title="{{notification.account.acct}}">
<fa-icon class="followed" [icon]="faUserPlus"></fa-icon>

View File

@ -46,6 +46,7 @@
color: $boost-color;
}
$acccount-info-left: 70px;
.follow-account {
padding: 5px;
height: 60px;
@ -62,8 +63,7 @@
height: 45px;
border-radius: 2px;
}
$acccount-info-left: 70px;
&__display-name {
position: absolute;
top: 7px;
@ -81,5 +81,44 @@
left: $acccount-info-left;
font-size: 13px;
color: $status-links-color;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
width: calc(100% - #{$acccount-info-left});
}
}
.follow_request {
width: calc(100% - #{$acccount-info-left});
margin-left: $acccount-info-left;
&__link {
display: inline-block;
width: calc(50%);
padding: 2px;
text-align: center;
color: rgb(182, 182, 182);
transition: all .2s;
// outline: 1px dotted greenyellow;
&--check {
&:hover {
color: greenyellow;
}
}
&--cross {
&:hover {
color: orangered;
}
}
}
&__icon {
text-align: center;
}
}

View File

@ -1,22 +1,30 @@
import { Component, Input } from '@angular/core';
import { faUserPlus } from "@fortawesome/free-solid-svg-icons";
import { faUserPlus, faUserClock, faCheck, faTimes } from "@fortawesome/free-solid-svg-icons";
import { NotificationWrapper } from '../notifications.component';
import { ToolsService } from '../../../../../services/tools.service';
import { Account } from '../../../../../services/models/mastodon.interfaces';
import { BrowseBase } from '../../../../../components/common/browse-base';
import { MastodonWrapperService } from '../../../../../services/mastodon-wrapper.service';
import { NotificationService } from '../../../../../services/notification.service';
@Component({
selector: 'app-notification',
templateUrl: './notification.component.html',
styleUrls: ['./notification.component.scss']
})
export class NotificationComponent extends BrowseBase {
export class NotificationComponent extends BrowseBase {
faUserPlus = faUserPlus;
faUserClock = faUserClock;
faCheck = faCheck;
faTimes = faTimes;
@Input() notification: NotificationWrapper;
constructor(private readonly toolsService: ToolsService) {
constructor(
private readonly notificationsService: NotificationService,
private readonly mastodonService: MastodonWrapperService,
private readonly toolsService: ToolsService) {
super();
}
@ -31,9 +39,47 @@ export class NotificationComponent extends BrowseBase {
this.browseAccountEvent.next(accountName);
return false;
}
openUrl(url: string): boolean {
window.open(url, '_blank');
return false;
}
followRequestWorking: boolean;
followRequestProcessed: boolean;
acceptFollowRequest(): boolean {
if(this.followRequestWorking) return false;
this.followRequestWorking = true;
this.mastodonService.authorizeFollowRequest(this.notification.provider, this.notification.notification.account.id)
.then(res => {
this.followRequestProcessed = true;
})
.catch(err => {
this.notificationsService.notifyHttpError(err, this.notification.provider);
})
.then(res => {
this.followRequestWorking = false;
});
return false;
}
refuseFollowRequest(): boolean {
if(this.followRequestWorking) return false;
this.followRequestWorking = true;
this.mastodonService.rejectFollowRequest(this.notification.provider, this.notification.notification.account.id)
.then(res => {
this.followRequestProcessed = true;
})
.catch(err => {
this.notificationsService.notifyHttpError(err, this.notification.provider);
})
.then(res => {
this.followRequestWorking = false;
});
return false;
}
}

View File

@ -158,11 +158,13 @@ export class NotificationWrapper {
this.account = notification.account;
this.wrapperId = `${this.type}-${notification.id}`;
this.notification = notification;
this.provider = provider;
}
provider: AccountInfo;
notification: Notification;
wrapperId: string;
account: Account;
status: StatusWrapper;
type: 'mention' | 'reblog' | 'favourite' | 'follow' | 'poll';
type: 'mention' | 'reblog' | 'favourite' | 'follow' | 'poll' | 'follow_request';
}

View File

@ -128,6 +128,8 @@ export class StreamNotificationsComponent extends BrowseBase {
this.mastodonService.getNotifications(this.account, null, null, null, 10)
.then((notifications: Notification[]) => {
console.warn(notifications);
this.isNotificationsLoading = false;
this.notifications = notifications.map(x => {
@ -235,7 +237,7 @@ export class StreamNotificationsComponent extends BrowseBase {
this.isMentionsLoading = true;
this.mastodonService.getNotifications(this.account, ['follow', 'favourite', 'reblog', 'poll'], this.lastMentionId)
this.mastodonService.getNotifications(this.account, ['follow', 'favourite', 'reblog', 'poll', 'follow_request'], this.lastMentionId)
.then((result: Notification[]) => {
if (result.length === 0) {
this.mentionsMaxReached = true;

View File

@ -13,7 +13,7 @@
<h2 class="profile__floating-header__names__display-name"
innerHTML="{{displayedAccount | accountEmoji }}" title="{{displayedAccount.display_name}}"></h2>
<a class="profile__floating-header__names__fullhandle" href="{{displayedAccount.url}}"
target="_blank" title="{{displayedAccount.acct}}">@{{displayedAccount.acct}}</a>
target="_blank" title="{{displayedAccount.acct}}">@{{displayedAccount.acct}}</a> <fa-icon class="fa-lock" *ngIf="displayedAccount.locked" [icon]="faLock" title="account locked"></fa-icon>
</div>
<div class="profile__floating-header__follow" *ngIf="relationship && !displayedAccount.moved">
@ -118,7 +118,7 @@
<h2 class="profile-name__link profile-name__display-name"
innerHTML="{{displayedAccount | accountEmoji }}" title="{{displayedAccount.display_name}}"></h2>
<h2 class="profile-name__link profile-name__fullhandle"><a href="{{displayedAccount.url}}"
target="_blank" title="{{displayedAccount.acct}}">@{{displayedAccount.acct}}</a></h2>
target="_blank" title="{{displayedAccount.acct}}">@{{displayedAccount.acct}}</a> <fa-icon class="fa-lock" *ngIf="displayedAccount.locked" [icon]="faLock" title="account locked"></fa-icon></h2>
</div>
<div class="profile-follows">

View File

@ -402,6 +402,12 @@ $floating-header-height: 60px;
}
}
.fa-lock {
margin-left: 5px;
color: gray;
font-size: 14px;
}
//Mastodon styling
:host ::ng-deep .profile-fields__field--value {
// font-size: 14px;

View File

@ -1,6 +1,6 @@
import { Component, OnInit, Input, Output, EventEmitter, ViewChild, ElementRef } from '@angular/core';
import { HttpErrorResponse } from '@angular/common/http';
import { faUser, faHourglassHalf, faUserCheck, faExclamationTriangle, faLink } from "@fortawesome/free-solid-svg-icons";
import { faUser, faHourglassHalf, faUserCheck, faExclamationTriangle, faLink, faLock } from "@fortawesome/free-solid-svg-icons";
import { faUser as faUserRegular } from "@fortawesome/free-regular-svg-icons";
import { Observable, Subscription } from 'rxjs';
import { Store } from '@ngxs/store';
@ -29,6 +29,7 @@ export class UserProfileComponent extends BrowseBase {
faUserCheck = faUserCheck;
faExclamationTriangle = faExclamationTriangle;
faLink = faLink;
faLock = faLock;
displayedAccount: Account;
hasNote: boolean;

View File

@ -252,7 +252,7 @@ export class MastodonWrapperService {
});
}
getNotifications(account: AccountInfo, excludeTypes: ('follow' | 'favourite' | 'reblog' | 'mention' | 'poll')[] = null, maxId: string = null, sinceId: string = null, limit: number = 15): Promise<Notification[]> {
getNotifications(account: AccountInfo, excludeTypes: ('follow' | 'favourite' | 'reblog' | 'mention' | 'poll' | 'follow_request')[] = 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);
@ -405,4 +405,18 @@ export class MastodonWrapperService {
return this.mastodonService.getFollowers(refreshedAccount, accountId, maxId, sinceId, limit);
});
}
authorizeFollowRequest(account: AccountInfo, id: number): Promise<Relationship> {
return this.refreshAccountIfNeeded(account)
.then((refreshedAccount: AccountInfo) => {
return this.mastodonService.authorizeFollowRequest(refreshedAccount, id);
});
}
rejectFollowRequest(account: AccountInfo, id: number): Promise<Relationship> {
return this.refreshAccountIfNeeded(account)
.then((refreshedAccount: AccountInfo) => {
return this.mastodonService.rejectFollowRequest(refreshedAccount, id);
});
}
}

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')[] = null, maxId: string = null, sinceId: string = null, limit: number = 15): Promise<Notification[]> {
getNotifications(account: AccountInfo, excludeTypes: ('follow' | 'favourite' | 'reblog' | 'mention' | 'poll' | 'follow_request')[] = null, maxId: string = null, sinceId: string = null, limit: number = 15): Promise<Notification[]> {
let route = `https://${account.instance}${this.apiRoutes.getNotifications}?limit=${limit}`;
if (maxId) {
@ -490,6 +490,7 @@ export class MastodonService {
return new FollowingResult(lastId, res.body)
});
}
getFollowing(account: AccountInfo, targetAccountId: number, maxId: string, sinceId: string, limit: number = 40): Promise<FollowingResult> {
const route = `https://${account.instance}${this.apiRoutes.getFollowing}`.replace('{0}', targetAccountId.toString());
@ -511,6 +512,20 @@ export class MastodonService {
return new FollowingResult(lastId, res.body)
});
}
authorizeFollowRequest(account: AccountInfo, id: number): Promise<Relationship> {
const route = `https://${account.instance}${this.apiRoutes.authorizeFollowRequest}`.replace('{0}', id.toString());
const headers = new HttpHeaders({ 'Authorization': `Bearer ${account.token.access_token}` });
return this.httpClient.post<Relationship>(route, null, { headers: headers }).toPromise();
}
rejectFollowRequest(account: AccountInfo, id: number): Promise<Relationship> {
const route = `https://${account.instance}${this.apiRoutes.rejectFollowRequest}`.replace('{0}', id.toString());
const headers = new HttpHeaders({ 'Authorization': `Bearer ${account.token.access_token}` });
return this.httpClient.post<Relationship>(route, null, { headers: headers }).toPromise();
}
}
export enum VisibilityEnum {

View File

@ -21,8 +21,8 @@ export class ApiRoutes {
getBlocks = '/api/v1/blocks';
getFavourites = '/api/v1/favourites';
getFollowRequests = '/api/v1/follow_requests';
authorizeFollowRequest = '/api/v1/follow_requests/authorize';
rejectFollowRequest = '/api/v1/follow_requests/reject';
authorizeFollowRequest = '/api/v1/follow_requests/{0}/authorize';
rejectFollowRequest = '/api/v1/follow_requests/{0}/reject';
followRemote = '/api/v1/follows';
getInstance = '/api/v1/instance';
uploadMediaAttachment = '/api/v1/media';

View File

@ -26,7 +26,7 @@ export interface Account {
username: string;
acct: string;
display_name: string;
locked: string;
locked: boolean;
created_at: string;
followers_count: number;
following_count: number;
@ -130,7 +130,7 @@ export interface Mention {
export interface Notification {
id: string;
type: 'mention' | 'reblog' | 'favourite' | 'follow' | 'poll';
type: 'mention' | 'reblog' | 'favourite' | 'follow' | 'poll' | 'follow_request';
created_at: string;
account: Account;
status?: Status;

View File

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