Skip to content

Commit

Permalink
- fix: error when lastMessage is null (#98)
Browse files Browse the repository at this point in the history
  • Loading branch information
agallardol authored Nov 29, 2023
1 parent bb461f0 commit 8dfe169
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion apps/shinkai-visor/src/components/inboxes/inboxes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export const Inboxes = () => {
{inbox.custom_name}
</span>
<div className="truncate text-left text-xs text-gray-100">
{getMessageContent(inbox.last_message)}
{inbox.last_message && getMessageContent(inbox.last_message)}
</div>
</div>
</div>
Expand Down
5 changes: 3 additions & 2 deletions libs/shinkai-message-ts/src/utils/shinkai_message_handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ export const isJobMessage = (message: ShinkaiMessage) => {
);
};

export const getMessageContent = (message: ShinkaiMessage) => {
export const getMessageContent = (message: ShinkaiMessage): string => {
if (!message) return '';
// unnencrypted content
if (message.body && 'unencrypted' in message.body) {
if ('unencrypted' in message.body.unencrypted.message_data) {
Expand Down Expand Up @@ -47,7 +48,7 @@ export const getMessageContent = (message: ShinkaiMessage) => {
return message.body.unencrypted.message_data.encrypted.content;
}
// raw content for encrypted body
return message.body?.encrypted.content;
return message.body?.encrypted.content || '';
};

export const getMessageFilesInbox = (message: ShinkaiMessage): string | undefined => {
Expand Down

0 comments on commit 8dfe169

Please sign in to comment.