优化ui
This commit is contained in:
+16
-12
@@ -123,6 +123,20 @@ export async function getCaregiverOverview(caregiverId: string) {
|
||||
};
|
||||
}
|
||||
|
||||
export function getCaregiverUnreadIncomingCount(caregiverId: string) {
|
||||
return prisma.familyMessage.count({
|
||||
where: {
|
||||
direction: MessageDirection.ELDER_TO_FAMILY,
|
||||
elderDevice: {
|
||||
bindings: {
|
||||
some: { caregiverId },
|
||||
},
|
||||
},
|
||||
readAt: null,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export async function getCaregiverMessages(caregiverId: string) {
|
||||
const [messages, unreadIncomingCount, unreadOutgoingCount] = await prisma.$transaction([
|
||||
prisma.familyMessage.findMany({
|
||||
@@ -141,17 +155,7 @@ export async function getCaregiverMessages(caregiverId: string) {
|
||||
orderBy: [{ createdAt: "desc" }, { publicId: "desc" }],
|
||||
take: 120,
|
||||
}),
|
||||
prisma.familyMessage.count({
|
||||
where: {
|
||||
direction: MessageDirection.ELDER_TO_FAMILY,
|
||||
elderDevice: {
|
||||
bindings: {
|
||||
some: { caregiverId },
|
||||
},
|
||||
},
|
||||
readAt: null,
|
||||
},
|
||||
}),
|
||||
getCaregiverUnreadIncomingCount(caregiverId),
|
||||
prisma.familyMessage.count({
|
||||
where: {
|
||||
direction: MessageDirection.FAMILY_TO_ELDER,
|
||||
@@ -394,4 +398,4 @@ export async function getCaregiverSettingsOverview(caregiverId: string) {
|
||||
deviceCount,
|
||||
pushSubscriptionCount,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user