mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-12-21 11:25:50 -05:00
feat(gui): Display developer responses to feedback (#302)
This commit is contained in:
parent
f1e5cdfbfe
commit
53a994e6dc
19 changed files with 1216 additions and 45 deletions
|
|
@ -146,4 +146,47 @@ export function usePendingApprovals(): PendingApprovalRequest[] {
|
|||
export function usePendingLockBitcoinApproval(): PendingLockBitcoinApprovalRequest[] {
|
||||
const approvals = usePendingApprovals();
|
||||
return approvals.filter((c) => c.content.details.type === "LockBitcoin");
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the number of unread messages from staff for a specific feedback conversation.
|
||||
* @param feedbackId The ID of the feedback conversation.
|
||||
* @returns The number of unread staff messages.
|
||||
*/
|
||||
export function useUnreadMessagesCount(feedbackId: string): number {
|
||||
const { conversationsMap, seenMessagesSet } = useAppSelector((state) => ({
|
||||
conversationsMap: state.conversations.conversations,
|
||||
// Convert seenMessages array to a Set for efficient lookup
|
||||
seenMessagesSet: new Set(state.conversations.seenMessages),
|
||||
}));
|
||||
|
||||
const messages = conversationsMap[feedbackId] || [];
|
||||
|
||||
const unreadStaffMessages = messages.filter(
|
||||
(msg) => msg.is_from_staff && !seenMessagesSet.has(msg.id.toString()),
|
||||
);
|
||||
|
||||
return unreadStaffMessages.length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the total number of unread messages from staff across all feedback conversations.
|
||||
* @returns The total number of unread staff messages.
|
||||
*/
|
||||
export function useTotalUnreadMessagesCount(): number {
|
||||
const { conversationsMap, seenMessagesSet } = useAppSelector((state) => ({
|
||||
conversationsMap: state.conversations.conversations,
|
||||
seenMessagesSet: new Set(state.conversations.seenMessages),
|
||||
}));
|
||||
|
||||
let totalUnreadCount = 0;
|
||||
for (const feedbackId in conversationsMap) {
|
||||
const messages = conversationsMap[feedbackId] || [];
|
||||
const unreadStaffMessages = messages.filter(
|
||||
(msg) => msg.is_from_staff && !seenMessagesSet.has(msg.id.toString()),
|
||||
);
|
||||
totalUnreadCount += unreadStaffMessages.length;
|
||||
}
|
||||
|
||||
return totalUnreadCount;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue