Skip to content

Commit

Permalink
Merge branch 'feature/discussions' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Aldemylla committed Nov 16, 2023
2 parents 57a6209 + 75d7f8d commit 633fead
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 16 deletions.
7 changes: 7 additions & 0 deletions src/components/chats/ContactInfo/ModalStartDiscussion.vue
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,13 @@ export default {
initial_message: this.message,
});
if (this.$route.path !== 'discussion' && responseDiscussion.uuid) {
this.$router.push({
name: 'discussion',
params: { discussionId: responseDiscussion.uuid },
});
}
this.close();
if (!responseDiscussion.status) {
Expand Down
6 changes: 3 additions & 3 deletions src/components/chats/DiscussionSidebar/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,10 @@ export default {
}
.discussion-sidebar {
padding: $unnnic-spacing-xs;
padding-bottom: $unnnic-spacing-sm;
&__room {
padding: $unnnic-spacing-xs;
padding-bottom: $unnnic-spacing-sm;
display: flex;
flex-direction: column;
gap: $unnnic-spacing-xs;
Expand Down
8 changes: 6 additions & 2 deletions src/components/chats/MessageManager/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@

<unnnic-button
v-if="discussionId && showActionButton"
@click="openFileUploader"
@click="openFileUploader([])"
type="secondary"
size="large"
iconCenter="attachment"
Expand All @@ -71,7 +71,7 @@
:title="$t('record_audio')"
/>
<more-actions-option
:action="openFileUploader"
:action="openFileUploader([])"
icon="attachment"
:title="$t('attach')"
/>
Expand Down Expand Up @@ -419,6 +419,10 @@ export default {
justify-content: flex-end;
padding-right: $unnnic-spacing-stack-sm;
:deep(.audio-player) {
width: auto;
}
}
}
</style>
20 changes: 11 additions & 9 deletions src/services/api/resources/chats/message.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,25 +103,27 @@ export default {
return response.data;
},

async sendDiscussionMedia(roomId, { media, updateLoadingFiles }) {
const msg = await this.sendDiscussionMessage(roomId, {
text: '',
});
updateLoadingFiles?.(msg.uuid, 0);
async sendDiscussionMedia(discussionUuid, { media, updateLoadingFiles }) {
console.log('media', media);
console.log('updateLoadingFiles', updateLoadingFiles);

const mediaUuid = media.name + Date.now();

updateLoadingFiles?.(mediaUuid, 0);
const response = await http.postForm(
'/media/',
`/discussion/${discussionUuid}/send_media_messages/`,
{
content_type: media.type,
discussion_message: msg.uuid,
text: '',
media_file: media,
},
{
onUploadProgress: (event) => {
const progress = event.loaded / event.total;
updateLoadingFiles?.(msg.uuid, progress);
updateLoadingFiles?.(mediaUuid, progress);
},
},
);
return response.data;
return response.data?.media?.[0];
},
};
2 changes: 1 addition & 1 deletion src/store/modules/chats/discussionMessages.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ export default {
await sendMedias({
itemType: 'discussion',
itemUuid: activeDiscussion.uuid,
itemUser: activeDiscussion.user,
itemUser: activeDiscussion.user || { email: Profile.state.me?.email },
medias,
sendItemMedia: (media) =>
Message.sendDiscussionMedia(activeDiscussion.uuid, {
Expand Down
2 changes: 1 addition & 1 deletion src/views/chats/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ export default {
openFileUploader(files) {
this.$refs.fileUploader.open();
if (files) {
if (files?.length > 0) {
this.files = [...files];
}
},
Expand Down

0 comments on commit 633fead

Please sign in to comment.