Skip to content

Commit

Permalink
Merge pull request #245 from NicolasConstant/develop
Browse files Browse the repository at this point in the history
0.23.1 PR
  • Loading branch information
NicolasConstant authored Apr 2, 2020
2 parents decb431 + e76d1d8 commit 10c8189
Show file tree
Hide file tree
Showing 18 changed files with 193 additions and 97 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sengi",
"version": "0.23.0",
"version": "0.23.1",
"license": "AGPL-3.0-or-later",
"main": "main-electron.js",
"description": "A multi-account desktop client for Mastodon and Pleroma",
Expand Down
6 changes: 4 additions & 2 deletions src/app/components/create-status/create-status.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
this.isSending = true;
this.mastodonService.getStatus(value.provider, value.status.in_reply_to_id)
.then((status: Status) => {
this.statusReplyingToWrapper = new StatusWrapper(status, value.provider);
let cwResult = this.toolsService.checkContentWarning(status);
this.statusReplyingToWrapper = new StatusWrapper(cwResult.status, value.provider, cwResult.applyCw, cwResult.hide);

const mentions = this.getMentions(this.statusReplyingToWrapper.status, this.statusReplyingToWrapper.provider);
for (const mention of mentions) {
Expand Down Expand Up @@ -564,7 +565,8 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
})
.then((status: Status) => {
if (this.statusReplyingToWrapper) {
this.notificationService.newStatusPosted(this.statusReplyingToWrapper.status.id, new StatusWrapper(status, account));
let cwPolicy = this.toolsService.checkContentWarning(status);
this.notificationService.newStatusPosted(this.statusReplyingToWrapper.status.id, new StatusWrapper(cwPolicy.status, account, cwPolicy.applyCw, cwPolicy.hide));
}

return status;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Component, OnInit, Output, EventEmitter, Input, ViewChild, ElementRef } from '@angular/core';

import { StatusWrapper } from '../../../../models/common.model';
import { OpenThreadEvent } from '../../../../services/tools.service';
import { OpenThreadEvent, ToolsService } from '../../../../services/tools.service';
import { AccountWrapper } from '../../../../models/account.models';
import { FavoriteResult, BookmarkResult } from '../../../../services/mastodon.service';
import { MastodonWrapperService } from '../../../../services/mastodon-wrapper.service';
Expand Down Expand Up @@ -41,8 +41,8 @@ export class BookmarksComponent implements OnInit {

@ViewChild('statusstream') public statustream: ElementRef;


constructor(
private readonly toolsService: ToolsService,
private readonly notificationService: NotificationService,
private readonly mastodonService: MastodonWrapperService) { }

Expand All @@ -63,7 +63,8 @@ export class BookmarksComponent implements OnInit {
.then((result: BookmarkResult) => {
this.maxId = result.max_id;
for (const s of result.bookmarked) {
const wrapper = new StatusWrapper(s, this.account.info);
let cwPolicy = this.toolsService.checkContentWarning(s);
const wrapper = new StatusWrapper(cwPolicy.status, this.account.info, cwPolicy.applyCw, cwPolicy.hide);
this.statuses.push(wrapper);
}
})
Expand Down Expand Up @@ -99,7 +100,8 @@ export class BookmarksComponent implements OnInit {

this.maxId = result.max_id;
for (const s of statuses) {
const wrapper = new StatusWrapper(s, this.account.info);
let cwPolicy = this.toolsService.checkContentWarning(s);
const wrapper = new StatusWrapper(cwPolicy.status, this.account.info, cwPolicy.applyCw, cwPolicy.hide);
this.statuses.push(wrapper);
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Component, OnInit, Input, Output, EventEmitter, ViewChild, ElementRef }
import { faUserFriends } from "@fortawesome/free-solid-svg-icons";

import { AccountWrapper } from '../../../../models/account.models';
import { OpenThreadEvent } from '../../../../services/tools.service';
import { OpenThreadEvent, ToolsService } from '../../../../services/tools.service';
import { StatusWrapper } from '../../../../models/common.model';
import { NotificationService } from '../../../../services/notification.service';
import { MastodonWrapperService } from '../../../../services/mastodon-wrapper.service';
Expand Down Expand Up @@ -42,6 +42,7 @@ export class DirectMessagesComponent implements OnInit {
@ViewChild('statusstream') public statustream: ElementRef;

constructor(
private readonly toolsService: ToolsService,
private readonly notificationService: NotificationService,
private readonly mastodonService: MastodonWrapperService) { }

Expand All @@ -60,7 +61,8 @@ export class DirectMessagesComponent implements OnInit {
this.mastodonService.getConversations(this.account.info)
.then((conversations: Conversation[]) => {
for (const c of conversations) {
const wrapper = new ConversationWrapper(c, this.account.info, this.account.avatar);
let cwPolicy = this.toolsService.checkContentWarning(c.last_status);
const wrapper = new ConversationWrapper(c, this.account.info, this.account.avatar, cwPolicy.applyCw, cwPolicy.hide);
this.conversations.push(wrapper);
}
})
Expand Down Expand Up @@ -95,7 +97,8 @@ export class DirectMessagesComponent implements OnInit {
}

for (const c of conversations) {
const wrapper = new ConversationWrapper(c, this.account.info, this.account.avatar);
let cwPolicy = this.toolsService.checkContentWarning(c.last_status);
const wrapper = new ConversationWrapper(c, this.account.info, this.account.avatar, cwPolicy.applyCw, cwPolicy.hide);
this.conversations.push(wrapper);
}
})
Expand All @@ -121,13 +124,14 @@ export class DirectMessagesComponent implements OnInit {
}

class ConversationWrapper {

constructor(
public conversation: Conversation,
public provider: AccountInfo,
public userAvatar: string
public userAvatar: string,
applyCw: boolean,
hideStatus: boolean
) {
this.lastStatus = new StatusWrapper(conversation.last_status, provider);
this.lastStatus = new StatusWrapper(conversation.last_status, provider, applyCw, hideStatus);
}

lastStatus: StatusWrapper;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Component, OnInit, Output, EventEmitter, Input, ViewChild, ElementRef } from '@angular/core';

import { StatusWrapper } from '../../../../models/common.model';
import { OpenThreadEvent } from '../../../../services/tools.service';
import { OpenThreadEvent, ToolsService } from '../../../../services/tools.service';
import { AccountWrapper } from '../../../../models/account.models';
import { FavoriteResult } from '../../../../services/mastodon.service';
import { MastodonWrapperService } from '../../../../services/mastodon-wrapper.service';
Expand Down Expand Up @@ -42,6 +42,7 @@ export class FavoritesComponent implements OnInit {
@ViewChild('statusstream') public statustream: ElementRef;

constructor(
private readonly toolsService: ToolsService,
private readonly notificationService: NotificationService,
private readonly mastodonService: MastodonWrapperService) { }

Expand All @@ -62,7 +63,8 @@ export class FavoritesComponent implements OnInit {
.then((result: FavoriteResult) => {
this.maxId = result.max_id;
for (const s of result.favorites) {
const wrapper = new StatusWrapper(s, this.account.info);
let cwPolicy = this.toolsService.checkContentWarning(s);
const wrapper = new StatusWrapper(cwPolicy.status, this.account.info, cwPolicy.applyCw, cwPolicy.hide);
this.statuses.push(wrapper);
}
})
Expand Down Expand Up @@ -99,7 +101,8 @@ export class FavoritesComponent implements OnInit {

this.maxId = result.max_id;
for (const s of statuses) {
const wrapper = new StatusWrapper(s, this.account.info);
let cwPolicy = this.toolsService.checkContentWarning(s);
const wrapper = new StatusWrapper(cwPolicy.status, this.account.info, cwPolicy.applyCw, cwPolicy.hide);
this.statuses.push(wrapper);
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { StatusWrapper } from '../../../../models/common.model';
import { Status, Notification } from '../../../../services/models/mastodon.interfaces';
import { MastodonWrapperService } from '../../../../services/mastodon-wrapper.service';
import { NotificationService } from '../../../../services/notification.service';
import { OpenThreadEvent } from '../../../../services/tools.service';
import { OpenThreadEvent, ToolsService } from '../../../../services/tools.service';


@Component({
Expand Down Expand Up @@ -45,6 +45,7 @@ export class MentionsComponent implements OnInit, OnDestroy {
private lastId: string;

constructor(
private readonly toolsService: ToolsService,
private readonly notificationService: NotificationService,
private readonly userNotificationService: UserNotificationService,
private readonly mastodonService: MastodonWrapperService) {
Expand Down Expand Up @@ -80,7 +81,8 @@ export class MentionsComponent implements OnInit, OnDestroy {
let orderedMentions = [...userNotification.mentions.map(x => x.status)].reverse();
for (let m of orderedMentions) {
if (!this.statuses.find(x => x.status.id === m.id)) {
const statusWrapper = new StatusWrapper(m, this.account.info);
let cwPolicy = this.toolsService.checkContentWarning(m);
const statusWrapper = new StatusWrapper(cwPolicy.status, this.account.info, cwPolicy.applyCw, cwPolicy.hide);
this.statuses.unshift(statusWrapper);
}
}
Expand Down Expand Up @@ -113,7 +115,8 @@ export class MentionsComponent implements OnInit, OnDestroy {
}

for (const s of statuses) {
const wrapper = new StatusWrapper(s, this.account.info);
let cwPolicy = this.toolsService.checkContentWarning(s);
const wrapper = new StatusWrapper(cwPolicy.status, this.account.info, cwPolicy.applyCw, cwPolicy.hide);
this.statuses.push(wrapper);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export class NotificationsComponent implements OnInit, OnDestroy {
private lastId: string;

constructor(
private readonly toolsService: ToolsService,
private readonly notificationService: NotificationService,
private readonly userNotificationService: UserNotificationService,
private readonly mastodonService: MastodonWrapperService) { }
Expand Down Expand Up @@ -72,7 +73,8 @@ export class NotificationsComponent implements OnInit, OnDestroy {
if (userNotification && userNotification.notifications) {
let orderedNotifications = [...userNotification.notifications].reverse();
for (let n of orderedNotifications) {
const notificationWrapper = new NotificationWrapper(n, this.account.info);
let cwPolicy = this.toolsService.checkContentWarning(n.status);
const notificationWrapper = new NotificationWrapper(n, this.account.info, cwPolicy.applyCw, cwPolicy.hide);
if (!this.notifications.find(x => x.wrapperId === notificationWrapper.wrapperId)) {
this.notifications.unshift(notificationWrapper);
}
Expand Down Expand Up @@ -105,7 +107,8 @@ export class NotificationsComponent implements OnInit, OnDestroy {
}

for (const s of notifications) {
const wrapper = new NotificationWrapper(s, this.account.info);
let cwPolicy = this.toolsService.checkContentWarning(s.status);
const wrapper = new NotificationWrapper(s, this.account.info, cwPolicy.applyCw, cwPolicy.hide);
this.notifications.push(wrapper);
}

Expand Down Expand Up @@ -133,14 +136,14 @@ export class NotificationsComponent implements OnInit, OnDestroy {
}

export class NotificationWrapper {
constructor(notification: Notification, provider: AccountInfo) {
constructor(notification: Notification, provider: AccountInfo, applyCw: boolean, hideStatus: boolean) {
this.type = notification.type;
switch(this.type){
case 'mention':
case 'reblog':
case 'favourite':
case 'poll':
this.status= new StatusWrapper(notification.status, provider);
case 'poll':
this.status= new StatusWrapper(notification.status, provider, applyCw, hideStatus);
break;
}
this.account = notification.account;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ export class SearchComponent implements OnInit {
this.hashtags = results.hashtags;

for (let status of results.statuses) {
const statusWrapper = new StatusWrapper(status, this.lastAccountUsed);
let cwPolicy = this.toolsService.checkContentWarning(status);
const statusWrapper = new StatusWrapper(cwPolicy.status, this.lastAccountUsed, cwPolicy.applyCw, cwPolicy.hide);
this.statuses.push(statusWrapper);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,7 @@ export class ActionBarComponent implements OnInit, OnDestroy {
this.isLocked = false;
}

if (status.sensitive || status.spoiler_text) {
this.isContentWarningActive = true;
}
this.isContentWarningActive = this.statusWrapper.applyCw;

this.checkIfBookmarksAreAvailable(this.selectedAccounts[0]);
this.checkIfFavorited();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,8 @@ export class StatusUserContextMenuComponent implements OnInit, OnDestroy {
this.navigationService.redraft(this.statusWrapper)
}

const deletedStatus = new StatusWrapper(this.displayedStatus, selectedAccount);
let cwPolicy = this.toolsService.checkContentWarning(this.displayedStatus);
const deletedStatus = new StatusWrapper(cwPolicy.status, selectedAccount, cwPolicy.applyCw, cwPolicy.hide);
this.notificationService.deleteStatus(deletedStatus);
})
.catch(err => {
Expand Down
3 changes: 2 additions & 1 deletion src/app/components/stream/status/poll/poll.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ export class PollComponent implements OnInit {
if (accountChanged && !this.pollPerAccountId[newSelectedAccount.id] && (this.statusWrapper.status.visibility === 'public' || this.statusWrapper.status.visibility === 'unlisted')) {
this.setStatsAtZero();

this.pollPerAccountId[newSelectedAccount.id] = this.toolsService.getStatusUsableByAccount(newSelectedAccount, new StatusWrapper(this.statusWrapper.status, this.statusWrapper.provider))
let statusWrapper = new StatusWrapper(this.statusWrapper.status, this.statusWrapper.provider, this.statusWrapper.applyCw, this.statusWrapper.hide);
this.pollPerAccountId[newSelectedAccount.id] = this.toolsService.getStatusUsableByAccount(newSelectedAccount, statusWrapper)
.then((status: Status) => {
if(!status || !(status.poll)) return null;
return this.mastodonService.getPoll(newSelectedAccount, status.poll.id);
Expand Down
Loading

0 comments on commit 10c8189

Please sign in to comment.