Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,23 @@
let scheduledAt: string;

async function create() {
const isDraft = draft;
draft = false;

const trimmedTitle = title?.trim() ?? '';
const trimmedBody = body?.trim() ?? '';

if (!isDraft && (!trimmedTitle || !trimmedBody)) {
addNotification({
type: 'error',
message: 'Title and message body cannot be empty.'
});
return;
}

if (title !== undefined) title = trimmedTitle;
if (body !== undefined) body = trimmedBody;

try {
const messageId = id || ID.unique();
const fileCompoundId = file ? `${file.bucketId}:${file.$id}` : undefined;
Expand All @@ -56,7 +73,7 @@
targets,
data: customData,
image: fileCompoundId,
draft,
draft: isDraft,
scheduledAt
});

Expand Down