From 7144463c5a5cc54d8b39fffe96048a41cd9ddba9 Mon Sep 17 00:00:00 2001 From: Nicolas Constant Date: Tue, 31 Mar 2020 18:53:56 -0400 Subject: [PATCH] added status hiding --- .../stream/status/status.component.html | 2 +- .../stream/status/status.component.ts | 39 ++++++++++++------- 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/src/app/components/stream/status/status.component.html b/src/app/components/stream/status/status.component.html index d9463266..2bd49a73 100644 --- a/src/app/components/stream/status/status.component.html +++ b/src/app/components/stream/status/status.component.html @@ -1,4 +1,4 @@ -
+
(); @Output() browseHashtagEvent = new EventEmitter(); @Output() browseThreadEvent = new EventEmitter(); @@ -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("
", " ").replace("
", " ").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; } } }