From 7a6eb9c3d223f7422934a426c794d829d8a0d5b2 Mon Sep 17 00:00:00 2001 From: Nicolas Constant Date: Fri, 8 Mar 2024 03:13:58 -0500 Subject: [PATCH] starting handling server filters --- .../stream/status/status.component.ts | 28 +++++++++++++++++++ .../user-profile/user-profile.component.html | 8 ++++-- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/src/app/components/stream/status/status.component.ts b/src/app/components/stream/status/status.component.ts index 11d4ee0c..264a2485 100644 --- a/src/app/components/stream/status/status.component.ts +++ b/src/app/components/stream/status/status.component.ts @@ -59,6 +59,8 @@ export class StatusComponent implements OnInit { @Input() notificationType: 'mention' | 'reblog' | 'favourite' | 'poll' | 'update'; @Input() notificationAccount: Account; + @Input() context: 'home' | 'notifications' | 'public' | 'thread' | 'account'; + private _statusWrapper: StatusWrapper; status: Status; @@ -98,6 +100,8 @@ export class StatusComponent implements OnInit { // this.statusAccountName = this.emojiConverter.applyEmojis(this.displayedStatus.account.emojis, this.displayedStatus.account.display_name, EmojiTypeEnum.small); let statusContent = this.emojiConverter.applyEmojis(this.displayedStatus.emojis, this.displayedStatus.content, EmojiTypeEnum.medium); this.statusContent = this.ensureMentionAreDisplayed(statusContent); + + this.validateFilteringStatus(); } get statusWrapper(): StatusWrapper { return this._statusWrapper; @@ -123,6 +127,30 @@ export class StatusComponent implements OnInit { if (this.statusesStateServiceSub) this.statusesStateServiceSub.unsubscribe(); } + private validateFilteringStatus(){ + // console.warn(this.displayedStatus); + + //TODO: finish this + + const filterStatus = this.displayedStatus.filtered; + if(!filterStatus || filterStatus.length === 0) return; + + console.warn(filterStatus); + console.warn(this.context); + + for (let filter of filterStatus) { + if(this.context && filter.filter.context && filter.filter.context.length > 0){ + if(!filter.filter.context.includes(this.context)) continue; + } + + if(filter.filter.filter_action === 'warn'){ + + } else if (filter.filter.filter_action === 'hide'){ + this.hideStatus = true; + } + } + } + getAvatar(acc: Account): string { if(this.freezeAvatarEnabled){ return acc.avatar_static; diff --git a/src/app/components/stream/user-profile/user-profile.component.html b/src/app/components/stream/user-profile/user-profile.component.html index c6111381..baf19d33 100644 --- a/src/app/components/stream/user-profile/user-profile.component.html +++ b/src/app/components/stream/user-profile/user-profile.component.html @@ -204,8 +204,12 @@
- +