diff options
Diffstat (limited to 'src/client/app/common/scripts')
| -rw-r--r-- | src/client/app/common/scripts/note-mixin.ts | 8 | ||||
| -rw-r--r-- | src/client/app/common/scripts/should-mute-note.ts | 28 |
2 files changed, 35 insertions, 1 deletions
diff --git a/src/client/app/common/scripts/note-mixin.ts b/src/client/app/common/scripts/note-mixin.ts index dd5098f4cd..9f1a4c6eea 100644 --- a/src/client/app/common/scripts/note-mixin.ts +++ b/src/client/app/common/scripts/note-mixin.ts @@ -1,5 +1,6 @@ import parse from '../../../../mfm/parse'; import { sum } from '../../../../prelude/array'; +import shouldMuteNote from './should-mute-note'; import MkNoteMenu from '../views/components/note-menu.vue'; import MkReactionPicker from '../views/components/reaction-picker.vue'; import Ok from '../views/components/ok.vue'; @@ -22,7 +23,8 @@ type Opts = { export default (opts: Opts = {}) => ({ data() { return { - showContent: false + showContent: false, + hideThisNote: false }; }, @@ -86,6 +88,10 @@ export default (opts: Opts = {}) => ({ } }, + created() { + this.hideThisNote = shouldMuteNote(this.$store.state.i, this.$store.state.settings, this.appearNote); + }, + methods: { reply(viaKeyboard = false) { this.$root.$post({ diff --git a/src/client/app/common/scripts/should-mute-note.ts b/src/client/app/common/scripts/should-mute-note.ts new file mode 100644 index 0000000000..a849135763 --- /dev/null +++ b/src/client/app/common/scripts/should-mute-note.ts @@ -0,0 +1,28 @@ +export default function(me, settings, note) { + const isMyNote = note.userId == me.id; + const isPureRenote = note.renoteId != null && note.text == null && note.fileIds.length == 0 && note.poll == null; + + if (settings.showMyRenotes === false) { + if (isMyNote && isPureRenote) { + return true; + } + } + + if (settings.showRenotedMyNotes === false) { + if (isPureRenote && (note.renote.userId == me.id)) { + return true; + } + } + + if (settings.showLocalRenotes === false) { + if (isPureRenote && (note.renote.user.host == null)) { + return true; + } + } + + if (!isMyNote && note.text && settings.mutedWords.some(q => !q.some(word => !note.text.includes(word)))) { + return true; + } + + return false; +} |