forked from AkkomaGang/akkoma-fe
Make mention strings work.
This commit is contained in:
parent
7e2c52b12c
commit
9ff8bf4c14
2 changed files with 31 additions and 3 deletions
|
@ -1,12 +1,40 @@
|
||||||
import statusPoster from '../../services/status_poster/status_poster.service.js'
|
import statusPoster from '../../services/status_poster/status_poster.service.js'
|
||||||
|
import { reject, map, uniqBy } from 'lodash';
|
||||||
|
|
||||||
|
const buildMentionsString = ({user, attentions}, currentUser) => {
|
||||||
|
|
||||||
|
let allAttentions = [...attentions]
|
||||||
|
|
||||||
|
allAttentions.unshift(user)
|
||||||
|
|
||||||
|
allAttentions = uniqBy(allAttentions, 'id')
|
||||||
|
allAttentions = reject(allAttentions, {id: currentUser.id})
|
||||||
|
|
||||||
|
let mentions = map(allAttentions, (attention) => {
|
||||||
|
return `@${attention.screen_name}`
|
||||||
|
})
|
||||||
|
|
||||||
|
return mentions.join(' ') + ' '
|
||||||
|
}
|
||||||
|
|
||||||
const PostStatusForm = {
|
const PostStatusForm = {
|
||||||
props: [
|
props: [
|
||||||
'replyTo'
|
'replyTo',
|
||||||
|
'repliedUser',
|
||||||
|
'attentions'
|
||||||
],
|
],
|
||||||
data () {
|
data () {
|
||||||
|
let statusText = ''
|
||||||
|
|
||||||
|
if (this.replyTo) {
|
||||||
|
const currentUser = this.$store.state.users.currentUser
|
||||||
|
statusText = buildMentionsString({ user: this.repliedUser, attentions: this.attentions }, currentUser)
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
newStatus: { }
|
newStatus: {
|
||||||
|
status: statusText
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
<favorite-button :status=status></favorite-button>
|
<favorite-button :status=status></favorite-button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<post-status-form v-if="replying" :reply-to="status.id"></post-status-form>
|
<post-status-form v-if="replying" :reply-to="status.id" :attentions="status.attentions" :repliedUser="status.user"></post-status-form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue