forked from mirrors/akkoma-fe
Merge branch 'develop' into feat/media-modal
This commit is contained in:
commit
c7cffbb6c7
32 changed files with 349 additions and 50 deletions
|
@ -95,7 +95,8 @@ module.exports = {
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
new ServiceWorkerWebpackPlugin({
|
new ServiceWorkerWebpackPlugin({
|
||||||
entry: path.join(__dirname, '..', 'src/sw.js')
|
entry: path.join(__dirname, '..', 'src/sw.js'),
|
||||||
|
filename: 'sw-pleroma.js'
|
||||||
})
|
})
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -425,6 +425,12 @@ main-router {
|
||||||
border-radius: 0 0 $fallback--panelRadius $fallback--panelRadius;
|
border-radius: 0 0 $fallback--panelRadius $fallback--panelRadius;
|
||||||
border-radius: 0 0 var(--panelRadius, $fallback--panelRadius) var(--panelRadius, $fallback--panelRadius);
|
border-radius: 0 0 var(--panelRadius, $fallback--panelRadius) var(--panelRadius, $fallback--panelRadius);
|
||||||
|
|
||||||
|
|
||||||
|
.faint {
|
||||||
|
color: $fallback--faint;
|
||||||
|
color: var(--panelFaint, $fallback--faint);
|
||||||
|
}
|
||||||
|
|
||||||
a {
|
a {
|
||||||
color: $fallback--link;
|
color: $fallback--link;
|
||||||
color: var(--panelLink, $fallback--link)
|
color: var(--panelLink, $fallback--link)
|
||||||
|
|
|
@ -89,6 +89,8 @@ const afterStoreSetup = ({ store, i18n }) => {
|
||||||
|
|
||||||
if ((config.chatDisabled)) {
|
if ((config.chatDisabled)) {
|
||||||
store.dispatch('disableChat')
|
store.dispatch('disableChat')
|
||||||
|
} else {
|
||||||
|
store.dispatch('initializeSocket')
|
||||||
}
|
}
|
||||||
|
|
||||||
const router = new VueRouter({
|
const router = new VueRouter({
|
||||||
|
|
21
src/components/link-preview/link-preview.js
Normal file
21
src/components/link-preview/link-preview.js
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
const LinkPreview = {
|
||||||
|
name: 'LinkPreview',
|
||||||
|
props: [
|
||||||
|
'card',
|
||||||
|
'size',
|
||||||
|
'nsfw'
|
||||||
|
],
|
||||||
|
computed: {
|
||||||
|
useImage () {
|
||||||
|
// Currently BE shoudn't give cards if tagged NSFW, this is a bit paranoid
|
||||||
|
// as it makes sure to hide the image if somehow NSFW tagged preview can
|
||||||
|
// exist.
|
||||||
|
return this.card.image && !this.nsfw && this.size !== 'hide'
|
||||||
|
},
|
||||||
|
useDescription () {
|
||||||
|
return this.card.description && /\S/.test(this.card.description)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default LinkPreview
|
79
src/components/link-preview/link-preview.vue
Normal file
79
src/components/link-preview/link-preview.vue
Normal file
|
@ -0,0 +1,79 @@
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<a class="link-preview-card" :href="card.url" target="_blank" rel="noopener">
|
||||||
|
<div class="card-image" :class="{ 'small-image': size === 'small' }" v-if="useImage">
|
||||||
|
<img :src="card.image"></img>
|
||||||
|
</div>
|
||||||
|
<div class="card-content">
|
||||||
|
<span class="card-host faint">{{ card.provider_name }}</span>
|
||||||
|
<h4 class="card-title">{{ card.title }}</h4>
|
||||||
|
<p class="card-description" v-if="useDescription">{{ card.description }}</p>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script src="./link-preview.js"></script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
@import '../../_variables.scss';
|
||||||
|
|
||||||
|
.link-preview-card {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
cursor: pointer;
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
|
// TODO: clean up the random margins in attachments, this makes preview line
|
||||||
|
// up with attachments...
|
||||||
|
margin-right: 0.7em;
|
||||||
|
|
||||||
|
.card-image {
|
||||||
|
flex-shrink: 0;
|
||||||
|
width: 120px;
|
||||||
|
max-width: 25%;
|
||||||
|
img {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
object-fit: cover;
|
||||||
|
border-radius: $fallback--attachmentRadius;
|
||||||
|
border-radius: var(--attachmentRadius, $fallback--attachmentRadius);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.small-image {
|
||||||
|
width: 80px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-content {
|
||||||
|
max-height: 100%;
|
||||||
|
margin: 0.5em;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-host {
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-description {
|
||||||
|
margin: 0.5em 0 0 0;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
word-break: break-word;
|
||||||
|
line-height: 1.2em;
|
||||||
|
// cap description at 3 lines, the 1px is to clean up some stray pixels
|
||||||
|
// TODO: fancier fade-out at the bottom to show off that it's too long?
|
||||||
|
max-height: calc(1.2em * 3 - 1px);
|
||||||
|
}
|
||||||
|
|
||||||
|
color: $fallback--text;
|
||||||
|
color: var(--text, $fallback--text);
|
||||||
|
border-style: solid;
|
||||||
|
border-width: 1px;
|
||||||
|
border-radius: $fallback--attachmentRadius;
|
||||||
|
border-radius: var(--attachmentRadius, $fallback--attachmentRadius);
|
||||||
|
border-color: $fallback--border;
|
||||||
|
border-color: var(--border, $fallback--border);
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -44,6 +44,7 @@
|
||||||
|
|
||||||
.nav-panel .panel {
|
.nav-panel .panel {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
box-shadow: var(--panelShadow);
|
||||||
}
|
}
|
||||||
.nav-panel ul {
|
.nav-panel ul {
|
||||||
list-style: none;
|
list-style: none;
|
||||||
|
|
|
@ -13,6 +13,11 @@ const Notifications = {
|
||||||
|
|
||||||
notificationsFetcher.startFetching({ store, credentials })
|
notificationsFetcher.startFetching({ store, credentials })
|
||||||
},
|
},
|
||||||
|
data () {
|
||||||
|
return {
|
||||||
|
bottomedOut: false
|
||||||
|
}
|
||||||
|
},
|
||||||
computed: {
|
computed: {
|
||||||
notifications () {
|
notifications () {
|
||||||
return notificationsFromStore(this.$store)
|
return notificationsFromStore(this.$store)
|
||||||
|
@ -28,6 +33,9 @@ const Notifications = {
|
||||||
},
|
},
|
||||||
unseenCount () {
|
unseenCount () {
|
||||||
return this.unseenNotifications.length
|
return this.unseenNotifications.length
|
||||||
|
},
|
||||||
|
loading () {
|
||||||
|
return this.$store.state.statuses.notifications.loading
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
|
@ -49,10 +57,16 @@ const Notifications = {
|
||||||
fetchOlderNotifications () {
|
fetchOlderNotifications () {
|
||||||
const store = this.$store
|
const store = this.$store
|
||||||
const credentials = store.state.users.currentUser.credentials
|
const credentials = store.state.users.currentUser.credentials
|
||||||
|
store.commit('setNotificationsLoading', { value: true })
|
||||||
notificationsFetcher.fetchAndUpdate({
|
notificationsFetcher.fetchAndUpdate({
|
||||||
store,
|
store,
|
||||||
credentials,
|
credentials,
|
||||||
older: true
|
older: true
|
||||||
|
}).then(notifs => {
|
||||||
|
store.commit('setNotificationsLoading', { value: false })
|
||||||
|
if (notifs.length === 0) {
|
||||||
|
this.bottomedOut = true
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,10 +18,15 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-footer">
|
<div class="panel-footer">
|
||||||
<a href="#" v-on:click.prevent='fetchOlderNotifications()' v-if="!notifications.loading">
|
<div v-if="bottomedOut" class="new-status-notification text-center panel-footer faint">
|
||||||
|
{{$t('notifications.no_more_notifications')}}
|
||||||
|
</div>
|
||||||
|
<a v-else-if="!loading" href="#" v-on:click.prevent="fetchOlderNotifications()">
|
||||||
<div class="new-status-notification text-center panel-footer">{{$t('notifications.load_older')}}</div>
|
<div class="new-status-notification text-center panel-footer">{{$t('notifications.load_older')}}</div>
|
||||||
</a>
|
</a>
|
||||||
<div class="new-status-notification text-center panel-footer" v-else>...</div>
|
<div v-else class="new-status-notification text-center panel-footer">
|
||||||
|
<i class="icon-spin3 animate-spin"/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -6,10 +6,12 @@ import PostStatusForm from '../post_status_form/post_status_form.vue'
|
||||||
import UserCardContent from '../user_card_content/user_card_content.vue'
|
import UserCardContent from '../user_card_content/user_card_content.vue'
|
||||||
import StillImage from '../still-image/still-image.vue'
|
import StillImage from '../still-image/still-image.vue'
|
||||||
import Gallery from '../gallery/gallery.vue'
|
import Gallery from '../gallery/gallery.vue'
|
||||||
import { filter, find } from 'lodash'
|
import LinkPreview from '../link-preview/link-preview.vue'
|
||||||
import { highlightClass, highlightStyle } from '../../services/user_highlighter/user_highlighter.js'
|
|
||||||
import generateProfileLink from 'src/services/user_profile_link_generator/user_profile_link_generator'
|
import generateProfileLink from 'src/services/user_profile_link_generator/user_profile_link_generator'
|
||||||
import fileType from 'src/services/file_type/file_type.service'
|
import fileType from 'src/services/file_type/file_type.service'
|
||||||
|
import { highlightClass, highlightStyle } from '../../services/user_highlighter/user_highlighter.js'
|
||||||
|
import { mentionMatchesUrl } from 'src/services/mention_matcher/mention_matcher.js'
|
||||||
|
import { filter, find } from 'lodash'
|
||||||
|
|
||||||
const Status = {
|
const Status = {
|
||||||
name: 'Status',
|
name: 'Status',
|
||||||
|
@ -33,7 +35,7 @@ const Status = {
|
||||||
userExpanded: false,
|
userExpanded: false,
|
||||||
preview: null,
|
preview: null,
|
||||||
showPreview: false,
|
showPreview: false,
|
||||||
showingTall: false,
|
showingTall: this.inConversation && this.focused,
|
||||||
expandingSubject: typeof this.$store.state.config.collapseMessageWithSubject === 'undefined'
|
expandingSubject: typeof this.$store.state.config.collapseMessageWithSubject === 'undefined'
|
||||||
? !this.$store.state.instance.collapseMessageWithSubject
|
? !this.$store.state.instance.collapseMessageWithSubject
|
||||||
: !this.$store.state.config.collapseMessageWithSubject,
|
: !this.$store.state.config.collapseMessageWithSubject,
|
||||||
|
@ -81,7 +83,7 @@ const Status = {
|
||||||
},
|
},
|
||||||
replyProfileLink () {
|
replyProfileLink () {
|
||||||
if (this.isReply) {
|
if (this.isReply) {
|
||||||
return this.generateUserProfileLink(this.status.in_reply_to_status_id, this.replyToName)
|
return this.generateUserProfileLink(this.status.in_reply_to_user_id, this.replyToName)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
retweet () { return !!this.statusoid.retweeted_status },
|
retweet () { return !!this.statusoid.retweeted_status },
|
||||||
|
@ -181,7 +183,7 @@ const Status = {
|
||||||
return this.tallStatus
|
return this.tallStatus
|
||||||
},
|
},
|
||||||
showingMore () {
|
showingMore () {
|
||||||
return this.showingTall || (this.status.summary && this.expandingSubject)
|
return (this.tallStatus && this.showingTall) || (this.status.summary && this.expandingSubject)
|
||||||
},
|
},
|
||||||
nsfwClickthrough () {
|
nsfwClickthrough () {
|
||||||
if (!this.status.nsfw) {
|
if (!this.status.nsfw) {
|
||||||
|
@ -243,7 +245,8 @@ const Status = {
|
||||||
PostStatusForm,
|
PostStatusForm,
|
||||||
UserCardContent,
|
UserCardContent,
|
||||||
StillImage,
|
StillImage,
|
||||||
Gallery
|
Gallery,
|
||||||
|
LinkPreview
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
visibilityIcon (visibility) {
|
visibilityIcon (visibility) {
|
||||||
|
@ -258,11 +261,23 @@ const Status = {
|
||||||
return 'icon-globe'
|
return 'icon-globe'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
linkClicked ({target}) {
|
linkClicked (event) {
|
||||||
|
let { target } = event
|
||||||
if (target.tagName === 'SPAN') {
|
if (target.tagName === 'SPAN') {
|
||||||
target = target.parentNode
|
target = target.parentNode
|
||||||
}
|
}
|
||||||
if (target.tagName === 'A') {
|
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')
|
window.open(target.href, '_blank')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -287,11 +302,11 @@ const Status = {
|
||||||
toggleShowMore () {
|
toggleShowMore () {
|
||||||
if (this.showingTall) {
|
if (this.showingTall) {
|
||||||
this.showingTall = false
|
this.showingTall = false
|
||||||
} else if (this.expandingSubject) {
|
} else if (this.expandingSubject && this.status.summary) {
|
||||||
this.expandingSubject = false
|
this.expandingSubject = false
|
||||||
} else if (this.hideTallStatus) {
|
} else if (this.hideTallStatus) {
|
||||||
this.showingTall = true
|
this.showingTall = true
|
||||||
} else if (this.hideSubjectStatus) {
|
} else if (this.hideSubjectStatus && this.status.summary) {
|
||||||
this.expandingSubject = true
|
this.expandingSubject = true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -329,8 +344,13 @@ const Status = {
|
||||||
if (this.status.id === id) {
|
if (this.status.id === id) {
|
||||||
let rect = this.$el.getBoundingClientRect()
|
let rect = this.$el.getBoundingClientRect()
|
||||||
if (rect.top < 100) {
|
if (rect.top < 100) {
|
||||||
window.scrollBy(0, rect.top - 200)
|
// Post is above screen, match its top to screen top
|
||||||
|
window.scrollBy(0, rect.top - 100)
|
||||||
|
} else if (rect.height >= (window.innerHeight - 50)) {
|
||||||
|
// Post we want to see is taller than screen so match its top to screen top
|
||||||
|
window.scrollBy(0, rect.top - 100)
|
||||||
} else if (rect.bottom > window.innerHeight - 50) {
|
} else if (rect.bottom > window.innerHeight - 50) {
|
||||||
|
// Post is below screen, match its bottom to screen bottom
|
||||||
window.scrollBy(0, rect.bottom - window.innerHeight + 50)
|
window.scrollBy(0, rect.bottom - window.innerHeight + 50)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,9 +24,9 @@
|
||||||
|
|
||||||
<div :class="[userClass, { highlighted: userStyle, 'is-retweet': retweet }]" :style="[ userStyle ]" class="media status">
|
<div :class="[userClass, { highlighted: userStyle, 'is-retweet': retweet }]" :style="[ userStyle ]" class="media status">
|
||||||
<div v-if="!noHeading" class="media-left">
|
<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"/>
|
<StillImage class='avatar' :class="{'avatar-compact': compact, 'better-shadow': betterShadow}" :src="status.user.profile_image_url_original"/>
|
||||||
</a>
|
</router-link>
|
||||||
</div>
|
</div>
|
||||||
<div class="status-body">
|
<div class="status-body">
|
||||||
<div class="usercard media-body" v-if="userExpanded">
|
<div class="usercard media-body" v-if="userExpanded">
|
||||||
|
@ -112,6 +112,10 @@
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div v-if="status.card && !hideSubjectStatus && !noHeading" class="link-preview media-body">
|
||||||
|
<link-preview :card="status.card" :size="attachmentSize" :nsfw="nsfwClickthrough" />
|
||||||
|
</div>
|
||||||
|
|
||||||
<div v-if="!noHeading && !noReplyLinks" class='status-actions media-body'>
|
<div v-if="!noHeading && !noReplyLinks" class='status-actions media-body'>
|
||||||
<div v-if="loggedIn">
|
<div v-if="loggedIn">
|
||||||
<a href="#" v-on:click.prevent="toggleReplying" :title="$t('tool_tip.reply')">
|
<a href="#" v-on:click.prevent="toggleReplying" :title="$t('tool_tip.reply')">
|
||||||
|
@ -235,6 +239,11 @@
|
||||||
vertical-align: bottom;
|
vertical-align: bottom;
|
||||||
flex-basis: 100%;
|
flex-basis: 100%;
|
||||||
|
|
||||||
|
a {
|
||||||
|
display: inline-block;
|
||||||
|
word-break: break-all;
|
||||||
|
}
|
||||||
|
|
||||||
small {
|
small {
|
||||||
font-weight: lighter;
|
font-weight: lighter;
|
||||||
}
|
}
|
||||||
|
@ -310,11 +319,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
a {
|
|
||||||
display: inline-block;
|
|
||||||
word-break: break-all;
|
|
||||||
}
|
|
||||||
|
|
||||||
.tall-status {
|
.tall-status {
|
||||||
position: relative;
|
position: relative;
|
||||||
height: 220px;
|
height: 220px;
|
||||||
|
@ -323,6 +327,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.tall-status-hider {
|
.tall-status-hider {
|
||||||
|
display: inline-block;
|
||||||
|
word-break: break-all;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
height: 70px;
|
height: 70px;
|
||||||
margin-top: 150px;
|
margin-top: 150px;
|
||||||
|
@ -340,6 +346,8 @@
|
||||||
.status-unhider, .cw-status-hider {
|
.status-unhider, .cw-status-hider {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
display: inline-block;
|
||||||
|
word-break: break-all;
|
||||||
}
|
}
|
||||||
|
|
||||||
.status-content {
|
.status-content {
|
||||||
|
|
|
@ -16,7 +16,8 @@ const Timeline = {
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
paused: false,
|
paused: false,
|
||||||
unfocused: false
|
unfocused: false,
|
||||||
|
bottomedOut: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
@ -95,7 +96,12 @@ const Timeline = {
|
||||||
showImmediately: true,
|
showImmediately: true,
|
||||||
userId: this.userId,
|
userId: this.userId,
|
||||||
tag: this.tag
|
tag: this.tag
|
||||||
}).then(() => store.commit('setLoading', { timeline: this.timelineName, value: false }))
|
}).then(statuses => {
|
||||||
|
store.commit('setLoading', { timeline: this.timelineName, value: false })
|
||||||
|
if (statuses.length === 0) {
|
||||||
|
this.bottomedOut = true
|
||||||
|
}
|
||||||
|
})
|
||||||
}, 1000, this),
|
}, 1000, this),
|
||||||
scrollLoad (e) {
|
scrollLoad (e) {
|
||||||
const bodyBRect = document.body.getBoundingClientRect()
|
const bodyBRect = document.body.getBoundingClientRect()
|
||||||
|
|
|
@ -20,10 +20,15 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div :class="classes.footer">
|
<div :class="classes.footer">
|
||||||
<a href="#" v-on:click.prevent='fetchOlderStatuses()' v-if="!timeline.loading">
|
<div v-if="bottomedOut" class="new-status-notification text-center panel-footer faint">
|
||||||
|
{{$t('timeline.no_more_statuses')}}
|
||||||
|
</div>
|
||||||
|
<a v-else-if="!timeline.loading" href="#" v-on:click.prevent='fetchOlderStatuses()'>
|
||||||
<div class="new-status-notification text-center panel-footer">{{$t('timeline.load_older')}}</div>
|
<div class="new-status-notification text-center panel-footer">{{$t('timeline.load_older')}}</div>
|
||||||
</a>
|
</a>
|
||||||
<div class="new-status-notification text-center panel-footer" v-else>...</div>
|
<div v-else class="new-status-notification text-center panel-footer">
|
||||||
|
<i class="icon-spin3 animate-spin"/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -36,7 +36,8 @@ const UserProfile = {
|
||||||
return this.$route.params.name || this.user.screen_name
|
return this.$route.params.name || this.user.screen_name
|
||||||
},
|
},
|
||||||
isUs () {
|
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 () {
|
friends () {
|
||||||
return this.user.friends
|
return this.user.friends
|
||||||
|
|
|
@ -10,7 +10,8 @@ const UserSettings = {
|
||||||
newLocked: this.$store.state.users.currentUser.locked,
|
newLocked: this.$store.state.users.currentUser.locked,
|
||||||
newNoRichText: this.$store.state.users.currentUser.no_rich_text,
|
newNoRichText: this.$store.state.users.currentUser.no_rich_text,
|
||||||
newDefaultScope: this.$store.state.users.currentUser.default_scope,
|
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,
|
followList: null,
|
||||||
followImportError: false,
|
followImportError: false,
|
||||||
followsImported: false,
|
followsImported: false,
|
||||||
|
@ -66,7 +67,8 @@ const UserSettings = {
|
||||||
/* eslint-disable camelcase */
|
/* eslint-disable camelcase */
|
||||||
const default_scope = this.newDefaultScope
|
const default_scope = this.newDefaultScope
|
||||||
const no_rich_text = this.newNoRichText
|
const no_rich_text = this.newNoRichText
|
||||||
const hide_network = this.newHideNetwork
|
const hide_followings = this.hideFollowings
|
||||||
|
const hide_followers = this.hideFollowers
|
||||||
/* eslint-enable camelcase */
|
/* eslint-enable camelcase */
|
||||||
this.$store.state.api.backendInteractor
|
this.$store.state.api.backendInteractor
|
||||||
.updateProfile({
|
.updateProfile({
|
||||||
|
@ -78,7 +80,8 @@ const UserSettings = {
|
||||||
/* eslint-disable camelcase */
|
/* eslint-disable camelcase */
|
||||||
default_scope,
|
default_scope,
|
||||||
no_rich_text,
|
no_rich_text,
|
||||||
hide_network
|
hide_followings,
|
||||||
|
hide_followers
|
||||||
/* eslint-enable camelcase */
|
/* eslint-enable camelcase */
|
||||||
}}).then((user) => {
|
}}).then((user) => {
|
||||||
if (!user.error) {
|
if (!user.error) {
|
||||||
|
|
|
@ -30,8 +30,12 @@
|
||||||
<label for="account-no-rich-text">{{$t('settings.no_rich_text_description')}}</label>
|
<label for="account-no-rich-text">{{$t('settings.no_rich_text_description')}}</label>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<input type="checkbox" v-model="newHideNetwork" id="account-hide-network">
|
<input type="checkbox" v-model="hideFollowings" id="account-hide-followings">
|
||||||
<label for="account-hide-network">{{$t('settings.hide_network_description')}}</label>
|
<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>
|
</p>
|
||||||
<button :disabled='newName.length <= 0' class="btn btn-default" @click="updateProfile">{{$t('general.submit')}}</button>
|
<button :disabled='newName.length <= 0' class="btn btn-default" @click="updateProfile">{{$t('general.submit')}}</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -155,7 +155,8 @@
|
||||||
"notification_visibility_mentions": "Erwähnungen",
|
"notification_visibility_mentions": "Erwähnungen",
|
||||||
"notification_visibility_repeats": "Wiederholungen",
|
"notification_visibility_repeats": "Wiederholungen",
|
||||||
"no_rich_text_description": "Rich-Text Formatierungen von allen Beiträgen entfernen",
|
"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",
|
"nsfw_clickthrough": "Aktiviere ausblendbares Overlay für Anhänge, die als NSFW markiert sind",
|
||||||
"panelRadius": "Panel",
|
"panelRadius": "Panel",
|
||||||
"pause_on_unfocused": "Streaming pausieren, wenn das Tab nicht fokussiert ist",
|
"pause_on_unfocused": "Streaming pausieren, wenn das Tab nicht fokussiert ist",
|
||||||
|
|
|
@ -49,7 +49,8 @@
|
||||||
"load_older": "Load older notifications",
|
"load_older": "Load older notifications",
|
||||||
"notifications": "Notifications",
|
"notifications": "Notifications",
|
||||||
"read": "Read!",
|
"read": "Read!",
|
||||||
"repeated_you": "repeated your status"
|
"repeated_you": "repeated your status",
|
||||||
|
"no_more_notifications": "No more notifications"
|
||||||
},
|
},
|
||||||
"post_status": {
|
"post_status": {
|
||||||
"new_status": "Post new status",
|
"new_status": "Post new status",
|
||||||
|
@ -160,7 +161,8 @@
|
||||||
"notification_visibility_mentions": "Mentions",
|
"notification_visibility_mentions": "Mentions",
|
||||||
"notification_visibility_repeats": "Repeats",
|
"notification_visibility_repeats": "Repeats",
|
||||||
"no_rich_text_description": "Strip rich text formatting from all posts",
|
"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",
|
"nsfw_clickthrough": "Enable clickthrough NSFW attachment hiding",
|
||||||
"panelRadius": "Panels",
|
"panelRadius": "Panels",
|
||||||
"pause_on_unfocused": "Pause streaming when tab is not focused",
|
"pause_on_unfocused": "Pause streaming when tab is not focused",
|
||||||
|
@ -320,7 +322,8 @@
|
||||||
"no_retweet_hint": "Post is marked as followers-only or direct and cannot be repeated",
|
"no_retweet_hint": "Post is marked as followers-only or direct and cannot be repeated",
|
||||||
"repeated": "repeated",
|
"repeated": "repeated",
|
||||||
"show_new": "Show new",
|
"show_new": "Show new",
|
||||||
"up_to_date": "Up-to-date"
|
"up_to_date": "Up-to-date",
|
||||||
|
"no_more_statuses": "No more statuses"
|
||||||
},
|
},
|
||||||
"user_card": {
|
"user_card": {
|
||||||
"approve": "Approve",
|
"approve": "Approve",
|
||||||
|
|
|
@ -49,7 +49,8 @@
|
||||||
"load_older": "Lataa vanhempia ilmoituksia",
|
"load_older": "Lataa vanhempia ilmoituksia",
|
||||||
"notifications": "Ilmoitukset",
|
"notifications": "Ilmoitukset",
|
||||||
"read": "Lue!",
|
"read": "Lue!",
|
||||||
"repeated_you": "toisti viestisi"
|
"repeated_you": "toisti viestisi",
|
||||||
|
"no_more_notifications": "Ei enempää ilmoituksia"
|
||||||
},
|
},
|
||||||
"post_status": {
|
"post_status": {
|
||||||
"new_status": "Uusi viesti",
|
"new_status": "Uusi viesti",
|
||||||
|
@ -209,7 +210,8 @@
|
||||||
"no_retweet_hint": "Viesti ei ole julkinen, eikä sitä voi toistaa",
|
"no_retweet_hint": "Viesti ei ole julkinen, eikä sitä voi toistaa",
|
||||||
"repeated": "toisti",
|
"repeated": "toisti",
|
||||||
"show_new": "Näytä uudet",
|
"show_new": "Näytä uudet",
|
||||||
"up_to_date": "Ajantasalla"
|
"up_to_date": "Ajantasalla",
|
||||||
|
"no_more_statuses": "Ei enempää viestejä"
|
||||||
},
|
},
|
||||||
"user_card": {
|
"user_card": {
|
||||||
"approve": "Hyväksy",
|
"approve": "Hyväksy",
|
||||||
|
|
|
@ -157,7 +157,8 @@
|
||||||
"notification_visibility_mentions": "メンション",
|
"notification_visibility_mentions": "メンション",
|
||||||
"notification_visibility_repeats": "リピート",
|
"notification_visibility_repeats": "リピート",
|
||||||
"no_rich_text_description": "リッチテキストをつかわない",
|
"no_rich_text_description": "リッチテキストをつかわない",
|
||||||
"hide_network_description": "わたしがフォローしているひとと、わたしをフォローしているひとを、みせない",
|
"hide_followings_description": "フォローしている人を表示しない",
|
||||||
|
"hide_followers_description": "フォローしている人を表示しない",
|
||||||
"nsfw_clickthrough": "NSFWなファイルをかくす",
|
"nsfw_clickthrough": "NSFWなファイルをかくす",
|
||||||
"panelRadius": "パネル",
|
"panelRadius": "パネル",
|
||||||
"pause_on_unfocused": "タブにフォーカスがないときストリーミングをとめる",
|
"pause_on_unfocused": "タブにフォーカスがないときストリーミングをとめる",
|
||||||
|
|
|
@ -156,7 +156,8 @@
|
||||||
"notification_visibility_mentions": "멘션",
|
"notification_visibility_mentions": "멘션",
|
||||||
"notification_visibility_repeats": "반복",
|
"notification_visibility_repeats": "반복",
|
||||||
"no_rich_text_description": "모든 게시물의 서식을 지우기",
|
"no_rich_text_description": "모든 게시물의 서식을 지우기",
|
||||||
"hide_network_description": "내 팔로우와 팔로워를 숨기기",
|
"hide_followings_description": "내가 팔로우하는 사람을 표시하지 않음",
|
||||||
|
"hide_followers_description": "나를 따르는 사람을 보여주지 마라.",
|
||||||
"nsfw_clickthrough": "NSFW 이미지 \"클릭해서 보이기\"를 활성화",
|
"nsfw_clickthrough": "NSFW 이미지 \"클릭해서 보이기\"를 활성화",
|
||||||
"panelRadius": "패널",
|
"panelRadius": "패널",
|
||||||
"pause_on_unfocused": "탭이 활성 상태가 아닐 때 스트리밍 멈추기",
|
"pause_on_unfocused": "탭이 활성 상태가 아닐 때 스트리밍 멈추기",
|
||||||
|
|
|
@ -127,7 +127,8 @@
|
||||||
"notification_visibility_mentions": "Упоминания",
|
"notification_visibility_mentions": "Упоминания",
|
||||||
"notification_visibility_repeats": "Повторы",
|
"notification_visibility_repeats": "Повторы",
|
||||||
"no_rich_text_description": "Убрать форматирование из всех постов",
|
"no_rich_text_description": "Убрать форматирование из всех постов",
|
||||||
"hide_network_description": "Не показывать кого я читаю и кто меня читает",
|
"hide_followings_description": "Не показывать кого я читаю",
|
||||||
|
"hide_followers_description": "Не показывать кто читает меня",
|
||||||
"nsfw_clickthrough": "Включить скрытие NSFW вложений",
|
"nsfw_clickthrough": "Включить скрытие NSFW вложений",
|
||||||
"panelRadius": "Панели",
|
"panelRadius": "Панели",
|
||||||
"pause_on_unfocused": "Приостановить загрузку когда вкладка не в фокусе",
|
"pause_on_unfocused": "Приостановить загрузку когда вкладка не в фокусе",
|
||||||
|
|
|
@ -20,6 +20,9 @@ const api = {
|
||||||
removeFetcher (state, {timeline}) {
|
removeFetcher (state, {timeline}) {
|
||||||
delete state.fetchers[timeline]
|
delete state.fetchers[timeline]
|
||||||
},
|
},
|
||||||
|
setWsToken (state, token) {
|
||||||
|
state.wsToken = token
|
||||||
|
},
|
||||||
setSocket (state, socket) {
|
setSocket (state, socket) {
|
||||||
state.socket = socket
|
state.socket = socket
|
||||||
},
|
},
|
||||||
|
@ -51,10 +54,14 @@ const api = {
|
||||||
window.clearInterval(fetcher)
|
window.clearInterval(fetcher)
|
||||||
store.commit('removeFetcher', {timeline})
|
store.commit('removeFetcher', {timeline})
|
||||||
},
|
},
|
||||||
initializeSocket (store, token) {
|
setWsToken (store, token) {
|
||||||
|
store.commit('setWsToken', token)
|
||||||
|
},
|
||||||
|
initializeSocket (store) {
|
||||||
// Set up websocket connection
|
// Set up websocket connection
|
||||||
if (!store.state.chatDisabled) {
|
if (!store.state.chatDisabled) {
|
||||||
let socket = new Socket('/socket', {params: {token: token}})
|
const token = store.state.wsToken
|
||||||
|
const socket = new Socket('/socket', {params: {token}})
|
||||||
socket.connect()
|
socket.connect()
|
||||||
store.dispatch('initializeChat', socket)
|
store.dispatch('initializeChat', socket)
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { remove, slice, each, find, maxBy, minBy, merge, last, isArray } from 'l
|
||||||
import apiService from '../services/api/api.service.js'
|
import apiService from '../services/api/api.service.js'
|
||||||
// import parse from '../services/status_parser/status_parser.js'
|
// import parse from '../services/status_parser/status_parser.js'
|
||||||
|
|
||||||
const emptyTl = () => ({
|
const emptyTl = (userId = 0) => ({
|
||||||
statuses: [],
|
statuses: [],
|
||||||
statusesObject: {},
|
statusesObject: {},
|
||||||
faves: [],
|
faves: [],
|
||||||
|
@ -14,7 +14,7 @@ const emptyTl = () => ({
|
||||||
loading: false,
|
loading: false,
|
||||||
followers: [],
|
followers: [],
|
||||||
friends: [],
|
friends: [],
|
||||||
userId: 0,
|
userId,
|
||||||
flushMarker: 0
|
flushMarker: 0
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@ export const defaultState = {
|
||||||
minId: Number.POSITIVE_INFINITY,
|
minId: Number.POSITIVE_INFINITY,
|
||||||
data: [],
|
data: [],
|
||||||
idStore: {},
|
idStore: {},
|
||||||
|
loading: false,
|
||||||
error: false
|
error: false
|
||||||
},
|
},
|
||||||
favorites: new Set(),
|
favorites: new Set(),
|
||||||
|
@ -319,7 +320,7 @@ export const mutations = {
|
||||||
each(oldTimeline.visibleStatuses, (status) => { oldTimeline.visibleStatusesObject[status.id] = status })
|
each(oldTimeline.visibleStatuses, (status) => { oldTimeline.visibleStatusesObject[status.id] = status })
|
||||||
},
|
},
|
||||||
clearTimeline (state, { timeline }) {
|
clearTimeline (state, { timeline }) {
|
||||||
state.timelines[timeline] = emptyTl()
|
state.timelines[timeline] = emptyTl(state.timelines[timeline].userId)
|
||||||
},
|
},
|
||||||
setFavorited (state, { status, value }) {
|
setFavorited (state, { status, value }) {
|
||||||
const newStatus = state.allStatusesObject[status.id]
|
const newStatus = state.allStatusesObject[status.id]
|
||||||
|
@ -348,6 +349,9 @@ export const mutations = {
|
||||||
setError (state, { value }) {
|
setError (state, { value }) {
|
||||||
state.error = value
|
state.error = value
|
||||||
},
|
},
|
||||||
|
setNotificationsLoading (state, { value }) {
|
||||||
|
state.notifications.loading = value
|
||||||
|
},
|
||||||
setNotificationsError (state, { value }) {
|
setNotificationsError (state, { value }) {
|
||||||
state.notifications.error = value
|
state.notifications.error = value
|
||||||
},
|
},
|
||||||
|
@ -376,6 +380,9 @@ const statuses = {
|
||||||
setError ({ rootState, commit }, { value }) {
|
setError ({ rootState, commit }, { value }) {
|
||||||
commit('setError', { value })
|
commit('setError', { value })
|
||||||
},
|
},
|
||||||
|
setNotificationsLoading ({ rootState, commit }, { value }) {
|
||||||
|
commit('setNotificationsLoading', { value })
|
||||||
|
},
|
||||||
setNotificationsError ({ rootState, commit }, { value }) {
|
setNotificationsError ({ rootState, commit }, { value }) {
|
||||||
commit('setNotificationsError', { value })
|
commit('setNotificationsError', { value })
|
||||||
},
|
},
|
||||||
|
|
|
@ -91,7 +91,9 @@ export const getters = {
|
||||||
userById: state => id =>
|
userById: state => id =>
|
||||||
state.users.find(user => user.id === id),
|
state.users.find(user => user.id === id),
|
||||||
userByName: state => name =>
|
userByName: state => name =>
|
||||||
state.users.find(user => user.screen_name === name)
|
state.users.find(user => user.screen_name &&
|
||||||
|
(user.screen_name.toLowerCase() === name.toLowerCase())
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const defaultState = {
|
export const defaultState = {
|
||||||
|
@ -222,10 +224,10 @@ const users = {
|
||||||
commit('setBackendInteractor', backendInteractorService(accessToken))
|
commit('setBackendInteractor', backendInteractorService(accessToken))
|
||||||
|
|
||||||
if (user.token) {
|
if (user.token) {
|
||||||
store.dispatch('initializeSocket', user.token)
|
store.dispatch('setWsToken', user.token)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start getting fresh tweets.
|
// Start getting fresh posts.
|
||||||
store.dispatch('startFetching', 'friends')
|
store.dispatch('startFetching', 'friends')
|
||||||
|
|
||||||
// Get user mutes and follower info
|
// Get user mutes and follower info
|
||||||
|
|
|
@ -130,7 +130,7 @@ const updateBanner = ({credentials, params}) => {
|
||||||
// description
|
// description
|
||||||
const updateProfile = ({credentials, params}) => {
|
const updateProfile = ({credentials, params}) => {
|
||||||
// Always include these fields, because they might be empty or false
|
// 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
|
let url = PROFILE_UPDATE_URL
|
||||||
|
|
||||||
const form = new FormData()
|
const form = new FormData()
|
||||||
|
|
|
@ -100,7 +100,8 @@ export const parseUser = (data) => {
|
||||||
output.rights = data.rights
|
output.rights = data.rights
|
||||||
output.no_rich_text = data.no_rich_text
|
output.no_rich_text = data.no_rich_text
|
||||||
output.default_scope = data.default_scope
|
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
|
output.background_image = data.background_image
|
||||||
// on mastoapi this info is contained in a "relationship"
|
// on mastoapi this info is contained in a "relationship"
|
||||||
output.following = data.following
|
output.following = data.following
|
||||||
|
@ -215,6 +216,7 @@ export const parseStatus = (data) => {
|
||||||
|
|
||||||
output.id = String(data.id)
|
output.id = String(data.id)
|
||||||
output.visibility = data.visibility
|
output.visibility = data.visibility
|
||||||
|
output.card = data.card
|
||||||
output.created_at = new Date(data.created_at)
|
output.created_at = new Date(data.created_at)
|
||||||
|
|
||||||
// Converting to string, the right way.
|
// Converting to string, the right way.
|
||||||
|
|
9
src/services/mention_matcher/mention_matcher.js
Normal file
9
src/services/mention_matcher/mention_matcher.js
Normal file
|
@ -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)
|
||||||
|
}
|
|
@ -24,6 +24,7 @@ const fetchAndUpdate = ({store, credentials, older = false}) => {
|
||||||
return apiService.fetchTimeline(args)
|
return apiService.fetchTimeline(args)
|
||||||
.then((notifications) => {
|
.then((notifications) => {
|
||||||
update({store, notifications, older})
|
update({store, notifications, older})
|
||||||
|
return notifications
|
||||||
}, () => store.dispatch('setNotificationsError', { value: true }))
|
}, () => store.dispatch('setNotificationsError', { value: true }))
|
||||||
.catch(() => store.dispatch('setNotificationsError', { value: true }))
|
.catch(() => store.dispatch('setNotificationsError', { value: true }))
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,12 +29,15 @@ const fetchAndUpdate = ({store, credentials, timeline = 'friends', older = false
|
||||||
args['userId'] = userId
|
args['userId'] = userId
|
||||||
args['tag'] = tag
|
args['tag'] = tag
|
||||||
|
|
||||||
|
const numStatusesBeforeFetch = timelineData.statuses.length
|
||||||
|
|
||||||
return apiService.fetchTimeline(args)
|
return apiService.fetchTimeline(args)
|
||||||
.then((statuses) => {
|
.then((statuses) => {
|
||||||
if (!older && statuses.length >= 20 && !timelineData.loading && timelineData.statuses.length) {
|
if (!older && statuses.length >= 20 && !timelineData.loading && numStatusesBeforeFetch > 0) {
|
||||||
store.dispatch('queueFlush', { timeline: timeline, id: timelineData.maxId })
|
store.dispatch('queueFlush', { timeline: timeline, id: timelineData.maxId })
|
||||||
}
|
}
|
||||||
update({store, statuses, timeline, showImmediately, userId})
|
update({store, statuses, timeline, showImmediately, userId})
|
||||||
|
return statuses
|
||||||
}, () => store.dispatch('setError', { value: true }))
|
}, () => store.dispatch('setError', { value: true }))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -240,6 +240,15 @@ describe('The Statuses module', () => {
|
||||||
expect(state.timelines.public.visibleStatuses[0].favorited).to.eql(true)
|
expect(state.timelines.public.visibleStatuses[0].favorited).to.eql(true)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('keeps userId when clearing user timeline', () => {
|
||||||
|
const state = cloneDeep(defaultState)
|
||||||
|
state.timelines.user.userId = 123
|
||||||
|
|
||||||
|
mutations.clearTimeline(state, { timeline: 'user' })
|
||||||
|
|
||||||
|
expect(state.timelines.user.userId).to.eql(123)
|
||||||
|
})
|
||||||
|
|
||||||
describe('notifications', () => {
|
describe('notifications', () => {
|
||||||
it('removes a notification when the notice gets removed', () => {
|
it('removes a notification when the notice gets removed', () => {
|
||||||
const user = { id: '1' }
|
const user = { id: '1' }
|
||||||
|
|
|
@ -45,6 +45,17 @@ describe('The users module', () => {
|
||||||
const expected = { screen_name: 'Guy', id: '1' }
|
const expected = { screen_name: 'Guy', id: '1' }
|
||||||
expect(getters.userByName(state)(name)).to.eql(expected)
|
expect(getters.userByName(state)(name)).to.eql(expected)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('returns user with matching screen_name with different case', () => {
|
||||||
|
const state = {
|
||||||
|
users: [
|
||||||
|
{ screen_name: 'guy', id: '1' }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
const name = 'Guy'
|
||||||
|
const expected = { screen_name: 'guy', id: '1' }
|
||||||
|
expect(getters.userByName(state)(name)).to.eql(expected)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('getUserById', () => {
|
describe('getUserById', () => {
|
||||||
|
|
|
@ -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)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
Loading…
Reference in a new issue