WIP attachments
This commit is contained in:
parent
c273560408
commit
86cc4ce08d
8 changed files with 48 additions and 15 deletions
|
@ -325,11 +325,24 @@ const Chat = {
|
|||
})
|
||||
this.fetchChat(true, chatId)
|
||||
},
|
||||
poster ({ status }) {
|
||||
return this.backendInteractor.postChatMessage({
|
||||
poster (opts) {
|
||||
const status = opts.status
|
||||
|
||||
if (!status) {
|
||||
// TODO:
|
||||
return Promise.resolve({ error: this.$t('chats.empty_message_error') })
|
||||
}
|
||||
|
||||
let params = {
|
||||
id: this.currentChat.id,
|
||||
content: status
|
||||
})
|
||||
}
|
||||
|
||||
if (opts.media && opts.media[0]) {
|
||||
params.mediaId = opts.media[0].id
|
||||
}
|
||||
|
||||
return this.backendInteractor.postChatMessage(params)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -76,7 +76,6 @@
|
|||
:disable-subject="true"
|
||||
:disable-scope-selector="true"
|
||||
:disable-notice="true"
|
||||
:disable-attachments="true"
|
||||
:disable-polls="true"
|
||||
:poster="poster"
|
||||
:preserve-focus="true"
|
||||
|
|
|
@ -46,12 +46,19 @@ const ChatMessage = {
|
|||
return this.chatViewItem.type === 'message'
|
||||
},
|
||||
messageForStatusContent () {
|
||||
return {
|
||||
let result = {
|
||||
summary: '',
|
||||
statusnet_html: this.message.content,
|
||||
text: this.message.content,
|
||||
attachments: []
|
||||
text: this.message.content
|
||||
}
|
||||
|
||||
if (this.message.attachment) {
|
||||
result.attachments = [this.message.attachment]
|
||||
} else {
|
||||
result.attachments = []
|
||||
}
|
||||
|
||||
return result
|
||||
},
|
||||
...mapState({
|
||||
betterShadow: state => state.interface.browserSupport.cssFilter,
|
||||
|
|
|
@ -36,7 +36,6 @@ const PostStatusForm = {
|
|||
'disableScopeSelector',
|
||||
'disableNotice',
|
||||
'disablePolls',
|
||||
'disableAttachments',
|
||||
'placeholder',
|
||||
'maxHeight',
|
||||
'poster',
|
||||
|
|
|
@ -169,7 +169,6 @@
|
|||
>
|
||||
<div class="form-bottom-left">
|
||||
<media-upload
|
||||
v-if="disableAttachments !== true"
|
||||
ref="mediaUpload"
|
||||
class="media-upload-icon"
|
||||
:drop-files="dropFiles"
|
||||
|
@ -179,7 +178,6 @@
|
|||
/>
|
||||
<div
|
||||
class="emoji-icon"
|
||||
:style="{ 'text-align' : (disableAttachments ? 'left' : 'center') }"
|
||||
>
|
||||
<i
|
||||
:title="$t('emoji.add_emoji')"
|
||||
|
@ -516,4 +514,11 @@
|
|||
z-index: 4;
|
||||
}
|
||||
}
|
||||
|
||||
// todo: unify with attachment.vue (otherwise images the uploaded images are not minified unless a status with an attachment was displayed before)
|
||||
img.media-upload {
|
||||
line-height: 0;
|
||||
max-height: 200px;
|
||||
max-width: 100%;
|
||||
}
|
||||
</style>
|
||||
|
|
|
@ -758,7 +758,8 @@
|
|||
"write_message": "Write a message",
|
||||
"delete": "Delete",
|
||||
"chats": "Chats",
|
||||
"new": "New Chat"
|
||||
"new": "New Chat",
|
||||
"empty_message_error": "Cannot post empty message"
|
||||
},
|
||||
"display_date": {
|
||||
"today": "Today"
|
||||
|
|
|
@ -1158,13 +1158,19 @@ const chatMessages = ({ id, credentials }) => {
|
|||
})
|
||||
}
|
||||
|
||||
const postChatMessage = ({ id, content, credentials }) => {
|
||||
const postChatMessage = ({ id, content, mediaId = null, credentials }) => {
|
||||
let payload = {
|
||||
'content': content
|
||||
}
|
||||
|
||||
if (mediaId) {
|
||||
payload['media_id'] = mediaId
|
||||
}
|
||||
|
||||
return promisedRequest({
|
||||
url: PLEROMA_CHAT_MESSAGES_URL(id),
|
||||
method: 'POST',
|
||||
payload: {
|
||||
'content': content
|
||||
},
|
||||
payload: payload,
|
||||
credentials
|
||||
})
|
||||
}
|
||||
|
|
|
@ -386,5 +386,8 @@ export const parseChatMessage = (message) => {
|
|||
output.id = parseInt(message.id, 10)
|
||||
output.created_at = new Date(message.created_at)
|
||||
output.chat_id = parseInt(message.chat_id, 10)
|
||||
if (message.attachment) {
|
||||
output.attachment = parseAttachment(message.attachment)
|
||||
}
|
||||
return output
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue