added status hiding

This commit is contained in:
Nicolas Constant 2020-03-31 18:53:56 -04:00
parent ff7148c33b
commit 7144463c5a
No known key found for this signature in database
GPG Key ID: 1E9F677FB01A5688
2 changed files with 26 additions and 15 deletions

View File

@ -1,4 +1,4 @@
<div class="status-wrapper" [class.direct-message]="isDirectMessage" [class.status-selected]="isSelected">
<div *ngIf="!hideStatus" class="status-wrapper" [class.direct-message]="isDirectMessage" [class.status-selected]="isSelected">
<div class="reblog" *ngIf="reblog">
<a class="reblog__profile-link" href title="{{ status.account.acct }}"
(click)="openAccount(status.account)"

View File

@ -40,6 +40,8 @@ export class StatusComponent implements OnInit {
isDirectMessage: boolean;
isSelected: boolean;
hideStatus: boolean = false;
@Output() browseAccountEvent = new EventEmitter<string>();
@Output() browseHashtagEvent = new EventEmitter<string>();
@Output() browseThreadEvent = new EventEmitter<OpenThreadEvent>();
@ -100,8 +102,9 @@ export class StatusComponent implements OnInit {
let cwPolicy = this.toolsService.getSettings().contentWarningPolicy;
let splittedContent = [];
if ((cwPolicy.policy === ContentWarningPolicyEnum.HideAll && cwPolicy.addCwOnContent.length > 0)
|| (cwPolicy.policy === ContentWarningPolicyEnum.AddOnAllContent && cwPolicy.removeCwOnContent.length > 0)) {
if ((cwPolicy.policy === ContentWarningPolicyEnum.HideAll && cwPolicy.addCwOnContent.length > 0)
|| (cwPolicy.policy === ContentWarningPolicyEnum.AddOnAllContent && cwPolicy.removeCwOnContent.length > 0)
|| (cwPolicy.hideCompletlyContent && cwPolicy.hideCompletlyContent.length > 0)) {
let parser = new DOMParser();
let dom = parser.parseFromString((status.content + ' ' + status.spoiler_text).replace("<br/>", " ").replace("<br>", " ").replace(/\n/g, ' '), 'text/html')
let contentToParse = dom.body.textContent;
@ -114,20 +117,28 @@ export class StatusComponent implements OnInit {
let detected = cwPolicy.addCwOnContent.filter(x => splittedContent.find(y => y == x || y == `#${x}`));
if (!detected || detected.length === 0) {
this.status.sensitive = false;
return;
}
if (!status.spoiler_text) {
status.spoiler_text = detected.join(' ');
}
this.setContentWarning(status);
} else if (cwPolicy.policy === ContentWarningPolicyEnum.AddOnAllContent) {
let detected = cwPolicy.removeCwOnContent.find(x => splittedContent.find(y => y == x) != null) != null;
if (!detected) {
this.setContentWarning(status);
} else {
if (!status.spoiler_text) {
status.spoiler_text = detected.join(' ');
}
this.setContentWarning(status);
}
} else if (cwPolicy.policy === ContentWarningPolicyEnum.AddOnAllContent) {
let detected = cwPolicy.removeCwOnContent.filter(x => splittedContent.find(y => y == x || y == `#${x}`));
if (detected && detected.length > 0) {
this.status.sensitive = false;
} else {
this.setContentWarning(status);
}
}
if (cwPolicy.hideCompletlyContent && cwPolicy.hideCompletlyContent.length > 0) {
console.warn('tata');
console.warn(cwPolicy.hideCompletlyContent);
let detected = cwPolicy.hideCompletlyContent.filter(x => splittedContent.find(y => y == x || y == `#${x}`));
if (detected && detected.length > 0) {
this.hideStatus = true;
}
}
}