mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
fix(webapp): show hint that message is being saved (#8690)
* Show hint that message is being saved * Translate transmitting message
This commit is contained in:
parent
2b457a5823
commit
252b4a037f
@ -69,6 +69,14 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-for="message in messages.filter((m) => m.isUploading)"
|
||||||
|
:slot="'message_' + message._id"
|
||||||
|
v-bind:key="message._id"
|
||||||
|
>
|
||||||
|
{{ $t('chat.transmitting') }}
|
||||||
|
</div>
|
||||||
|
|
||||||
<div v-for="room in rooms" :slot="'room-list-avatar_' + room.id" :key="room.id">
|
<div v-for="room in rooms" :slot="'room-list-avatar_' + room.id" :key="room.id">
|
||||||
<div
|
<div
|
||||||
v-if="room.avatar"
|
v-if="room.avatar"
|
||||||
@ -394,6 +402,35 @@ export default {
|
|||||||
if (filesToUpload && filesToUpload.length > 0) {
|
if (filesToUpload && filesToUpload.length > 0) {
|
||||||
mutationVariables.files = filesToUpload
|
mutationVariables.files = filesToUpload
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Immediately add new message
|
||||||
|
const localMessage = {
|
||||||
|
...messageDetails,
|
||||||
|
_id: 'new',
|
||||||
|
seen: false,
|
||||||
|
saved: false,
|
||||||
|
date: new Date(),
|
||||||
|
senderId: this.currentUser.id,
|
||||||
|
files:
|
||||||
|
messageDetails.files?.map((file) => ({
|
||||||
|
...file,
|
||||||
|
url: URL.createObjectURL(new Blob([file.blob], { type: file.type })),
|
||||||
|
})) ?? [],
|
||||||
|
// Custom property
|
||||||
|
isUploading: true,
|
||||||
|
}
|
||||||
|
this.messages = [...this.messages, localMessage]
|
||||||
|
|
||||||
|
const roomIndex = this.rooms.findIndex((r) => r.id === roomId)
|
||||||
|
if (roomIndex !== -1) {
|
||||||
|
const changedRoom = { ...this.rooms[roomIndex] }
|
||||||
|
changedRoom.lastMessage.content = content
|
||||||
|
|
||||||
|
// Move changed room to the top of the list
|
||||||
|
changedRoom.index = changedRoom.lastMessage.date
|
||||||
|
this.rooms = [changedRoom, ...this.rooms.filter((r) => r.id !== roomId)]
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { data } = await this.$apollo.mutate({
|
const { data } = await this.$apollo.mutate({
|
||||||
mutation: createMessageMutation(),
|
mutation: createMessageMutation(),
|
||||||
@ -401,17 +438,10 @@ export default {
|
|||||||
})
|
})
|
||||||
const createdMessagePayload = data.CreateMessage
|
const createdMessagePayload = data.CreateMessage
|
||||||
|
|
||||||
if (createdMessagePayload) {
|
if (createdMessagePayload && roomIndex !== -1) {
|
||||||
const roomIndex = this.rooms.findIndex((r) => r.id === roomId)
|
|
||||||
if (roomIndex !== -1) {
|
|
||||||
const changedRoom = { ...this.rooms[roomIndex] }
|
const changedRoom = { ...this.rooms[roomIndex] }
|
||||||
changedRoom.lastMessage.content = createdMessagePayload.content.trim().substring(0, 30)
|
changedRoom.lastMessage.content = createdMessagePayload.content.trim().substring(0, 30)
|
||||||
changedRoom.lastMessage.date = createdMessagePayload.date
|
changedRoom.lastMessage.date = createdMessagePayload.date
|
||||||
|
|
||||||
// Move changed room to the top of the list
|
|
||||||
changedRoom.index = createdMessagePayload.date
|
|
||||||
this.rooms = [changedRoom, ...this.rooms.filter((r) => r.id !== roomId)]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.$toast.error(error.message)
|
this.$toast.error(error.message)
|
||||||
|
|||||||
@ -130,6 +130,7 @@
|
|||||||
"roomEmpty": "Keinen Raum selektiert",
|
"roomEmpty": "Keinen Raum selektiert",
|
||||||
"roomsEmpty": "Keine Räume",
|
"roomsEmpty": "Keine Räume",
|
||||||
"search": "Chat-Räume filtern",
|
"search": "Chat-Räume filtern",
|
||||||
|
"transmitting": "Nachricht wird übertragen ...",
|
||||||
"typeMessage": "Nachricht schreiben",
|
"typeMessage": "Nachricht schreiben",
|
||||||
"userProfileButton": {
|
"userProfileButton": {
|
||||||
"label": "Chat",
|
"label": "Chat",
|
||||||
|
|||||||
@ -130,6 +130,7 @@
|
|||||||
"roomEmpty": "No room selected",
|
"roomEmpty": "No room selected",
|
||||||
"roomsEmpty": "No rooms",
|
"roomsEmpty": "No rooms",
|
||||||
"search": "Filter chat rooms",
|
"search": "Filter chat rooms",
|
||||||
|
"transmitting": "Transmitting message ...",
|
||||||
"typeMessage": "Type message",
|
"typeMessage": "Type message",
|
||||||
"userProfileButton": {
|
"userProfileButton": {
|
||||||
"label": "Chat",
|
"label": "Chat",
|
||||||
|
|||||||
@ -130,6 +130,7 @@
|
|||||||
"roomEmpty": null,
|
"roomEmpty": null,
|
||||||
"roomsEmpty": null,
|
"roomsEmpty": null,
|
||||||
"search": "Filtrar salas de chat",
|
"search": "Filtrar salas de chat",
|
||||||
|
"transmitting": null,
|
||||||
"typeMessage": null,
|
"typeMessage": null,
|
||||||
"userProfileButton": {
|
"userProfileButton": {
|
||||||
"label": null,
|
"label": null,
|
||||||
|
|||||||
@ -130,6 +130,7 @@
|
|||||||
"roomEmpty": null,
|
"roomEmpty": null,
|
||||||
"roomsEmpty": null,
|
"roomsEmpty": null,
|
||||||
"search": "Filtrer les salons de chat",
|
"search": "Filtrer les salons de chat",
|
||||||
|
"transmitting": null,
|
||||||
"typeMessage": null,
|
"typeMessage": null,
|
||||||
"userProfileButton": {
|
"userProfileButton": {
|
||||||
"label": null,
|
"label": null,
|
||||||
|
|||||||
@ -130,6 +130,7 @@
|
|||||||
"roomEmpty": null,
|
"roomEmpty": null,
|
||||||
"roomsEmpty": null,
|
"roomsEmpty": null,
|
||||||
"search": null,
|
"search": null,
|
||||||
|
"transmitting": null,
|
||||||
"typeMessage": null,
|
"typeMessage": null,
|
||||||
"userProfileButton": {
|
"userProfileButton": {
|
||||||
"label": null,
|
"label": null,
|
||||||
|
|||||||
@ -130,6 +130,7 @@
|
|||||||
"roomEmpty": null,
|
"roomEmpty": null,
|
||||||
"roomsEmpty": null,
|
"roomsEmpty": null,
|
||||||
"search": null,
|
"search": null,
|
||||||
|
"transmitting": null,
|
||||||
"typeMessage": null,
|
"typeMessage": null,
|
||||||
"userProfileButton": {
|
"userProfileButton": {
|
||||||
"label": null,
|
"label": null,
|
||||||
|
|||||||
@ -130,6 +130,7 @@
|
|||||||
"roomEmpty": null,
|
"roomEmpty": null,
|
||||||
"roomsEmpty": null,
|
"roomsEmpty": null,
|
||||||
"search": null,
|
"search": null,
|
||||||
|
"transmitting": null,
|
||||||
"typeMessage": null,
|
"typeMessage": null,
|
||||||
"userProfileButton": {
|
"userProfileButton": {
|
||||||
"label": null,
|
"label": null,
|
||||||
|
|||||||
@ -130,6 +130,7 @@
|
|||||||
"roomEmpty": null,
|
"roomEmpty": null,
|
||||||
"roomsEmpty": null,
|
"roomsEmpty": null,
|
||||||
"search": null,
|
"search": null,
|
||||||
|
"transmitting": null,
|
||||||
"typeMessage": null,
|
"typeMessage": null,
|
||||||
"userProfileButton": {
|
"userProfileButton": {
|
||||||
"label": null,
|
"label": null,
|
||||||
|
|||||||
@ -130,6 +130,7 @@
|
|||||||
"roomEmpty": null,
|
"roomEmpty": null,
|
||||||
"roomsEmpty": null,
|
"roomsEmpty": null,
|
||||||
"search": null,
|
"search": null,
|
||||||
|
"transmitting": null,
|
||||||
"typeMessage": null,
|
"typeMessage": null,
|
||||||
"userProfileButton": {
|
"userProfileButton": {
|
||||||
"label": null,
|
"label": null,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user