all repos — emessage @ 0cbb6ef61f1c6f3f3a199c14add57b3daed63684

The EMessage email client

frontend/src/lib/components/EnvelopeControl.svelte (view raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
<script lang="ts">
	import { goto } from "$app/navigation";
	import { global } from "$lib/global.svelte.js";

	let { fromContact, toContact } = $props();
	
	const fromName = `${fromContact.Firstname} ${fromContact.Lastname}`.trim();
	const toName = `${toContact.Firstname} ${toContact.Lastname}`.trim();
	
	async function check_from_select () {
 		const selected = fromSlct.options[fromSlct.selectedIndex];
 		if (selected && selected.id === 'editFromContact') {
			global.contact = fromContact;
 			goto("/contact");
 		}
	}
	async function check_to_select () {
 		const selected = toSlct.options[toSlct.selectedIndex];
 		if (selected && selected.id === 'editToContact') {
			global.contact = toContact;
 			goto("/contact");
 		}
	}
</script>

<div class="flex gap-2 text-xs">
	<span>From: {fromName}</span>
	<select id="fromSlct"
			onchange={check_from_select}>
		{#each fromContact.Emails as address}
			<option value={address.value}>&lt;{address.Value}&gt; ({address.Key})</option>
		{:else}
			<option>Nobody &lt;&gt;</option>
		{/each}
		<option id="editFromContact">Edit my contact card</option>
	</select>
	<span>To: {toName}</span>
	<select id="toSlct"
			onchange={check_to_select}>
		{#each toContact.Emails as address}
			<option value={address.value}>&lt;{address.Value}&gt; ({address.Key})</option>
		{:else}
			<option>Nobody &lt;&gt;</option>
		{/each}
		<option id="editToContact">Edit their contact card</option>
	</select>
</div>