Skip to content

Commit 0b8008e

Browse files
v1.22.0 (#65)
* Notification list for devs has always a red dot * fixing null value name email inbox mail * fix missing name inbox mail --------- Co-authored-by: LennartSchmidtKern <lennart.schmidt@kern.ai>
1 parent ec0b9e0 commit 0b8008e

File tree

5 files changed

+27
-23
lines changed

5 files changed

+27
-23
lines changed

components/AppNotifications.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export default function AppNotifications(props: AppNotificationsProps) {
4747
}, [props.notifications, showMoreClicked]);
4848

4949
const hasNewNotifications = useMemo(() => {
50-
if (lastSeenNotification === -1) return true; // if no notification was seen
50+
if (lastSeenNotification === -1) return props.notifications.length > 0;
5151
return props.notifications.some(notification => notification.id > lastSeenNotification);
5252
}, [lastSeenNotification, props.notifications]);
5353

components/inbox-mail/CreateNewMailModal.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,9 +275,9 @@ function UserSelector(props: UserSelectorProps) {
275275
setFilteredUsers(
276276
props.users.filter(
277277
(u) =>
278-
u.firstName.toLowerCase().includes(lower) ||
279-
u.lastName.toLowerCase().includes(lower) ||
280-
u.mail.toLowerCase().includes(lower)
278+
(u.firstName && u.firstName.toLowerCase().includes(lower)) ||
279+
(u.lastName && u.lastName.toLowerCase().includes(lower)) ||
280+
(u.mail && u.mail.toLowerCase().includes(lower))
281281
).filter((u) => !props.selectedUsers.some((selected) => selected.id === u.id))
282282
);
283283
}

