-
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
18 changed files
with
649 additions
and
55 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
<script lang="ts"> | ||
import adapters from '$lib/adapters' | ||
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 ObjectHeader from './object-header.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 timestamp: string | undefined = undefined | ||
let senderName = | ||
users.find((user) => user.publicKey === message.senderPublicKey)?.name ?? '<unknown>' | ||
let recipientName = myMessage | ||
? 'you' | ||
: users.length === 2 | ||
? users.find((user) => user.publicKey !== message.senderPublicKey)?.name ?? '<unknown>' | ||
: `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}> | ||
{#if !object} | ||
<Loading /> | ||
{:else} | ||
<div class="wo text-normal"> | ||
<Container> | ||
{#if message.command === 'invite'} | ||
{senderName} 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. | ||
{/if} | ||
</Container> | ||
<Container gap={12}> | ||
<ObjectHeader name={object.name} logoImg={object.logo} logoAlt={`${object.name} logo`} /> | ||
</Container> | ||
<Container padY={0}> | ||
{#if message.command === 'invite'} | ||
{#if myMessage} | ||
<p class="install-status"> | ||
{#if isInstalledInChat} | ||
<CheckmarkFilled />Invite accepted | ||
{:else} | ||
Invite pending... | ||
{/if} | ||
</p> | ||
{:else} | ||
<Button variant="strong" on:click={() => acceptInstall(message.objectId)}>Accept</Button | ||
> | ||
{/if} | ||
{:else if message.command === 'accept'} | ||
<p class="install-status"> | ||
{#if isInstalledInChat} | ||
<CheckmarkFilled />Invite accepted | ||
{:else} | ||
Invite pending... | ||
{/if} | ||
</p> | ||
{/if} | ||
</Container> | ||
</div> | ||
{/if} | ||
</ChatMessage> | ||
|
||
<style lang="scss"> | ||
.install-status { | ||
display: flex; | ||
flex-direction: row; | ||
align-items: center; | ||
gap: 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> |
File renamed without changes.
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
Oops, something went wrong.