-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
760 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
<script lang="ts"> | ||
import adapters from '$lib/adapters' | ||
import routes from '$lib/routes' | ||
import type { InstallMessage, WithMeta } from '$lib/stores/chat' | ||
import { installedObjectStore } from '$lib/stores/installed-objects' | ||
import type { User } from '$lib/types' | ||
import Button from './button.svelte' | ||
import ChatMessage from './chat-message.svelte' | ||
import Container from './container.svelte' | ||
import CheckmarkFilled from './icons/checkmark-filled.svelte' | ||
import Loading from './loading.svelte' | ||
import ObjectInstallInfo from './object-install-info.svelte' | ||
import { goto } from '$app/navigation' | ||
import { hashString } from '$lib/adapters/waku/crypto' | ||
import Checkmark from './icons/checkmark.svelte' | ||
import Pending from './icons/pending.svelte' | ||
//am I the sender of this message? | ||
export let myMessage = false | ||
export let message: WithMeta<InstallMessage> | ||
export let users: User[] | ||
export let objects: string[] | undefined | ||
export let chatId: string | ||
//is this message in a group chat? | ||
export let group = false | ||
//is the sender of the current message the same as the previous message? | ||
export let sameSender = false | ||
export let senderName: string | undefined = undefined | ||
export let timestamp: string | undefined = undefined | ||
let senderNameLabel = myMessage | ||
? 'You' | ||
: users.find((user) => user.publicKey === message.senderPublicKey)?.name ?? '<unknown>' | ||
let recipientName = !group | ||
? myMessage | ||
? users.find((user) => user.publicKey !== message.senderPublicKey)?.name ?? '<unknown>' | ||
: 'you' | ||
: `chat members` | ||
$: object = $installedObjectStore.objects.get(message.objectId) | ||
$: isInstalledInChat = object && objects && objects.includes(object.objectId) | ||
async function acceptInstall(objectId: string) { | ||
await adapters.sendInstall(chatId, objectId, 'accept') | ||
} | ||
</script> | ||
|
||
<ChatMessage bubble={true} {group} {sameSender} {timestamp} {myMessage} object={true} {senderName}> | ||
{#if !object} | ||
<Loading /> | ||
{:else} | ||
<div class="wo text-normal"> | ||
<Container> | ||
{#if message.command === 'invite'} | ||
{senderNameLabel} invited {recipientName} to use "{object.name}" in this chat. | ||
{:else if message.command === 'accept'} | ||
{senderNameLabel} accepted the invite. You can now use "{object.name}" in this chat. | ||
{/if} | ||
</Container> | ||
<Container gap={12}> | ||
<ObjectInstallInfo | ||
onClick={() => object && goto(routes.SETTINGS_OBJECT(hashString(object.objectId)))} | ||
name={object.name} | ||
logoImg={object.logo} | ||
logoAlt={`${object.name} logo`} | ||
/> | ||
</Container> | ||
<Container padY={0}> | ||
{#if message.command === 'invite'} | ||
{#if isInstalledInChat} | ||
<p class="install-status"> | ||
<CheckmarkFilled />Invite accepted | ||
</p> | ||
{:else if myMessage} | ||
<p class="install-status"> | ||
<Pending />Invite pending | ||
</p> | ||
{:else} | ||
<Button variant="strong" on:click={() => acceptInstall(message.objectId)} | ||
><Checkmark /> Accept</Button | ||
> | ||
{/if} | ||
{:else if message.command === 'accept'} | ||
<p class="install-status"> | ||
{#if isInstalledInChat} | ||
<CheckmarkFilled />Invite accepted | ||
{:else} | ||
<Pending />Invite pending | ||
{/if} | ||
</p> | ||
{/if} | ||
</Container> | ||
</div> | ||
{/if} | ||
<svelte:fragment slot="avatar"> | ||
{#if $$slots.avatar} | ||
<slot name="avatar" /> | ||
{/if} | ||
</svelte:fragment> | ||
</ChatMessage> | ||
|
||
<style lang="scss"> | ||
.install-status { | ||
display: flex; | ||
flex-direction: row; | ||
justify-content: center; | ||
align-items: center; | ||
gap: var(--spacing-6); | ||
background-color: var(--color-step-10, var(--color-dark-step-50)); | ||
border-radius: var(--spacing-24); | ||
padding: var(--spacing-6); | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<script lang="ts"> | ||
export let size = 20 | ||
</script> | ||
|
||
<svg id="icon" xmlns="http://www.w3.org/2000/svg" width={size} height={size} viewBox="0 0 32 32"> | ||
<defs> | ||
<style> | ||
.cls-1 { | ||
fill: none; | ||
} | ||
</style> | ||
</defs> | ||
<path | ||
d="M28,30H4a2.0021,2.0021,0,0,1-2-2V4A2.0021,2.0021,0,0,1,4,2H28a2.0021,2.0021,0,0,1,2,2V28A2.0021,2.0021,0,0,1,28,30ZM4,4V28H28V4Z" | ||
transform="translate(0 0)" | ||
/> | ||
<rect x="13" y="7" width="2" height="7" /> | ||
<rect x="8" y="7" width="2" height="7" /> | ||
<path | ||
d="M22,14H20a2.0021,2.0021,0,0,1-2-2V9a2.0021,2.0021,0,0,1,2-2h2a2.0021,2.0021,0,0,1,2,2v3A2.0021,2.0021,0,0,1,22,14ZM20,9v3h2V9Z" | ||
transform="translate(0 0)" | ||
/> | ||
<rect x="22" y="18" width="2" height="7" /> | ||
<rect x="8" y="18" width="2" height="7" /> | ||
<path | ||
d="M17,25H15a2.0021,2.0021,0,0,1-2-2V20a2.0021,2.0021,0,0,1,2-2h2a2.0021,2.0021,0,0,1,2,2v3A2.0021,2.0021,0,0,1,17,25Zm-2-5v3h2V20Z" | ||
transform="translate(0 0)" | ||
/> | ||
<rect | ||
id="_Transparent_Rectangle_" | ||
data-name="<Transparent Rectangle>" | ||
class="cls-1" | ||
width="32" | ||
height="32" | ||
/> | ||
</svg> |
Oops, something went wrong.
c935f04
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
waku-objects-playground – ./
waku-objects-playground-waku-objects.vercel.app
waku-objects-playground.vercel.app
chat.wakuplay.im
waku-objects-playground-git-main-waku-objects.vercel.app