Skip to content

Commit

Permalink
fix(chat): fix successive message display
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed May 22, 2022
1 parent b6d723d commit b3c449e
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 5 deletions.
6 changes: 5 additions & 1 deletion plugins/adapter/onebot/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,12 @@ export function adaptSession(data: OneBot.Payload) {
session.selfId = data.self_tiny_id ? data.self_tiny_id : '' + data.self_id
session.type = data.post_type

if (data.post_type === 'message') {
if (data.post_type === 'message' || data.post_type === 'message_sent') {
Object.assign(session, adaptMessage(data))
if (data.post_type === 'message_sent' && !session.guildId) {
session.channelId = 'private:' + data.target_id
}
session.type = 'message'
session.subtype = data.message_type === 'guild' ? 'group' : data.message_type
session.subsubtype = data.message_type
return session
Expand Down
2 changes: 1 addition & 1 deletion plugins/frontend/chat/client/chat.vue
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ const filtered = computed(() => {
})
function isSuccessive({ quote, userId, channelId }: Message, index: number) {
const prev = messages[index - 1]
const prev = filtered.value[index - 1]
return !quote && !!prev && prev.userId === userId && prev.channelId === channelId
}
Expand Down
1 change: 0 additions & 1 deletion plugins/frontend/chat/client/message.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
<template v-else>
<img class="avatar" v-if="data.avatar" :src="data.avatar"/>
<div class="header">
<span class="channel">{{ data.channelName || '私聊' }}</span>
<span class="username">{{ data.username }}</span>
<span class="timestamp">{{ formatDateTime(new Date(data.timestamp)) }}</span>
</div>
Expand Down
2 changes: 1 addition & 1 deletion plugins/frontend/chat/src/locales/zh.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ chat:
guild: '[推荐群:{ name }]'
face: 表情
record: 语音
video: 短视频
video: 视频
image: 图片
music: 音乐
quote: 引用
Expand Down
2 changes: 1 addition & 1 deletion plugins/frontend/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
],
"dependencies": {
"@koishijs/segment": "^1.1.1",
"@satorijs/components": "^0.3.0",
"@satorijs/components": "^0.3.1",
"@types/marked": "^4.0.3",
"@vitejs/plugin-vue": "^2.3.1",
"@vueuse/core": "^7.7.1",
Expand Down

0 comments on commit b3c449e

Please sign in to comment.