kopia lustrzana https://github.com/nextcloud/social
Properly send to data when creating a post
Signed-off-by: Julius Härtl <jus@bitgrid.net>pull/18/head
rodzic
bb1fceb801
commit
29469ef10a
|
@ -386,13 +386,27 @@ export default {
|
|||
}
|
||||
]
|
||||
},
|
||||
getCleanPost() {
|
||||
getPostData() {
|
||||
let element = this.$refs.composerInput.cloneNode(true)
|
||||
Array.from(element.getElementsByClassName('emoji')).forEach((emoji) => {
|
||||
var em = document.createTextNode(emoji.getAttribute('alt'))
|
||||
emoji.replaceWith(em)
|
||||
})
|
||||
return element.innerText
|
||||
let to = []
|
||||
const re = /@((\w+)(@[\w.]+)?)/g
|
||||
let match = null
|
||||
do {
|
||||
match = re.exec(element.innerText)
|
||||
if (match) {
|
||||
to.push(match[1])
|
||||
}
|
||||
} while (match)
|
||||
|
||||
return {
|
||||
content: element.innerText,
|
||||
to: to,
|
||||
type: this.type
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
@ -411,10 +425,7 @@ export default {
|
|||
this.menuOpened = false
|
||||
},
|
||||
createPost(event) {
|
||||
this.$store.dispatch('post', {
|
||||
content: this.getCleanPost,
|
||||
type: this.type
|
||||
}).then((response) => {
|
||||
this.$store.dispatch('post', this.getPostData).then((response) => {
|
||||
this.post = ''
|
||||
this.$refs.composerInput.innerText = this.post
|
||||
})
|
||||
|
|
|
@ -32,6 +32,10 @@ const mutations = {
|
|||
state.since = data[item].published
|
||||
state.timeline.push(data[item])
|
||||
}
|
||||
},
|
||||
addPost(state, data) {
|
||||
// FIXME: push data we receive to the timeline array
|
||||
// state.timeline.push(data)
|
||||
}
|
||||
}
|
||||
const getters = {
|
||||
|
@ -43,6 +47,9 @@ const actions = {
|
|||
post(context, post) {
|
||||
return axios.post(OC.generateUrl('apps/social/api/v1/post'), { data: post }).then((response) => {
|
||||
context.commit('addPost', { data: response.data })
|
||||
}).catch((error) => {
|
||||
OC.Notification.showTemporary('Failed to create a post')
|
||||
console.error('Failed to create a post', error)
|
||||
})
|
||||
},
|
||||
fetchTimeline(context, account) {
|
||||
|
|
Ładowanie…
Reference in New Issue