Skip to content

Commit

Permalink
feat(sidebar): display other message types in message preview (#4493)
Browse files Browse the repository at this point in the history
* feat(i18n): add messaging strings

* chore(i18n): add comment for i18n-t

* feat(sidebar): display other message types in message preview

* fix(attachment): fix download button alignment
  • Loading branch information
jasonwoodland committed Aug 26, 2022
1 parent 53f3519 commit 3219640
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 16 deletions.
2 changes: 1 addition & 1 deletion components/views/chat/message/attachments/Item/Item.less
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
}

.file-info {
flex-shrink: 1;
flex: 1;
overflow: hidden;
cursor: pointer;
}
Expand Down
1 change: 1 addition & 0 deletions components/views/chat/message/notice/Notice.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<div class="message-notice">
<!-- TODO(i18n): replace with i18n-t https://vue-i18n.intlify.dev/guide/advanced/component.html -->
<template v-if="message.type === 'member_join'">
<div class="icon color-green">
<ArrowRightIcon />
Expand Down
46 changes: 31 additions & 15 deletions components/views/navigation/sidebar/list/item/Item.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
ConversationMessage,
} from '~/libraries/Iridium/chat/types'
import { User } from '~/libraries/Iridium/friends/types'
import { conversationMessageIsNotice } from '~/utilities/chat'
export default Vue.extend({
components: {
Expand Down Expand Up @@ -89,25 +90,40 @@ export default Vue.extend({
},
lastMessageDisplay(): string {
const lastMessage = this.messages.at(-1)
if (!lastMessage) {
const message = this.messages.at(-1)
if (!message) {
return this.$t('messaging.say_hi') as string
}
return lastMessage.body || ''
// const sender = message.from === iridium.connector?.id ? 'me' : 'user'
const name = iridium.users.getUser(message.from)?.name
const members = message.members
?.map((did) => iridium.users.getUser(did)?.name)
.filter((name) => name)
.join(', ')
// switch (message.type) {
// case MessagingTypesEnum.TEXT:
// return message.payload
// case MessagingTypesEnum.FILE:
// case MessagingTypesEnum.GLYPH:
// return this.$t(`messaging.user_sent.${sender}`, {
// msgType: message.type,
// }) as string
// default:
// return this.$t(`messaging.user_sent_something.${sender}`) as string
// }
const fromSelf = message.from === iridium.connector?.id
if (message.attachments.length) {
return fromSelf
? (this.$t('messaging.you_sent_attachment') as string)
: (this.$t('messaging.sent_attachment', { name }) as string)
}
switch (message.type) {
case 'glyph':
return fromSelf
? (this.$t('messaging.you_sent_glyph') as string)
: (this.$t('messaging.sent_glyph', { name }) as string)
case 'member_join':
return this.$t('messaging.group_join', {
name,
members,
}) as string
case 'member_leave':
return this.$t('messaging.group_leave', { name }) as string
}
return message.body || ''
},
isSelected(): boolean {
Expand Down
6 changes: 6 additions & 0 deletions locales/en-US.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ export default {
enter_to: 'enter to',
save: 'save',
},
group_join: '{name} added {members} to the group.',
group_leave: '{name} left the group.',
sent_attachment: '{name} sent an attachment.',
you_sent_attachment: 'You sent an attachment.',
sent_glyph: '{name} sent a glyph.',
you_sent_glyph: 'You sent a glyph.',
group_join_notice: {
added: 'added',
to_group: 'to the group.',
Expand Down

0 comments on commit 3219640

Please sign in to comment.