adapted chatmessage to display statuses
This commit is contained in:
parent
55917125a8
commit
a58cdd954d
9 changed files with 85 additions and 20 deletions
|
|
@ -49,15 +49,15 @@ const ChatMessage = {
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
author() {
|
author() {
|
||||||
return this.$store.getters.findUser(
|
const accountId = this.message.account_id || this.message.user.id
|
||||||
this.chatItem.data.account_id
|
|
||||||
)
|
return this.$store.getters.findUser(accountId)
|
||||||
},
|
},
|
||||||
isCurrentUser() {
|
isCurrentUser() {
|
||||||
return this.message.account_id === this.currentUser.id
|
return this.author.id === this.currentUser.id
|
||||||
},
|
},
|
||||||
message() {
|
message() {
|
||||||
return this.chatItem.data
|
return this.isMessage ? this.chatItem.data : null
|
||||||
},
|
},
|
||||||
isMessage() {
|
isMessage() {
|
||||||
return this.chatItem.type === 'message'
|
return this.chatItem.type === 'message'
|
||||||
|
|
@ -66,7 +66,7 @@ const ChatMessage = {
|
||||||
return {
|
return {
|
||||||
summary: '',
|
summary: '',
|
||||||
emojis: this.message.emojis,
|
emojis: this.message.emojis,
|
||||||
raw_html: this.message.content || '',
|
raw_html: this.message.content || this.message.raw_html || '',
|
||||||
text: this.message.content || '',
|
text: this.message.content || '',
|
||||||
attachments: this.message.attachments,
|
attachments: this.message.attachments,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,7 @@
|
||||||
v-else
|
v-else
|
||||||
class="chat-message-date-separator"
|
class="chat-message-date-separator"
|
||||||
>
|
>
|
||||||
<ChatMessageDate :date="chatItem.date" />
|
<ChatMessageDate :date="chatItem.date" :show-time="chatItem.isTime" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,22 +7,34 @@
|
||||||
<script>
|
<script>
|
||||||
import localeService from 'src/services/locale/locale.service.js'
|
import localeService from 'src/services/locale/locale.service.js'
|
||||||
|
|
||||||
|
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Timeago',
|
name: 'Timeago',
|
||||||
props: ['date'],
|
props: ['date', 'showTime'],
|
||||||
computed: {
|
computed: {
|
||||||
|
time12hFormat() {
|
||||||
|
return useMergedConfigStore().mergedConfig.absoluteTimeFormat12h === '12h'
|
||||||
|
},
|
||||||
displayDate() {
|
displayDate() {
|
||||||
const today = new Date()
|
const today = new Date()
|
||||||
today.setHours(0, 0, 0, 0)
|
today.setHours(0, 0, 0, 0)
|
||||||
|
|
||||||
if (this.date.getTime() === today.getTime()) {
|
if (this.date.getTime() === today.getTime()) {
|
||||||
return this.$t('display_date.today')
|
return this.$t('display_date.today')
|
||||||
|
} else {
|
||||||
|
if (this.showTime) {
|
||||||
|
return this.date.toLocaleTimeString(
|
||||||
|
localeService.internalToBrowserLocale(this.$i18n.locale),
|
||||||
|
{ hour12: this.time12hFormat, hour: 'numeric', minute: 'numeric' }
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
return this.date.toLocaleDateString(
|
return this.date.toLocaleDateString(
|
||||||
localeService.internalToBrowserLocale(this.$i18n.locale),
|
localeService.internalToBrowserLocale(this.$i18n.locale),
|
||||||
{ day: 'numeric', month: 'long' },
|
{ day: 'numeric', month: 'long' },
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ const ChatMessageList = {
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
messages: Array,
|
messages: Array,
|
||||||
|
headerDate: Boolean,
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
|
@ -26,8 +27,23 @@ const ChatMessageList = {
|
||||||
const newerMessage = messages[index + 1]
|
const newerMessage = messages[index + 1]
|
||||||
const newerItem = acc[acc.length - 1]
|
const newerItem = acc[acc.length - 1]
|
||||||
|
|
||||||
const diff = message.created_at - (olderMessage?.created_at || 0)
|
const diff = olderMessage ? message.created_at - olderMessage.created_at : null
|
||||||
const MAX_DIFF = 1000 * 60 // 5 minutes
|
|
||||||
|
const MAX_DIFF = 1000 * 60 * 5 // 5 minutes
|
||||||
|
|
||||||
|
const dateDiffs = (() => {
|
||||||
|
if (olderMessage) {
|
||||||
|
const newerDate = new Date(message.created_at)
|
||||||
|
const olderDate = new Date(olderMessage.created_at)
|
||||||
|
|
||||||
|
newerDate.setHours(0, 0, 0, 0)
|
||||||
|
olderDate.setHours(0, 0, 0, 0)
|
||||||
|
|
||||||
|
return newerDate.toISOString() !== olderDate.toISOString()
|
||||||
|
} else {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
})()
|
||||||
|
|
||||||
const chatItem = {
|
const chatItem = {
|
||||||
type: 'message',
|
type: 'message',
|
||||||
|
|
@ -54,10 +70,12 @@ const ChatMessageList = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (diff > MAX_DIFF || !olderMessage) {
|
if (diff > MAX_DIFF || (!olderMessage && this.headerDate)) {
|
||||||
return [...acc, chatItem, {
|
return [...acc, chatItem, {
|
||||||
type: 'date',
|
type: 'date',
|
||||||
date,
|
date,
|
||||||
|
isDate: dateDiffs,
|
||||||
|
isTime: diff > MAX_DIFF && !dateDiffs,
|
||||||
id: date.getTime().toString(),
|
id: date.getTime().toString(),
|
||||||
}]
|
}]
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,10 @@
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<ChatMessageList :messages="chatMessages" />
|
<ChatMessageList
|
||||||
|
header-date
|
||||||
|
:messages="chatMessages"
|
||||||
|
/>
|
||||||
<div
|
<div
|
||||||
ref="footer"
|
ref="footer"
|
||||||
class="panel-body footer"
|
class="panel-body footer"
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import { mapState } from 'vuex'
|
||||||
import QuickFilterSettings from 'src/components/quick_filter_settings/quick_filter_settings.vue'
|
import QuickFilterSettings from 'src/components/quick_filter_settings/quick_filter_settings.vue'
|
||||||
import QuickViewSettings from 'src/components/quick_view_settings/quick_view_settings.vue'
|
import QuickViewSettings from 'src/components/quick_view_settings/quick_view_settings.vue'
|
||||||
import ThreadTree from 'src/components/thread_tree/thread_tree.vue'
|
import ThreadTree from 'src/components/thread_tree/thread_tree.vue'
|
||||||
|
import ChatMessageList from 'src/components/chat_message_list/chat_message_list.vue'
|
||||||
|
|
||||||
import { useInterfaceStore } from 'src/stores/interface'
|
import { useInterfaceStore } from 'src/stores/interface'
|
||||||
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
||||||
|
|
@ -127,15 +128,18 @@ const conversation = {
|
||||||
displayStyle() {
|
displayStyle() {
|
||||||
return this.mergedConfig.conversationDisplay
|
return this.mergedConfig.conversationDisplay
|
||||||
},
|
},
|
||||||
isTreeView() {
|
|
||||||
return !this.isLinearView
|
|
||||||
},
|
|
||||||
treeViewIsSimple() {
|
treeViewIsSimple() {
|
||||||
return !this.mergedConfig.conversationTreeAdvanced
|
return !this.mergedConfig.conversationTreeAdvanced
|
||||||
},
|
},
|
||||||
|
isTreeView() {
|
||||||
|
return this.displayStyle === 'tree'
|
||||||
|
},
|
||||||
isLinearView() {
|
isLinearView() {
|
||||||
return this.displayStyle === 'linear'
|
return this.displayStyle === 'linear'
|
||||||
},
|
},
|
||||||
|
isChatView() {
|
||||||
|
return this.displayStyle === 'chat'
|
||||||
|
},
|
||||||
shouldFadeAncestors() {
|
shouldFadeAncestors() {
|
||||||
return this.mergedConfig.conversationTreeFadeAncestors
|
return this.mergedConfig.conversationTreeFadeAncestors
|
||||||
},
|
},
|
||||||
|
|
@ -404,6 +408,7 @@ const conversation = {
|
||||||
ThreadTree,
|
ThreadTree,
|
||||||
QuickFilterSettings,
|
QuickFilterSettings,
|
||||||
QuickViewSettings,
|
QuickViewSettings,
|
||||||
|
ChatMessageList,
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
statusId(newVal, oldVal) {
|
statusId(newVal, oldVal) {
|
||||||
|
|
|
||||||
|
|
@ -196,6 +196,14 @@
|
||||||
/>
|
/>
|
||||||
</article>
|
</article>
|
||||||
</div>
|
</div>
|
||||||
|
<div
|
||||||
|
v-if="isChatView"
|
||||||
|
class="thread-body"
|
||||||
|
>
|
||||||
|
<ChatMessageList
|
||||||
|
:messages="conversation"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
|
|
|
||||||
|
|
@ -13,9 +13,10 @@ import {
|
||||||
faFolderTree,
|
faFolderTree,
|
||||||
faList,
|
faList,
|
||||||
faWrench,
|
faWrench,
|
||||||
|
faMessage,
|
||||||
} from '@fortawesome/free-solid-svg-icons'
|
} from '@fortawesome/free-solid-svg-icons'
|
||||||
|
|
||||||
library.add(faList, faFolderTree, faBars, faWrench)
|
library.add(faList, faFolderTree, faBars, faWrench, faMessage)
|
||||||
|
|
||||||
const QuickViewSettings = {
|
const QuickViewSettings = {
|
||||||
props: {
|
props: {
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,24 @@
|
||||||
/> {{ $t('settings.conversation_display_linear_quick') }}
|
/> {{ $t('settings.conversation_display_linear_quick') }}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="menu-item dropdown-item -icon-double">
|
||||||
|
<button
|
||||||
|
class="main-button"
|
||||||
|
:aria-checked="conversationDisplay === 'chat'"
|
||||||
|
role="menuitemradio"
|
||||||
|
@click="conversationDisplay = 'chat'"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
class="input menu-checkbox -radio"
|
||||||
|
:class="{ 'menu-checkbox-checked': conversationDisplay === 'chat' }"
|
||||||
|
:aria-hidden="true"
|
||||||
|
/><FAIcon
|
||||||
|
icon="message"
|
||||||
|
:aria-hidden="true"
|
||||||
|
fixed-width
|
||||||
|
/> {{ $t('settings.conversation_display_chat_quick') }}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
role="separator"
|
role="separator"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue