From 5e93ca3edb4a7866c662418c49af17daba91baa2 Mon Sep 17 00:00:00 2001 From: eugenijm Date: Thu, 7 May 2020 21:50:30 +0300 Subject: [PATCH] WIP chat avatars --- src/boot/routes.js | 2 +- src/components/chat/chat.js | 2 +- src/components/chat/chat.vue | 1 + src/components/chat_message/chat_message.js | 12 ++++++++++-- src/components/chat_message/chat_message.scss | 1 - src/components/chat_message/chat_message.vue | 15 +++++++++++++++ src/components/notification/notification.js | 6 +++++- src/components/notification/notification.vue | 6 ++---- .../post_status_form/post_status_form.js | 5 +++-- src/components/status_content/status_content.js | 2 +- src/components/status_content/status_content.vue | 2 +- 11 files changed, 40 insertions(+), 14 deletions(-) diff --git a/src/boot/routes.js b/src/boot/routes.js index 48b8c9da..c770746f 100644 --- a/src/boot/routes.js +++ b/src/boot/routes.js @@ -58,7 +58,7 @@ export default (store) => { { name: 'external-user-profile', path: '/users/:id', component: UserProfile }, { name: 'interactions', path: '/users/:username/interactions', component: Interactions, beforeEnter: validateAuthenticatedRoute }, { name: 'dms', path: '/users/:username/dms', component: DMs, beforeEnter: validateAuthenticatedRoute }, - { name: 'chat', path: '/chats/:recipient_id', component: Chat, meta: { dontScroll: false }, beforeEnter: validateAuthenticatedRoute }, + { name: 'chat', path: '/users/:username/chats/:recipient_id', component: Chat, meta: { dontScroll: false }, beforeEnter: validateAuthenticatedRoute }, { name: 'chats', path: '/users/:username/chats', component: ChatList, meta: { dontScroll: false }, beforeEnter: validateAuthenticatedRoute }, { name: 'settings', path: '/settings', component: Settings }, { name: 'registration', path: '/registration', component: Registration }, diff --git a/src/components/chat/chat.js b/src/components/chat/chat.js index 2e3fe975..8f8e279d 100644 --- a/src/components/chat/chat.js +++ b/src/components/chat/chat.js @@ -282,7 +282,7 @@ const Chat = { } }, 100), goBack () { - this.$router.push({ name: 'chats', params: { username: this.screen_name } }) + this.$router.push({ name: 'chats', params: { username: this.currentUser.screen_name } }) }, fetchChat (isFirstFetch, chatId) { this.chatViewItems = chatService.getView(this.currentChatMessageService) diff --git a/src/components/chat/chat.vue b/src/components/chat/chat.vue index 02b03609..5847348e 100644 --- a/src/components/chat/chat.vue +++ b/src/components/chat/chat.vue @@ -71,6 +71,7 @@ :poster="poster" :preserve-focus="true" :polls-available="false" + :auto-focus="true" :placeholder="formPlaceholder" max-height="160" @resize="handleResize" diff --git a/src/components/chat_message/chat_message.js b/src/components/chat_message/chat_message.js index 7d3d27e2..7e3cfad3 100644 --- a/src/components/chat_message/chat_message.js +++ b/src/components/chat_message/chat_message.js @@ -5,6 +5,7 @@ import Gallery from '../gallery/gallery.vue' import LinkPreview from '../link-preview/link-preview.vue' import StatusContent from '../status_content/status_content.vue' import ChatMessageDate from '../chat_message_date/chat_message_date.vue' +import generateProfileLink from 'src/services/user_profile_link_generator/user_profile_link_generator' const ChatMessage = { name: 'ChatMessage', @@ -32,9 +33,15 @@ const ChatMessage = { isCurrentUser () { return this.message.account_id === this.currentUser.id }, + author () { + return this.findUser(this.message.account_id) + }, message () { return this.chatViewItem.data }, + userProfileLink () { + return generateProfileLink(this.author.id, this.author.screen_name, this.$store.state.instance.restrictedNicknames) + }, isMessage () { return this.chatViewItem.type === 'message' }, @@ -48,9 +55,10 @@ const ChatMessage = { }, ...mapState({ betterShadow: state => state.interface.browserSupport.cssFilter, - currentUser: state => state.users.currentUser + currentUser: state => state.users.currentUser, + restrictedNicknames: state => state.instance.restrictedNicknames }), - ...mapGetters(['mergedConfig']) + ...mapGetters(['mergedConfig', 'findUser']) }, methods: { onHover (bool) { diff --git a/src/components/chat_message/chat_message.scss b/src/components/chat_message/chat_message.scss index 1859dbc9..3e219e24 100644 --- a/src/components/chat_message/chat_message.scss +++ b/src/components/chat_message/chat_message.scss @@ -37,7 +37,6 @@ .avatar-wrapper { margin-right: 10px; - margin-top: auto; width: 32px; } diff --git a/src/components/chat_message/chat_message.vue b/src/components/chat_message/chat_message.vue index 79b775cc..7aeec30b 100644 --- a/src/components/chat_message/chat_message.vue +++ b/src/components/chat_message/chat_message.vue @@ -10,6 +10,21 @@ class="direct-conversation" :class="[{ 'outgoing': isCurrentUser, 'incoming': !isCurrentUser }]" > +
+ + + +
state.users.currentUser + }) } } diff --git a/src/components/notification/notification.vue b/src/components/notification/notification.vue index 3a8eaf26..65566047 100644 --- a/src/components/notification/notification.vue +++ b/src/components/notification/notification.vue @@ -113,7 +113,7 @@ class="timeago" >
- +