Skip to content

Commit

Permalink
Merge branch 'main' into tests/add-services-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuseduardomedeiros committed Jan 9, 2025
2 parents a6bad02 + 208a9a3 commit 1b12945
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,15 @@ export default (message, { app }) => {

if (document.hidden) {
const { first_name, last_name } = message.user;
sendWindowNotification({
title: `${first_name} ${last_name}`,
message: message.text,
image: message.media?.[0]?.url,
});
try {
sendWindowNotification({
title: `${first_name} ${last_name}`,
message: message.text,
image: message.media?.[0]?.url,
});
} catch (error) {
console.log(error);
}
}

const isCurrentDiscussion = activeDiscussion?.uuid === message.discussion;
Expand Down
14 changes: 9 additions & 5 deletions src/services/api/websocket/listeners/room/message/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,15 @@ export default async (message, { app }) => {
notification.notify();

if (document.hidden) {
sendWindowNotification({
title: message.contact.name,
message: message.text,
image: message.media?.[0]?.url,
});
try {
sendWindowNotification({
title: message.contact.name,
message: message.text,
image: message.media?.[0]?.url,
});
} catch (error) {
console.log(error);
}
}

const isCurrentRoom =
Expand Down
4 changes: 2 additions & 2 deletions src/utils/__tests__/notifications.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import isMobile from 'is-mobile';

vi.mock('@/plugins/i18n', () => ({
default: {
t: vi.fn((key) => key),
global: { t: vi.fn((key) => key) },
},
}));

Expand Down Expand Up @@ -98,7 +98,7 @@ describe('sendWindowNotification', () => {
image: 'Test Image',
});

expect(i18n.t).toHaveBeenCalledWith('media');
expect(i18n.global.t).toHaveBeenCalledWith('media');
expect(iframessa.emit).toHaveBeenCalledWith('notification', [
'Test Title',
{
Expand Down
2 changes: 1 addition & 1 deletion src/utils/notifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export function sendWindowNotification({
silent: true,
badge: logo,
icon: logo,
body: image ? `${i18n.t('media')}\n${message}` : message,
body: image ? `${i18n.global.t('media')}\n${message}` : message,
tag: title,
};

Expand Down

0 comments on commit 1b12945

Please sign in to comment.