Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(sidebar): display other message types in message preview #4493

Merged
merged 4 commits into from
Aug 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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