diff --git a/src/routes/(console)/project-[project]/messaging/message-[message]/+layout.ts b/src/routes/(console)/project-[project]/messaging/message-[message]/+layout.ts index 7e3985ea37..637631dd93 100644 --- a/src/routes/(console)/project-[project]/messaging/message-[message]/+layout.ts +++ b/src/routes/(console)/project-[project]/messaging/message-[message]/+layout.ts @@ -41,13 +41,21 @@ export const load: LayoutLoad = async ({ params, depends }) => { }) ); - await Promise.allSettled(usersPromise); + const messageRecipients: Record> = {}; + const messageRecipientsPromise = Object.values(message.users).map((userId) => + sdk.forProject.users.get(userId).then((user) => { + messageRecipients[user.$id] = user; + }) + ); + + await Promise.allSettled([usersPromise, messageRecipientsPromise]); return { message, topicsById, targetsById, usersById, + messageRecipients, header: Header, breadcrumbs: Breadcrumbs }; diff --git a/src/routes/(console)/project-[project]/messaging/message-[message]/+page.svelte b/src/routes/(console)/project-[project]/messaging/message-[message]/+page.svelte index 878c47ffdc..6e299cc847 100644 --- a/src/routes/(console)/project-[project]/messaging/message-[message]/+page.svelte +++ b/src/routes/(console)/project-[project]/messaging/message-[message]/+page.svelte @@ -12,6 +12,7 @@ import { MessagingProviderType } from '@appwrite.io/console'; import UpdateTopics from './updateTopics.svelte'; import UpdateTargets from './updateTargets.svelte'; + import Recipients from './recipients.svelte'; import { onMount } from 'svelte'; export let data: PageData; @@ -34,6 +35,7 @@ {/if} + {#if $message.status !== 'processing'} {/if} diff --git a/src/routes/(console)/project-[project]/messaging/message-[message]/emailMessage.svelte b/src/routes/(console)/project-[project]/messaging/message-[message]/emailMessage.svelte index fc897c3984..36c479683b 100644 --- a/src/routes/(console)/project-[project]/messaging/message-[message]/emailMessage.svelte +++ b/src/routes/(console)/project-[project]/messaging/message-[message]/emailMessage.svelte @@ -60,25 +60,21 @@ subject === message.data.subject && content === message.data.content && html === ((message.data['html'] ?? false) as boolean); + + $: isDraft = message.status === 'draft';
- +
Message
- - + + Enable the HTML mode if your message contains HTML tags. diff --git a/src/routes/(console)/project-[project]/messaging/message-[message]/recipients.svelte b/src/routes/(console)/project-[project]/messaging/message-[message]/recipients.svelte new file mode 100644 index 0000000000..fcce2439d3 --- /dev/null +++ b/src/routes/(console)/project-[project]/messaging/message-[message]/recipients.svelte @@ -0,0 +1,91 @@ + + + + Users + + {@const sum = messageRecipients.length} + {#if sum} +
+ + + Name + Identifier + + + {#each messageRecipients.slice(offset, offset + limit) as recipient (recipient.$id)} + + +
+ + {recipient.name} + +
+
+ + + {getIdentifier(recipient)} + + +
+ {/each} +
+
+
+

Total users: {messageRecipients.length}

+ +
+
+ {:else} + +
+ No users have been selected. +

+ Need a hand? Check out our + + . +

+
+
+ {/if} +
+
diff --git a/src/routes/(console)/project-[project]/messaging/message-[message]/updateTargets.svelte b/src/routes/(console)/project-[project]/messaging/message-[message]/updateTargets.svelte index 8c112fba95..c05bdce614 100644 --- a/src/routes/(console)/project-[project]/messaging/message-[message]/updateTargets.svelte +++ b/src/routes/(console)/project-[project]/messaging/message-[message]/updateTargets.svelte @@ -93,11 +93,13 @@ } } + $: isDraft = message.status === 'draft'; + $: disabled = symmetricDifference(targetIds, Object.keys(selectedTargetsById)).length === 0; - + Targets {@const sum = targetIds.length} @@ -106,7 +108,7 @@
Target
- {#if message.status == 'draft'} + {#if isDraft}