|
27 | 27 | room.lastMessage && room.lastMessage.new && !typingUsers
|
28 | 28 | }"
|
29 | 29 | >
|
30 |
| - <span v-if="isMessageCheckmarkVisible(room)"> |
| 30 | + <span v-if="isMessageCheckmarkVisible"> |
31 | 31 | <slot name="checkmark-icon" v-bind="room.lastMessage">
|
32 | 32 | <svg-icon
|
33 | 33 | :name="
|
|
52 | 52 | <slot name="microphone-icon">
|
53 | 53 | <svg-icon name="microphone" class="vac-icon-microphone" />
|
54 | 54 | </slot>
|
55 |
| - {{ formattedDuration(room.lastMessage.file.duration) }} |
| 55 | + {{ formattedDuration }} |
56 | 56 | </div>
|
57 | 57 | <format-message
|
58 | 58 | v-else-if="room.lastMessage"
|
59 |
| - :content="getLastMessage(room)" |
| 59 | + :content="getLastMessage" |
60 | 60 | :deleted="!!room.lastMessage.deleted && !typingUsers"
|
61 | 61 | :users="room.users"
|
62 | 62 | :linkify="false"
|
|
97 | 97 | <div v-for="action in roomActions" :key="action.name">
|
98 | 98 | <div
|
99 | 99 | class="vac-menu-item"
|
100 |
| - @click.stop="roomActionHandler(action, room)" |
| 100 | + @click.stop="roomActionHandler(action)" |
101 | 101 | >
|
102 | 102 | {{ action.title }}
|
103 | 103 | </div>
|
@@ -147,64 +147,62 @@ export default {
|
147 | 147 | },
|
148 | 148 |
|
149 | 149 | computed: {
|
150 |
| - userStatus() { |
151 |
| - if (!this.room.users || this.room.users.length !== 2) return |
152 |
| -
|
153 |
| - const user = this.room.users.find(u => u._id !== this.currentUserId) |
154 |
| - if (user.status) return user.status.state |
155 |
| -
|
156 |
| - return null |
157 |
| - }, |
158 |
| - typingUsers() { |
159 |
| - return typingText(this.room, this.currentUserId, this.textMessages) |
160 |
| - } |
161 |
| - }, |
162 |
| -
|
163 |
| - watch: {}, |
164 |
| -
|
165 |
| - methods: { |
166 |
| - getLastMessage(room) { |
| 150 | + getLastMessage() { |
167 | 151 | const isTyping = this.typingUsers
|
168 | 152 | if (isTyping) return isTyping
|
169 | 153 |
|
170 |
| - const content = room.lastMessage.deleted |
| 154 | + const content = this.room.lastMessage.deleted |
171 | 155 | ? this.textMessages.MESSAGE_DELETED
|
172 |
| - : room.lastMessage.content |
| 156 | + : this.room.lastMessage.content |
173 | 157 |
|
174 |
| - if (room.users.length <= 2) { |
| 158 | + if (this.room.users.length <= 2) { |
175 | 159 | return content
|
176 | 160 | }
|
177 | 161 |
|
178 |
| - const user = room.users.find( |
179 |
| - user => user._id === room.lastMessage.sender_id |
| 162 | + const user = this.room.users.find( |
| 163 | + user => user._id === this.room.lastMessage.sender_id |
180 | 164 | )
|
181 | 165 |
|
182 |
| - if (room.lastMessage.username) { |
183 |
| - return `${room.lastMessage.username} - ${content}` |
| 166 | + if (this.room.lastMessage.username) { |
| 167 | + return `${this.room.lastMessage.username} - ${content}` |
184 | 168 | } else if (!user || user._id === this.currentUserId) {
|
185 | 169 | return content
|
186 | 170 | }
|
187 | 171 |
|
188 | 172 | return `${user.username} - ${content}`
|
189 | 173 | },
|
190 |
| - formattedDuration(s) { |
191 |
| - s = Math.round(s) |
192 |
| - return (s - (s %= 60)) / 60 + (s > 9 ? ':' : ':0') + s |
| 174 | + userStatus() { |
| 175 | + if (!this.room.users || this.room.users.length !== 2) return |
| 176 | +
|
| 177 | + const user = this.room.users.find(u => u._id !== this.currentUserId) |
| 178 | + if (user.status) return user.status.state |
| 179 | +
|
| 180 | + return null |
193 | 181 | },
|
194 |
| - isMessageCheckmarkVisible(room) { |
| 182 | + typingUsers() { |
| 183 | + return typingText(this.room, this.currentUserId, this.textMessages) |
| 184 | + }, |
| 185 | + isMessageCheckmarkVisible() { |
195 | 186 | return (
|
196 | 187 | !this.typingUsers &&
|
197 |
| - room.lastMessage && |
198 |
| - !room.lastMessage.deleted && |
199 |
| - room.lastMessage.sender_id === this.currentUserId && |
200 |
| - (room.lastMessage.saved || |
201 |
| - room.lastMessage.distributed || |
202 |
| - room.lastMessage.seen) |
| 188 | + this.room.lastMessage && |
| 189 | + !this.room.lastMessage.deleted && |
| 190 | + this.room.lastMessage.sender_id === this.currentUserId && |
| 191 | + (this.room.lastMessage.saved || |
| 192 | + this.room.lastMessage.distributed || |
| 193 | + this.room.lastMessage.seen) |
203 | 194 | )
|
204 | 195 | },
|
205 |
| - roomActionHandler(action, room) { |
| 196 | + formattedDuration() { |
| 197 | + let s = Math.round(this.room.lastMessage.file.duration) |
| 198 | + return (s - (s %= 60)) / 60 + (s > 9 ? ':' : ':0') + s |
| 199 | + } |
| 200 | + }, |
| 201 | +
|
| 202 | + methods: { |
| 203 | + roomActionHandler(action) { |
206 | 204 | this.closeRoomMenu()
|
207 |
| - this.$emit('room-action-handler', { action, roomId: room.roomId }) |
| 205 | + this.$emit('room-action-handler', { action, roomId: this.room.roomId }) |
208 | 206 | },
|
209 | 207 | closeRoomMenu() {
|
210 | 208 | this.roomMenuOpened = null
|
|
0 commit comments