fix support issue
This commit is contained in:
+27
-8
@@ -40,6 +40,7 @@ type PendingOutgoingAdminMessage = {
|
||||
type: AdminOutgoingMessageType
|
||||
room_id: string
|
||||
content: string
|
||||
reply?: string
|
||||
}
|
||||
optimisticKey: string | null
|
||||
attempts: number
|
||||
@@ -908,7 +909,8 @@ const appendOptimisticAdminMessage = (
|
||||
roomId: string,
|
||||
content: string,
|
||||
messageId: string,
|
||||
typeContent: AdminOutgoingMessageType = 'text'
|
||||
typeContent: AdminOutgoingMessageType = 'text',
|
||||
replyId: string | null = null
|
||||
) => {
|
||||
const optimistic = normalizeMessage(
|
||||
{
|
||||
@@ -918,6 +920,7 @@ const appendOptimisticAdminMessage = (
|
||||
content,
|
||||
type_content: typeContent,
|
||||
type: typeContent,
|
||||
reply: replyId || undefined,
|
||||
created_at: new Date().toISOString()
|
||||
},
|
||||
'optimistic'
|
||||
@@ -1348,7 +1351,7 @@ export const fetchAdminRooms = async () => {
|
||||
const existing = existingMap.get(roomId)
|
||||
const serverUnread = Number(room?.unread_count ?? room?.unreadCount ?? 0)
|
||||
const localUnread = Number(existing?.unread_count ?? existing?.unreadCount ?? 0)
|
||||
const unread = isViewingRoomNow(roomId)
|
||||
const unread = canTreatAdminRoomAsRead(roomId)
|
||||
? 0
|
||||
: Math.max(serverUnread, localUnread)
|
||||
|
||||
@@ -1513,7 +1516,7 @@ export const setAdminActiveRoom = async (
|
||||
|
||||
refreshFocusHeartbeat()
|
||||
|
||||
if (isViewingRoomNow(roomId)) {
|
||||
if (isViewingRoomNow(roomId) && isAdminActiveRoomAtBottom.value) {
|
||||
clearRoomUnread(roomId)
|
||||
}
|
||||
|
||||
@@ -1550,9 +1553,11 @@ export const setAdminActiveRoom = async (
|
||||
export const sendAdminMessage = async (
|
||||
roomId: string,
|
||||
content: string,
|
||||
type: AdminOutgoingMessageType = 'text'
|
||||
type: AdminOutgoingMessageType = 'text',
|
||||
replyId: string | null = null
|
||||
) => {
|
||||
const value = content.trim()
|
||||
const reply = replyId ? String(replyId).trim() : ''
|
||||
|
||||
if (!roomId) throw new Error('room_id is required')
|
||||
if (!value) return
|
||||
@@ -1570,15 +1575,25 @@ export const sendAdminMessage = async (
|
||||
}
|
||||
|
||||
const messageId = createUuid()
|
||||
const optimisticKey = appendOptimisticAdminMessage(roomId, value, messageId, type)
|
||||
const optimisticKey = appendOptimisticAdminMessage(
|
||||
roomId,
|
||||
value,
|
||||
messageId,
|
||||
type,
|
||||
reply || null
|
||||
)
|
||||
|
||||
const payload = {
|
||||
const payload: PendingOutgoingAdminMessage['payload'] = {
|
||||
id: messageId,
|
||||
type,
|
||||
room_id: roomId,
|
||||
content: value
|
||||
}
|
||||
|
||||
if (reply) {
|
||||
payload.reply = reply
|
||||
}
|
||||
|
||||
pendingOutgoingById.set(messageId, {
|
||||
payload,
|
||||
optimisticKey,
|
||||
@@ -1596,8 +1611,12 @@ export const sendAdminMessage = async (
|
||||
}
|
||||
}
|
||||
|
||||
export const sendAdminTextMessage = async (roomId: string, content: string) => {
|
||||
return await sendAdminMessage(roomId, content, 'text')
|
||||
export const sendAdminTextMessage = async (
|
||||
roomId: string,
|
||||
content: string,
|
||||
replyId: string | null = null
|
||||
) => {
|
||||
return await sendAdminMessage(roomId, content, 'text', replyId)
|
||||
}
|
||||
|
||||
export const sendAdminMediaMessage = async (
|
||||
|
||||
Reference in New Issue
Block a user