From 65ab5ffa32516f7ce55e0a1ac4145b51b35c0306 Mon Sep 17 00:00:00 2001 From: "Mr. Stallion" Date: Fri, 31 Dec 2021 18:06:08 -0600 Subject: [PATCH] Smart filters --- CHANGELOG.md | 3 + chat/CharacterSearch.vue | 10 +- chat/ConversationView.vue | 28 ++++- chat/SettingsView.vue | 155 ++++++++++++++++++++++- chat/UserList.vue | 25 +++- chat/common.ts | 37 ++++++ chat/conversations.ts | 42 ++++++- chat/core.ts | 10 +- chat/interfaces.ts | 4 + chat/message_view.ts | 17 ++- learn/cache-manager.ts | 14 ++- learn/filter/smart-filter.ts | 235 +++++++++++++++++++++++++++++++++++ learn/filter/types.ts | 47 +++++++ learn/matcher-types.ts | 130 ++++++++++++++++++- learn/matcher.ts | 15 ++- learn/profile-cache.ts | 17 ++- 16 files changed, 760 insertions(+), 29 deletions(-) create mode 100644 learn/filter/smart-filter.ts create mode 100644 learn/filter/types.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index f56b861..49cf4ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## Canary +* Added a way to hide/filter out characters, messages, and ads (Settings > Identity Politics) + ## 1.16.2 * Fixed broken auto-ads diff --git a/chat/CharacterSearch.vue b/chat/CharacterSearch.vue index d3ca16c..43bf674 100644 --- a/chat/CharacterSearch.vue +++ b/chat/CharacterSearch.vue @@ -270,7 +270,7 @@ core.connection.onMessage('FKS', async (data) => { const results = data.characters.map((x) => ({ character: core.characters.get(x), profile: null })) .filter((x) => core.state.hiddenUsers.indexOf(x.character.name) === -1 && !x.character.isIgnored) - .filter((x) => this.isSpeciesMatch(x) && this.isBodyTypeMatch(x)) + .filter((x) => this.isSpeciesMatch(x) && this.isBodyTypeMatch(x) && this.isSmartFilterMatch(x)) .sort(sort); // pre-warm cache @@ -399,6 +399,14 @@ return this.data.bodytypes.indexOf(bodytype!.value) > -1 } + isSmartFilterMatch(result: SearchResult) { + if (!core.state.settings.risingFilter.hideSearchResults) { + return true; + } + + return result.profile ? !result.profile?.match.isFiltered : true; + } + getSpeciesOptions(): SearchSpecies[] { const species = _.map( speciesMapping, diff --git a/chat/ConversationView.vue b/chat/ConversationView.vue index 03872e6..9bbbf4e 100644 --- a/chat/ConversationView.vue +++ b/chat/ConversationView.vue @@ -449,16 +449,26 @@ /* tslint:disable */ getMessageWrapperClasses(): any { + const filter = core.state.settings.risingFilter; + const classes:any = {}; + + if (this.isPrivate(this.conversation)) { + classes['filter-channel-messages'] = filter.hidePrivateMessages; + return classes; + } + if (!this.isChannel(this.conversation)) { return {}; } const conv = this.conversation; - const classes:any = {}; classes['messages-' + conv.mode] = true; classes['hide-non-matching'] = !this.showNonMatchingAds; + classes['filter-ads'] = filter.hideAds; + classes['filter-channel-messages'] = conv.channel.owner !== '' ? filter.hidePrivateChannelMessages : filter.hidePublicChannelMessages; + return classes; } @@ -839,12 +849,26 @@ } - .messages.hide-non-matching .message.message-score { + .messages.hide-non-matching .message.message-score, + { &.mismatch { display: none; } } + .messages.filter-ads { + .message.filter-match.message-ad { + display: none; + } + } + + .messages.filter-channel-messages { + .message.filter-match.message-message, + .message.filter-match.message-action { + display: none; + } + } + .message { .message-pre { font-size: 75%; diff --git a/chat/SettingsView.vue b/chat/SettingsView.vue index 5a93a49..e2cb43b 100644 --- a/chat/SettingsView.vue +++ b/chat/SettingsView.vue @@ -1,7 +1,7 @@