Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion api/src/unraid-api/auth/auth.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ export class GraphqlAuthGuard
// parse cookies from raw headers on initial web socket connection request
if (fullContext.connectionParams) {
const rawHeaders = fullContext.req.extra.request.rawHeaders;
const headerIndex = rawHeaders.findIndex((headerOrValue) => headerOrValue === 'Cookie');
const headerIndex = rawHeaders.findIndex(
(headerOrValue) => headerOrValue.toLowerCase() === 'cookie'
);
const cookieString = rawHeaders[headerIndex + 1];
request.cookies = parseCookies(cookieString);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,12 @@ export class NotificationsService {
const notification = await this.loadNotificationFile(path, NotificationType[type]);
this.increment(notification.importance, NotificationsService.overview[type.toLowerCase()]);

this.publishOverview();
pubsub.publish(PUBSUB_CHANNEL.NOTIFICATION_ADDED, {
notificationAdded: notification,
});
if (type === NotificationType.UNREAD) {
this.publishOverview();
pubsub.publish(PUBSUB_CHANNEL.NOTIFICATION_ADDED, {
notificationAdded: notification,
});
}
}

/**
Expand Down
26 changes: 13 additions & 13 deletions web/_data/serverState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,19 +131,19 @@ const osVersionBranch = 'stable';
// };

export const serverState: Server = {
activationCodeData: {
code: 'CC2KP3TDRF',
partnerName: 'OEM Partner',
partnerUrl: 'https://unraid.net/OEM+Partner',
sysModel: 'OEM Partner v1',
comment: 'OEM Partner NAS',
caseIcon: 'case-model.png',
header: '#ffffff',
headermetacolor: '#eeeeee',
background: '#000000',
showBannerGradient: 'yes',
partnerLogo: true,
},
// activationCodeData: {
// code: 'CC2KP3TDRF',
// partnerName: 'OEM Partner',
// partnerUrl: 'https://unraid.net/OEM+Partner',
// sysModel: 'OEM Partner v1',
// comment: 'OEM Partner NAS',
// caseIcon: 'case-model.png',
// header: '#ffffff',
// headermetacolor: '#eeeeee',
// background: '#000000',
// showBannerGradient: 'yes',
// partnerLogo: true,
// },
avatar: 'https://source.unsplash.com/300x300/?portrait',
config: {
id: 'config-id',
Expand Down
16 changes: 12 additions & 4 deletions web/components/Notifications/Sidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ const { onResult: onNotificationAdded } = useSubscription(notificationAddedSubsc
onNotificationAdded(({ data }) => {
if (!data) return;
const notif = useFragment(NOTIFICATION_FRAGMENT, data.notificationAdded);
if (notif.type !== NotificationType.Unread) return;
// probably smart to leave this log outside the if-block for the initial release
console.log('incoming notification', notif);
if (!globalThis.toast) {
return;
}
Comment on lines +48 to +50
Copy link
Contributor

@coderabbitai coderabbitai bot Feb 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Your error handling would make a junior developer cry!

A silent return when globalThis.toast is undefined? No error logging? No fallback? This is the kind of code that keeps DevOps engineers up at night!

Add proper error handling:

   if (!globalThis.toast) {
+    console.error('Toast notification system not initialized');
     return;
   }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (!globalThis.toast) {
return;
}
if (!globalThis.toast) {
console.error('Toast notification system not initialized');
return;
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thoughts yall? @elibosley @mdatelle

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would error here so users can see what is happening.


const funcMapping: Record<Importance, (typeof globalThis)['toast']['info' | 'error' | 'warning']> = {
[Importance.Alert]: globalThis.toast.error,
Expand All @@ -51,10 +57,12 @@ onNotificationAdded(({ data }) => {
const toast = funcMapping[notif.importance];
const createOpener = () => ({ label: 'Open', onClick: () => location.assign(notif.link as string) });

toast(notif.title, {
description: notif.subject,
action: notif.link ? createOpener() : undefined,
});
requestAnimationFrame(() =>
toast(notif.title, {
description: notif.subject,
action: notif.link ? createOpener() : undefined,
})
);
});

const overview = computed(() => {
Expand Down
Loading