diff --git a/src/lib/adapters/waku/index.ts b/src/lib/adapters/waku/index.ts index 21fed29b..1cda9b57 100644 --- a/src/lib/adapters/waku/index.ts +++ b/src/lib/adapters/waku/index.ts @@ -231,6 +231,8 @@ async function executeOnInstallMessage( chatId: string, message: WithMeta, ) { + console.debug({ publicKey, message }) + if (message.senderPublicKey === publicKey) { if (message.command === 'accept') { const installedObjects = get(installedObjectStore).objects @@ -275,22 +277,20 @@ async function executeOnInstallMessage( objectId: message.objectId, name: objectSpec.object.name, description: objectSpec.object.description, - // TODO fix relative path to absolute logo: objectSpec.object.files.logo.path, installed: false, } installedObjectStore.addInstalledObject(installedObject) } else if (message.command === 'accept') { - const installedObjects = get(installedObjectStore).objects - if (!installedObjects.has(message.objectId)) { + const installedObject = get(installedObjectStore).objects.get(message.objectId) + if (!installedObject) { return } - installedObjectStore.updateInstalledObject(message.objectId, (object) => ({ - ...object, - installed: true, - })) + if (!installedObject.installed) { + return + } // add to chat objects chats.updateChat(chatId, (chat) => { diff --git a/src/lib/components/chat-message.svelte b/src/lib/components/chat-message.svelte index 935184b0..00c77c0c 100644 --- a/src/lib/components/chat-message.svelte +++ b/src/lib/components/chat-message.svelte @@ -77,12 +77,14 @@ max-width: 75%; margin-right: auto; margin-left: 0; + font-family: (--font-serif); &:not(:last-child) { margin-bottom: var(--spacing-12); } &.object { + font-family: sans-serif; .message-content { width: 100%; } @@ -93,7 +95,6 @@ padding: var(--spacing-12); border-radius: var(--border-radius); display: inline-block; - font-family: var(--font-serif); background-color: var(--color-base, var(--color-dark-step-40)); } @@ -118,6 +119,10 @@ } } + &.object { + font-style: normal; + } + .timestamp { text-align: end; } diff --git a/src/lib/components/chat-object-invite.svelte b/src/lib/components/chat-object-invite.svelte index 3dd8aa84..35de1bd4 100644 --- a/src/lib/components/chat-object-invite.svelte +++ b/src/lib/components/chat-object-invite.svelte @@ -1,5 +1,6 @@ - + {#if !object} {:else}
{#if message.command === 'invite'} - {senderName} invited {recipientName} to use "{object.name}" in this chat. + {senderNameLabel} invited {recipientName} to use "{object.name}" in this chat. {:else if message.command === 'accept'} - {senderName} accepted the invite. You can now use "{object.name}" in this chat. + {senderNameLabel} accepted the invite. You can now use "{object.name}" in this chat. {/if} - + object && goto(routes.SETTINGS_OBJECT(hashString(object.objectId)))} + name={object.name} + logoImg={object.logo} + logoAlt={`${object.name} logo`} + /> {#if message.command === 'invite'} - {#if myMessage} + {#if isInstalledInChat} +

+ Invite accepted +

+ {:else if myMessage}

- {#if isInstalledInChat} - Invite accepted - {:else} - Invite pending... - {/if} + Invite pending

{:else} - acceptInstall(message.objectId)} + > Accept {/if} {:else if message.command === 'accept'} @@ -75,20 +89,29 @@ {#if isInstalledInChat} Invite accepted {:else} - Invite pending... + Invite pending {/if}

{/if}
{/if} + + {#if $$slots.avatar} + + {/if} +
diff --git a/src/lib/components/icons/information.svelte b/src/lib/components/icons/information.svelte new file mode 100644 index 00000000..4a5149ea --- /dev/null +++ b/src/lib/components/icons/information.svelte @@ -0,0 +1,23 @@ + + + + + + + + + + + diff --git a/src/lib/components/object-install-info.svelte b/src/lib/components/object-install-info.svelte new file mode 100644 index 00000000..1215dde8 --- /dev/null +++ b/src/lib/components/object-install-info.svelte @@ -0,0 +1,55 @@ + + +
+ {#if logoImg} + {logoAlt} + {/if} + {#if name} +

{name}

+ {/if} +
+ +
+ +
+ + diff --git a/src/routes/chat/[id]/object/new/+page.svelte b/src/routes/chat/[id]/object/new/+page.svelte index f237c209..1291637b 100644 --- a/src/routes/chat/[id]/object/new/+page.svelte +++ b/src/routes/chat/[id]/object/new/+page.svelte @@ -97,17 +97,6 @@ console.debug('send invite', { object }) - const wallet = $walletStore.wallet - if (!wallet) { - errorStore.addEnd({ - title: 'Wallet Error', - message: 'No wallet found', - retry: () => sendInstallInvite(object), - reload: true, - }) - return - } - try { await adapters.sendInstall($page.params.id, object.objectId, 'invite') showInvite = undefined diff --git a/src/routes/group/chat/[id]/+page.svelte b/src/routes/group/chat/[id]/+page.svelte index 388acaba..dacc5b51 100644 --- a/src/routes/group/chat/[id]/+page.svelte +++ b/src/routes/group/chat/[id]/+page.svelte @@ -38,6 +38,7 @@ import ChatDateBadge from '$lib/components/chat-date-badge.svelte' import { errorStore } from '$lib/stores/error' import { publicKeyToAddress } from '$lib/adapters/waku/crypto' + import ChatObjectInvite from '$lib/components/chat-object-invite.svelte' let div: HTMLElement let autoscroll = true @@ -197,12 +198,14 @@ {:else} + {@const publicKey = wallet.signingKey.compressedPublicKey}
{#each messages as message, i} + {@const sender = chat.users.find((u) => message.senderPublicKey === u.publicKey)} {#if message.type === 'user' && message.text?.length > 0} {@const sameSender = messages[i].senderPublicKey === messages[i - 1]?.senderPublicKey} @@ -210,10 +213,6 @@ i + 1 === messages.length || messages[i].senderPublicKey !== messages[i + 1]?.senderPublicKey || messages[i + 1]?.type !== 'user'} - {@const sender = chat.users.find( - (u) => message.senderPublicKey === u.publicKey, - )} - {@const publicKey = wallet.signingKey.compressedPublicKey} {#if i === 0 || (i > 0 && areDifferentDays(messages[i].timestamp, messages[i - 1].timestamp))} {/if} @@ -238,6 +237,23 @@ {:else if message.type === 'data'} + {:else if message.type === 'install'} + + + {#if message.senderPublicKey !== publicKey} + + {/if} + + {/if} {/each}
diff --git a/src/routes/identity/+page.svelte b/src/routes/identity/+page.svelte index ed7da393..165b7aaa 100644 --- a/src/routes/identity/+page.svelte +++ b/src/routes/identity/+page.svelte @@ -29,13 +29,10 @@ import { uploadPicture } from '$lib/adapters/ipfs' import Avatar from '$lib/components/avatar.svelte' import { errorStore } from '$lib/stores/error' - import { installedObjectStore } from '$lib/stores/installed-objects' - import { getObjectSpec } from '$lib/objects/external/lib' import DataBlob from '$lib/components/icons/data-blob.svelte' let avatar = $profile.avatar let name = $profile.name - let objectPath = '' $: if ($profile.loading === false && !name && !avatar) { name = $profile.name diff --git a/src/routes/objects/+page.svelte b/src/routes/objects/+page.svelte index bd594b85..7da99e7b 100644 --- a/src/routes/objects/+page.svelte +++ b/src/routes/objects/+page.svelte @@ -22,7 +22,7 @@ let objectPath = '' $: loading = $installedObjectStore.loading - $: installedObjects = loading ? [] : getInstalledObjectList() + $: installedObjects = $installedObjectStore && getInstalledObjectList() async function addObject() { const { object } = await getObjectSpec(objectPath, 'chat') @@ -75,6 +75,7 @@ {/each} + Developer stuff diff --git a/src/routes/objects/[object_id]/+page.svelte b/src/routes/objects/[object_id]/+page.svelte index 49ff6e57..8e807276 100644 --- a/src/routes/objects/[object_id]/+page.svelte +++ b/src/routes/objects/[object_id]/+page.svelte @@ -13,6 +13,7 @@ import { page } from '$app/stores' import { getInstalledObjectList } from '$lib/objects/lookup' import { hashString } from '$lib/adapters/waku/crypto' + import TrashCan from '$lib/components/icons/trash-can.svelte' let hashedObjectId = $page.params.object_id @@ -20,8 +21,6 @@ $: objects = loading ? undefined : getInstalledObjectList() $: object = objects?.find((object) => hashString(object.objectId) === hashedObjectId) - $: console.debug({ objects, object }) - function uninstall(objectId: string) { // TODO are you sure dialog installedObjectStore.removeInstalledObject(objectId) @@ -46,12 +45,13 @@ + {object.name}

{object.name}

{object.description}

{#if !object.preInstalled && object.installed} - + {/if}
@@ -59,17 +59,14 @@