components/inbox-mail/InboxMailAdminPanel.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ function InboxMailAdminPanel(props: InboxMailAdminPanelProps) {
6868
{props.selectedThread.progressState !== InboxMailThreadSupportProgressState.PENDING && props.selectedThread.metaData?.supportOwnerName && (
6969
<div className="bg-orange-400 text-white rounded-full px-2 py-0.5 text-xs flex items-center gap-x-2 ml-2">
7070
<IconProgressCheck className="w-5 h-5" />
71-
{props.selectedThread.metaData.supportOwnerName.first}{" "}
72-
{props.selectedThread.metaData.supportOwnerName.last}
71+
{props.selectedThread.metaData.supportOwnerName?.first}{" "}
72+
{props.selectedThread.metaData.supportOwnerName?.last}
7373
</div>
7474
)}
7575
</div>

components/inbox-mail/InboxMailItem.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export default function ThreadMailItem(props: ThreadMailItemProps) {
3838
</div>
3939

4040
<span className="text-sm text-gray-500">
41-
{t("inboxMail.to")}: {props.mail.recipientNames.map((name) => `${name.first} ${name.last}`).join(", ")}
41+
{t("inboxMail.to")}: {props.mail.recipientNames.map((name) => `${name?.first} ${name?.last}`).join(", ")}
4242
</span>
4343
</div>
4444
</div>

components/inbox-mail/helper.ts

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ import { getNewInboxMailsInfo } from "./service-mail";
55

66
export const MAIL_LIMIT_PER_PAGE = 8;
77

8-
const setInitials = (first: string, last: string) => first[0]?.toUpperCase() + last[0]?.toUpperCase();
8+
const setInitials = (first?: string, last?: string) => {
9+
const firstInitial = first && first.length > 0 ? first[0].toUpperCase() : "";
10+
const lastInitial = last && last.length > 0 ? last[0].toUpperCase() : "";
11+
return firstInitial + lastInitial;
12+
};
913

1014
export function prepareThreadDisplayData(
1115
thread: InboxMailThread,
@@ -44,52 +48,52 @@ export function prepareThreadDisplayData(
4448
}
4549
else if (!thread.isAdminSupportThread) {
4650
if (thread.latestMail.senderId === currentUser.id) {
47-
displayName = thread.latestMail.recipientNames.map(r => `${r.first} ${r.last}`).join(", ");
51+
displayName = thread.latestMail.recipientNames.map(r => `${r?.first} ${r?.last}`).join(", ");
4852
const r = thread.latestMail.recipientNames[0];
49-
displayInitials = setInitials(r.first, r.last);
53+
displayInitials = setInitials(r?.first, r?.last);
5054
setColor(recipientIds[0]);
5155
} else {
5256
const s = thread.latestMail.senderName;
53-
const first = s.first ?? "";
54-
const last = s.last ?? "";
57+
const first = s?.first ?? "";
58+
const last = s?.last ?? "";
5559
displayName = `${first} ${last}`.trim();
5660
displayInitials = setInitials(first, last);
5761
setColor(thread.latestMail.senderId);
5862
}
5963
} else if (thread.isAdminSupportThread && thread.metaData?.autoGenerated) {
6064
if (thread.latestMail.senderId) {
61-
displayName = thread.latestMail.recipientNames.map(r => `${r.first} ${r.last}`).join(", ");
65+
displayName = thread.latestMail.recipientNames.map(r => `${r?.first} ${r?.last}`).join(", ");
6266
}
6367
else {
64-
displayName = `${thread.latestMail.senderName.first} ${thread.latestMail.senderName.last}`;
68+
displayName = `${thread.latestMail.senderName?.first} ${thread.latestMail.senderName?.last}`;
6569
DisplayIcon = IconBug
6670
background = "#FFE5E5";
6771
text = "#A30000";
6872
}
6973
} else if (thread.isAdminSupportThread && isAdmin && thread.latestMail.senderId === currentUser.id) {
70-
displayName = `${thread.latestMail.senderName.first} ${thread.latestMail.senderName.last}`;
71-
displayInitials = setInitials(thread.latestMail.senderName.first, thread.latestMail.senderName.last);
74+
displayName = `${thread.latestMail.senderName?.first} ${thread.latestMail.senderName?.last}`;
75+
displayInitials = setInitials(thread.latestMail.senderName?.first, thread.latestMail.senderName?.last);
7276
setColor(thread.latestMail.senderId);
7377

7478
} else if (thread.isAdminSupportThread && isAdmin) {
7579
if (thread.latestMail.senderId === currentUser.id && thread.latestMail.recipientNames.length === 0) {
76-
displayName = `${thread.latestMail.senderName.first} ${thread.latestMail.senderName.last}`;
80+
displayName = `${thread.latestMail.senderName?.first} ${thread.latestMail.senderName?.last}`;
7781
} else if (thread.latestMail.senderId === currentUser.id) {
78-
displayName = thread.latestMail.recipientNames.map(r => `${r.first} ${r.last}`).join(", ");
82+
displayName = thread.latestMail.recipientNames.map(r => `${r?.first} ${r?.last}`).join(", ");
7983
const r = thread.latestMail.recipientNames[0];
80-
displayInitials = setInitials(r.first, r.last);
84+
displayInitials = setInitials(r?.first, r?.last);
8185
setColor(recipientIds[0]);
8286
} else {
8387
const s = thread.latestMail.senderName;
84-
displayName = `${s.first} ${s.last}`;
85-
displayInitials = setInitials(s.first ?? "", s.last ?? "");
88+
displayName = `${s?.first} ${s?.last}`;
89+
displayInitials = setInitials(s?.first ?? "", s?.last ?? "");
8690
setColor(thread.latestMail.senderId ?? thread.createdBy);
8791
}
8892
} else {
8993
if (thread.latestMail.senderId === currentUser.id) {
90-
displayName = thread.latestMail.recipientNames.map(r => `${r.first} ${r.last}`).join(", ");
94+
displayName = thread.latestMail.recipientNames.map(r => `${r?.first} ${r?.last}`).join(", ");
9195
} else {
92-
displayName = `${thread.latestMail.senderName.first} ${thread.latestMail.senderName.last}`;
96+
displayName = `${thread.latestMail.senderName?.first} ${thread.latestMail.senderName?.last}`;
9397
}
9498
}
9599

0 commit comments

Comments
 (0)