From 296ab5430147f01107131046dcd428085bef9020 Mon Sep 17 00:00:00 2001 From: scarlett Date: Fri, 24 Aug 2018 20:04:26 +0100 Subject: [PATCH 1/4] Add settings for changing the visibility of replies in the timeline. --- src/components/settings/settings.js | 4 +++ src/components/settings/settings.vue | 10 +++++++ src/components/status/status.js | 42 ++++++++++++++++++++++++++++ src/components/status/status.vue | 2 +- src/i18n/messages.js | 3 ++ src/main.js | 1 + src/modules/config.js | 1 + 7 files changed, 62 insertions(+), 1 deletion(-) diff --git a/src/components/settings/settings.js b/src/components/settings/settings.js index c85ef59f..d5ca33cc 100644 --- a/src/components/settings/settings.js +++ b/src/components/settings/settings.js @@ -8,6 +8,7 @@ const settings = { hideAttachmentsLocal: this.$store.state.config.hideAttachments, hideAttachmentsInConvLocal: this.$store.state.config.hideAttachmentsInConv, hideNsfwLocal: this.$store.state.config.hideNsfw, + replyVisibilityLocal: this.$store.state.config.replyVisibility, loopVideoLocal: this.$store.state.config.loopVideo, loopVideoSilentOnlyLocal: this.$store.state.config.loopVideoSilentOnly, muteWordsString: this.$store.state.config.muteWords.join('\n'), @@ -44,6 +45,9 @@ const settings = { hideNsfwLocal (value) { this.$store.dispatch('setOption', { name: 'hideNsfw', value }) }, + replyVisibilityLocal (value) { + this.$store.dispatch('setOption', { name: 'replyVisibility', value }) + }, loopVideoLocal (value) { this.$store.dispatch('setOption', { name: 'loopVideo', value }) }, diff --git a/src/components/settings/settings.vue b/src/components/settings/settings.vue index 415317f0..9612876e 100644 --- a/src/components/settings/settings.vue +++ b/src/components/settings/settings.vue @@ -38,6 +38,16 @@ +
  • + +
  • diff --git a/src/components/status/status.js b/src/components/status/status.js index 9670f69d..a6cb6b6f 100644 --- a/src/components/status/status.js +++ b/src/components/status/status.js @@ -105,6 +105,48 @@ const Status = { const lengthScore = this.status.statusnet_html.split(/ 20 }, + isReply () { + if (this.status.in_reply_to_status_id) { + return true + } + // For private replies where we can't see the OP, in_reply_to_status_id will be null. + // So instead, check that the post starts with a @mention. + if (this.status.visibility === 'private') { + var textBody = this.status.text + if (this.status.summary !== null) { + textBody = textBody.substring(this.status.summary.length, textBody.length) + } + return textBody.startsWith('@') + } + return false + }, + hideReply () { + if (this.$store.state.config.replyVisibility === 'all') { + return false + } + if (this.inlineExpanded || this.expanded || !this.isReply) { + return false + } + if (this.status.user.id === this.$store.state.users.currentUser.id) { + return false + } + if (this.status.activity_type === 'repeat') { + return false + } + var checkFollowing = this.$store.state.config.replyVisibility === 'following' + for (var i = 0; i < this.status.attentions.length; ++i) { + if (this.status.user.id === this.status.attentions[i].id) { + continue + } + if (checkFollowing && this.status.attentions[i].following) { + return false + } + if (this.status.attentions[i].id === this.$store.state.users.currentUser.id) { + return false + } + } + return this.status.attentions.length > 0 + }, hideSubjectStatus () { if (this.tallStatus && !this.$store.state.config.collapseMessageWithSubject) { return false diff --git a/src/components/status/status.vue b/src/components/status/status.vue index e7d5ed7a..2bc44ee7 100644 --- a/src/components/status/status.vue +++ b/src/components/status/status.vue @@ -1,5 +1,5 @@