|
29 | 29 | import SvgIcon from "$lib/SvgIcon.svelte"; |
30 | 30 | import DialogConfirm from "$lib/DialogConfirm.svelte"; |
31 | 31 | import ConversationHeader from "./ConversationHeader.svelte"; |
| 32 | + import Avatar from "$lib/Avatar.svelte"; |
32 | 33 |
|
33 | 34 | const conversationStore = getContext<{ getStore: () => ConversationStore }>( |
34 | 35 | "conversationStore", |
|
69 | 70 | let deleteMessageActionHashB64: undefined | ActionHashB64 = undefined; |
70 | 71 | let isDeletingMessage = false; |
71 | 72 |
|
| 73 | + let showAvatarDialog = false; |
| 74 | +
|
72 | 75 | let isFirstConfigLoad = true; |
73 | 76 | let isFirstProfilesLoad = true; |
74 | 77 | let isFirstLoadMessages = true; |
|
232 | 235 | </script> |
233 | 236 |
|
234 | 237 | <Header backUrl="/conversations"> |
| 238 | + <!-- Left slot: Back button + Avatar that opens dialog on click --> |
| 239 | + <div slot="left" class="flex items-center"> |
| 240 | + <ButtonIconBare |
| 241 | + on:click={() => goto('/conversations')} |
| 242 | + icon="caretLeft" |
| 243 | + moreClasses="!h-[16px] !w-[16px] text-base" |
| 244 | + moreClassesButton="p-4" |
| 245 | + /> |
| 246 | + <button class="flex items-center" on:click={() => showAvatarDialog = true}> |
| 247 | + {#if $conversation.dnaProperties.privacy === Privacy.Private} |
| 248 | + <div class="flex -space-x-1"> |
| 249 | + {#each $joined.list |
| 250 | + .filter(([agentPubKeyB64]) => agentPubKeyB64 !== myPubKeyB64) |
| 251 | + .slice(0, 2) as [agentPubKeyB64] (agentPubKeyB64)} |
| 252 | + <Avatar cellIdB64={$page.params.id} {agentPubKeyB64} size={40} moreClasses="ring-2 ring-surface-100-800-token" /> |
| 253 | + {/each} |
| 254 | + </div> |
| 255 | + {:else if $conversation.config?.image} |
| 256 | + <img |
| 257 | + src={$conversation.config.image} |
| 258 | + alt="Conversation" |
| 259 | + class="h-10 w-10 rounded-full object-cover" |
| 260 | + /> |
| 261 | + {/if} |
| 262 | + </button> |
| 263 | + </div> |
| 264 | + |
235 | 265 | <h1 slot="center" class="overflow-hidden text-ellipsis whitespace-nowrap p-4 text-center"> |
236 | 266 | {$conversationTitle} |
237 | 267 | </h1> |
|
275 | 305 | <ConversationMessages |
276 | 306 | loadingTop={loadingMessagesOld} |
277 | 307 | cellIdB64={$page.params.id} |
278 | | - messages={$messages.list.reverse()} |
| 308 | + messages={[...$messages.list].reverse()} |
279 | 309 | on:delete={(e) => { |
280 | 310 | deleteMessageActionHashB64 = e.detail; |
281 | 311 | showDeleteDialog = true; |
|
304 | 334 | > |
305 | 335 | <p>{$t("common.delete_message_dialog_message")}</p> |
306 | 336 | </DialogConfirm> |
| 337 | + |
| 338 | +<!-- Avatar Dialog for larger view --> |
| 339 | +{#if showAvatarDialog} |
| 340 | + <div |
| 341 | + class="fixed inset-0 z-50 flex items-center justify-center bg-black/70" |
| 342 | + on:click={() => showAvatarDialog = false} |
| 343 | + on:keydown={(e) => e.key === 'Escape' && (showAvatarDialog = false)} |
| 344 | + role="button" |
| 345 | + tabindex="0" |
| 346 | + > |
| 347 | + <div class="flex flex-col items-center gap-6 p-4"> |
| 348 | + {#if $conversation.dnaProperties.privacy === Privacy.Private} |
| 349 | + <div class="flex items-center gap-6"> |
| 350 | + {#each $joined.list |
| 351 | + .filter(([agentPubKeyB64]) => agentPubKeyB64 !== myPubKeyB64) |
| 352 | + .slice(0, 2) as [agentPubKeyB64] (agentPubKeyB64)} |
| 353 | + <Avatar cellIdB64={$page.params.id} {agentPubKeyB64} size={200} /> |
| 354 | + {/each} |
| 355 | + </div> |
| 356 | + {:else if $conversation.config?.image} |
| 357 | + <img |
| 358 | + src={$conversation.config.image} |
| 359 | + alt="Conversation" |
| 360 | + class="h-52 w-52 rounded-full object-cover" |
| 361 | + /> |
| 362 | + {/if} |
| 363 | + <h2 class="text-2xl font-semibold text-white">{$conversationTitle}</h2> |
| 364 | + </div> |
| 365 | + </div> |
| 366 | +{/if} |
0 commit comments