aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/components/status/status.js15
-rw-r--r--src/components/status/status.vue4
-rw-r--r--src/components/user_profile/user_profile.js3
-rw-r--r--src/components/user_settings/user_settings.js9
-rw-r--r--src/components/user_settings/user_settings.vue8
-rw-r--r--src/i18n/de.json3
-rw-r--r--src/i18n/en.json3
-rw-r--r--src/i18n/ja.json3
-rw-r--r--src/i18n/ko.json3
-rw-r--r--src/i18n/ru.json3
-rw-r--r--src/services/api/api.service.js2
-rw-r--r--src/services/entity_normalizer/entity_normalizer.service.js3
-rw-r--r--src/services/mention_matcher/mention_matcher.js9
-rw-r--r--test/unit/specs/services/mention_matcher/mention_matcher.spec.js63
14 files changed, 115 insertions, 16 deletions
diff --git a/src/components/status/status.js b/src/components/status/status.js
index f85b7847..f7b0357b 100644
--- a/src/components/status/status.js
+++ b/src/components/status/status.js
@@ -9,6 +9,7 @@ import LinkPreview from '../link-preview/link-preview.vue'
import { filter, find } from 'lodash'
import { highlightClass, highlightStyle } from '../../services/user_highlighter/user_highlighter.js'
import generateProfileLink from 'src/services/user_profile_link_generator/user_profile_link_generator'
+import { mentionMatchesUrl } from 'src/services/mention_matcher/mention_matcher.js'
const Status = {
name: 'Status',
@@ -237,11 +238,23 @@ const Status = {
return 'icon-globe'
}
},
- linkClicked ({target}) {
+ linkClicked (event) {
+ let { target } = event
if (target.tagName === 'SPAN') {
target = target.parentNode
}
if (target.tagName === 'A') {
+ if (target.className.match(/mention/)) {
+ const href = target.getAttribute('href')
+ const attn = this.status.attentions.find(attn => mentionMatchesUrl(attn, href))
+ if (attn) {
+ event.stopPropagation()
+ event.preventDefault()
+ const link = this.generateUserProfileLink(attn.id, attn.screen_name)
+ this.$router.push(link)
+ return
+ }
+ }
window.open(target.href, '_blank')
}
},
diff --git a/src/components/status/status.vue b/src/components/status/status.vue
index d88428c7..45100a46 100644
--- a/src/components/status/status.vue
+++ b/src/components/status/status.vue
@@ -24,9 +24,9 @@
<div :class="[userClass, { highlighted: userStyle, 'is-retweet': retweet }]" :style="[ userStyle ]" class="media status">
<div v-if="!noHeading" class="media-left">
- <a :href="status.user.statusnet_profile_url" @click.stop.prevent.capture="toggleUserExpanded">
+ <router-link :to="userProfileLink" @click.stop.prevent.capture.native="toggleUserExpanded">
<StillImage class='avatar' :class="{'avatar-compact': compact, 'better-shadow': betterShadow}" :src="status.user.profile_image_url_original"/>
- </a>
+ </router-link>
</div>
<div class="status-body">
<div class="usercard media-body" v-if="userExpanded">
diff --git a/src/components/user_profile/user_profile.js b/src/components/user_profile/user_profile.js
index 991062cd..27e138b0 100644
--- a/src/components/user_profile/user_profile.js
+++ b/src/components/user_profile/user_profile.js
@@ -36,7 +36,8 @@ const UserProfile = {
return this.$route.params.name || this.user.screen_name
},
isUs () {
- return this.userId === this.$store.state.users.currentUser.id
+ return this.userId && this.$store.state.users.currentUser.id &&
+ this.userId === this.$store.state.users.currentUser.id
},
friends () {
return this.user.friends
diff --git a/src/components/user_settings/user_settings.js b/src/components/user_settings/user_settings.js
index dcce275a..be799f5d 100644
--- a/src/components/user_settings/user_settings.js
+++ b/src/components/user_settings/user_settings.js
@@ -10,7 +10,8 @@ const UserSettings = {
newLocked: this.$store.state.users.currentUser.locked,
newNoRichText: this.$store.state.users.currentUser.no_rich_text,
newDefaultScope: this.$store.state.users.currentUser.default_scope,
- newHideNetwork: this.$store.state.users.currentUser.hide_network,
+ hideFollowings: this.$store.state.users.currentUser.hide_followings,
+ hideFollowers: this.$store.state.users.currentUser.hide_followers,
followList: null,
followImportError: false,
followsImported: false,
@@ -66,7 +67,8 @@ const UserSettings = {
/* eslint-disable camelcase */
const default_scope = this.newDefaultScope
const no_rich_text = this.newNoRichText
- const hide_network = this.newHideNetwork
+ const hide_followings = this.hideFollowings
+ const hide_followers = this.hideFollowers
/* eslint-enable camelcase */
this.$store.state.api.backendInteractor
.updateProfile({
@@ -78,7 +80,8 @@ const UserSettings = {
/* eslint-disable camelcase */
default_scope,
no_rich_text,
- hide_network
+ hide_followings,
+ hide_followers
/* eslint-enable camelcase */
}}).then((user) => {
if (!user.error) {
diff --git a/src/components/user_settings/user_settings.vue b/src/components/user_settings/user_settings.vue
index 4bc2eeec..253bbd34 100644
--- a/src/components/user_settings/user_settings.vue
+++ b/src/components/user_settings/user_settings.vue
@@ -30,8 +30,12 @@
<label for="account-no-rich-text">{{$t('settings.no_rich_text_description')}}</label>
</p>
<p>
- <input type="checkbox" v-model="newHideNetwork" id="account-hide-network">
- <label for="account-hide-network">{{$t('settings.hide_network_description')}}</label>
+ <input type="checkbox" v-model="hideFollowings" id="account-hide-followings">
+ <label for="account-hide-followings">{{$t('settings.hide_followings_description')}}</label>
+ </p>
+ <p>
+ <input type="checkbox" v-model="hideFollowers" id="account-hide-followers">
+ <label for="account-hide-followers">{{$t('settings.hide_followers_description')}}</label>
</p>
<button :disabled='newName.length <= 0' class="btn btn-default" @click="updateProfile">{{$t('general.submit')}}</button>
</div>
diff --git a/src/i18n/de.json b/src/i18n/de.json
index c87371e6..82860e9e 100644
--- a/src/i18n/de.json
+++ b/src/i18n/de.json
@@ -155,7 +155,8 @@
"notification_visibility_mentions": "Erwähnungen",
"notification_visibility_repeats": "Wiederholungen",
"no_rich_text_description": "Rich-Text Formatierungen von allen Beiträgen entfernen",
- "hide_network_description": "Zeige nicht, wem ich folge und wer mir folgt",
+ "hide_followings_description": "Zeige nicht, wem ich folge",
+ "hide_followers_description": "Zeige nicht, wer mir folgt",
"nsfw_clickthrough": "Aktiviere ausblendbares Overlay für Anhänge, die als NSFW markiert sind",
"panelRadius": "Panel",
"pause_on_unfocused": "Streaming pausieren, wenn das Tab nicht fokussiert ist",
diff --git a/src/i18n/en.json b/src/i18n/en.json
index 3ff98ab0..a2106f1a 100644
--- a/src/i18n/en.json
+++ b/src/i18n/en.json
@@ -157,7 +157,8 @@
"notification_visibility_mentions": "Mentions",
"notification_visibility_repeats": "Repeats",
"no_rich_text_description": "Strip rich text formatting from all posts",
- "hide_network_description": "Don't show who I'm following and who's following me",
+ "hide_followings_description": "Don't show who I'm following",
+ "hide_followers_description": "Don't show who's following me",
"nsfw_clickthrough": "Enable clickthrough NSFW attachment hiding",
"panelRadius": "Panels",
"pause_on_unfocused": "Pause streaming when tab is not focused",
diff --git a/src/i18n/ja.json b/src/i18n/ja.json
index 161856f0..37e96f6c 100644
--- a/src/i18n/ja.json
+++ b/src/i18n/ja.json
@@ -157,7 +157,8 @@
"notification_visibility_mentions": "メンション",
"notification_visibility_repeats": "リピート",
"no_rich_text_description": "リッチテキストをつかわない",
- "hide_network_description": "わたしがフォローしているひとと、わたしをフォローしているひとを、みせない",
+ "hide_followings_description": "フォローしている人を表示しない",
+ "hide_followers_description": "フォローしている人を表示しない",
"nsfw_clickthrough": "NSFWなファイルをかくす",
"panelRadius": "パネル",
"pause_on_unfocused": "タブにフォーカスがないときストリーミングをとめる",
diff --git a/src/i18n/ko.json b/src/i18n/ko.json
index 4b69df07..9f40be51 100644
--- a/src/i18n/ko.json
+++ b/src/i18n/ko.json
@@ -156,7 +156,8 @@
"notification_visibility_mentions": "멘션",
"notification_visibility_repeats": "반복",
"no_rich_text_description": "모든 게시물의 서식을 지우기",
- "hide_network_description": "내 팔로우와 팔로워를 숨기기",
+ "hide_followings_description": "내가 팔로우하는 사람을 표시하지 않음",
+ "hide_followers_description": "나를 따르는 사람을 보여주지 마라.",
"nsfw_clickthrough": "NSFW 이미지 \"클릭해서 보이기\"를 활성화",
"panelRadius": "패널",
"pause_on_unfocused": "탭이 활성 상태가 아닐 때 스트리밍 멈추기",
diff --git a/src/i18n/ru.json b/src/i18n/ru.json
index 0887bb59..bf1e319f 100644
--- a/src/i18n/ru.json
+++ b/src/i18n/ru.json
@@ -127,7 +127,8 @@
"notification_visibility_mentions": "Упоминания",
"notification_visibility_repeats": "Повторы",
"no_rich_text_description": "Убрать форматирование из всех постов",
- "hide_network_description": "Не показывать кого я читаю и кто меня читает",
+ "hide_followings_description": "Не показывать кого я читаю",
+ "hide_followers_description": "Не показывать кто читает меня",
"nsfw_clickthrough": "Включить скрытие NSFW вложений",
"panelRadius": "Панели",
"pause_on_unfocused": "Приостановить загрузку когда вкладка не в фокусе",
diff --git a/src/services/api/api.service.js b/src/services/api/api.service.js
index 5b0d8650..31b48cb6 100644
--- a/src/services/api/api.service.js
+++ b/src/services/api/api.service.js
@@ -130,7 +130,7 @@ const updateBanner = ({credentials, params}) => {
// description
const updateProfile = ({credentials, params}) => {
// Always include these fields, because they might be empty or false
- const fields = ['description', 'locked', 'no_rich_text', 'hide_network']
+ const fields = ['description', 'locked', 'no_rich_text', 'hide_followings', 'hide_followers']
let url = PROFILE_UPDATE_URL
const form = new FormData()
diff --git a/src/services/entity_normalizer/entity_normalizer.service.js b/src/services/entity_normalizer/entity_normalizer.service.js
index deffa537..fa955ad6 100644
--- a/src/services/entity_normalizer/entity_normalizer.service.js
+++ b/src/services/entity_normalizer/entity_normalizer.service.js
@@ -100,7 +100,8 @@ export const parseUser = (data) => {
output.rights = data.rights
output.no_rich_text = data.no_rich_text
output.default_scope = data.default_scope
- output.hide_network = data.hide_network
+ output.hide_followings = data.hide_followings
+ output.hide_followers = data.hide_followers
output.background_image = data.background_image
// on mastoapi this info is contained in a "relationship"
output.following = data.following
diff --git a/src/services/mention_matcher/mention_matcher.js b/src/services/mention_matcher/mention_matcher.js
new file mode 100644
index 00000000..2c1ed970
--- /dev/null
+++ b/src/services/mention_matcher/mention_matcher.js
@@ -0,0 +1,9 @@
+
+export const mentionMatchesUrl = (attention, url) => {
+ if (url === attention.statusnet_profile_url) {
+ return true
+ }
+ const [namepart, instancepart] = attention.screen_name.split('@')
+ const matchstring = new RegExp('://' + instancepart + '/.*' + namepart + '$', 'g')
+ return !!url.match(matchstring)
+}
diff --git a/test/unit/specs/services/mention_matcher/mention_matcher.spec.js b/test/unit/specs/services/mention_matcher/mention_matcher.spec.js
new file mode 100644
index 00000000..4f6f58ff
--- /dev/null
+++ b/test/unit/specs/services/mention_matcher/mention_matcher.spec.js
@@ -0,0 +1,63 @@
+import * as MentionMatcher from 'src/services/mention_matcher/mention_matcher.js'
+
+const localAttn = () => ({
+ id: 123,
+ is_local: true,
+ name: 'Guy',
+ screen_name: 'person',
+ statusnet_profile_url: 'https://instance.com/users/person'
+})
+
+const externalAttn = () => ({
+ id: 123,
+ is_local: false,
+ name: 'Guy',
+ screen_name: 'person@instance.com',
+ statusnet_profile_url: 'https://instance.com/users/person'
+})
+
+describe('MentionMatcher', () => {
+ describe.only('mentionMatchesUrl', () => {
+ it('should match local mention', () => {
+ const attention = localAttn()
+ const url = 'https://instance.com/users/person'
+
+ expect(MentionMatcher.mentionMatchesUrl(attention, url)).to.eql(true)
+ })
+
+ it('should not match a local mention with same name but different instance', () => {
+ const attention = localAttn()
+ const url = 'https://website.com/users/person'
+
+ expect(MentionMatcher.mentionMatchesUrl(attention, url)).to.eql(false)
+ })
+
+ it('should match external pleroma mention', () => {
+ const attention = externalAttn()
+ const url = 'https://instance.com/users/person'
+
+ expect(MentionMatcher.mentionMatchesUrl(attention, url)).to.eql(true)
+ })
+
+ it('should not match external pleroma mention with same name but different instance', () => {
+ const attention = externalAttn()
+ const url = 'https://website.com/users/person'
+
+ expect(MentionMatcher.mentionMatchesUrl(attention, url)).to.eql(false)
+ })
+
+ it('should match external mastodon mention', () => {
+ const attention = externalAttn()
+ const url = 'https://instance.com/@person'
+
+ expect(MentionMatcher.mentionMatchesUrl(attention, url)).to.eql(true)
+ })
+
+ it('should not match external mastodon mention with same name but different instance', () => {
+ const attention = externalAttn()
+ const url = 'https://website.com/@person'
+
+ expect(MentionMatcher.mentionMatchesUrl(attention, url)).to.eql(false)
+ })
+ })
+})