Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(attachments): create attachments component to alleviate duplicate code #682

Merged
merged 41 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
583cdeb
make small
Jekrimo Sep 27, 2024
8b0a643
partial
Jekrimo Sep 30, 2024
4538143
fixes
Jekrimo Sep 30, 2024
5ede45a
clean
Jekrimo Sep 30, 2024
ab82d6b
Merge branch 'dev' into pin-button-size
Jekrimo Sep 30, 2024
065c7b8
Merge branch 'dev' into pin-button-size
stavares843 Oct 1, 2024
4cea9a9
test build
Jekrimo Oct 1, 2024
87f7483
Merge branch 'pin-button-size' of https://github.com/Satellite-im/Upl…
Jekrimo Oct 1, 2024
5c4e43c
deeper
Jekrimo Oct 1, 2024
11a6b57
maybe work now
Jekrimo Oct 1, 2024
fe79982
Merge branch 'dev' into pin-button-size
luisecm Oct 2, 2024
341be35
Merge branch 'dev' into pin-button-size
luisecm Oct 2, 2024
fc6e307
Merge branch 'dev' into pin-button-size
Jekrimo Oct 3, 2024
1be075b
Merge branch 'dev' into pin-button-size
phillsatellite Oct 3, 2024
b1dbaf0
Merge branch 'dev' into pin-button-size
phillsatellite Oct 3, 2024
48a21c2
Merge branch 'dev' into pin-button-size
luisecm Oct 3, 2024
f5e4840
Merge branch 'dev' into pin-button-size
luisecm Oct 4, 2024
b167106
Merge branch 'dev' into pin-button-size
luisecm Oct 5, 2024
4e5f27d
fix misstype
Jekrimo Oct 7, 2024
b1f5e06
Merge branch 'pin-button-size' of https://github.com/Satellite-im/Upl…
Jekrimo Oct 7, 2024
a7d0104
clean up repeat code
Jekrimo Oct 7, 2024
34df6b4
Merge branch 'dev' into make-attachment-component
stavares843 Oct 7, 2024
2ccbad8
Merge branch 'dev' into make-attachment-component
Jekrimo Oct 8, 2024
830bb0d
no indicator fix
Jekrimo Oct 8, 2024
6323c35
Merge branch 'make-attachment-component' of https://github.com/Satell…
Jekrimo Oct 8, 2024
d3e2dd9
fix preview popup
Jekrimo Oct 8, 2024
f880109
Merge branch 'dev' into make-attachment-component
stavares843 Oct 8, 2024
9e391e6
Merge branch 'dev' into make-attachment-component
stavares843 Oct 8, 2024
2ac1bd2
idk man
Jekrimo Oct 9, 2024
d925920
Merge branch 'dev' into make-attachment-component
lgmarchi Oct 9, 2024
5cd31b4
global try
Jekrimo Oct 10, 2024
f7c2232
Merge branch 'make-attachment-component' of https://github.com/Satell…
Jekrimo Oct 10, 2024
3c3239e
yayfix
Jekrimo Oct 10, 2024
342985d
fix
Jekrimo Oct 10, 2024
fcf65c5
Merge branch 'make-attachment-component' of https://github.com/Satell…
Jekrimo Oct 10, 2024
d3866b2
resolve conflicts
Jekrimo Oct 10, 2024
eef3dd6
Merge branch 'dev' into make-attachment-component
Jekrimo Oct 10, 2024
06ab124
Merge branch 'dev' into make-attachment-component
luisecm Oct 10, 2024
9c13c33
Merge branch 'dev' of https://github.com/Satellite-im/UplinkWeb into …
Jekrimo Oct 14, 2024
21ab654
unused css
Jekrimo Oct 14, 2024
30eccc0
Merge branch 'dev' into make-attachment-component
stavares843 Oct 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions src/lib/components/messaging/AttachmentRenderer.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<script lang="ts">
import { MessageAttachmentKind, Shape } from "$lib/enums"
import { FileEmbed, ImageEmbed, Modal, STLViewer } from "$lib/components"
import { OperationState, type Attachment } from "$lib/types"
import { RaygunStoreInstance } from "$lib/wasm/RaygunStore"
import TextDocument from "./embeds/TextDocument.svelte"
import AudioEmbed from "./embeds/AudioEmbed.svelte"
import VideoEmbed from "./embeds/VideoEmbed.svelte"
import { createEventDispatcher } from "svelte"
export let attachments: Attachment[] = []
export let messageId
export let chatID: string

async function download_attachment(message: string, attachment: Attachment) {
await RaygunStoreInstance.downloadAttachment(chatID, message, attachment.name, attachment.size)
}
const dispatch = createEventDispatcher()
const dispatcher = (event: string, detail: string) => {
dispatch(event, detail)
}
</script>

{#each attachments as attachment}
{#if attachment.kind === MessageAttachmentKind.File || attachment.location.length == 0}
<FileEmbed
altBackgroundColor={true}
fileInfo={{
id: "1",
isRenaming: OperationState.Initial,
source: "unknown",
name: attachment.name,
size: attachment.size,
icon: Shape.Document,
displayName: attachment.name,
type: "unknown/unknown",
remotePath: "",
}}
on:download={() => download_attachment(messageId, attachment)} />
{:else if attachment.kind === MessageAttachmentKind.Image}
<ImageEmbed
source={attachment.location}
name={attachment.name}
filesize={attachment.size}
on:click={() => {
dispatcher("openAttachment", attachment.location)
}}
on:download={() => download_attachment(messageId, attachment)} />
{:else if attachment.kind === MessageAttachmentKind.Text}
<TextDocument />
{:else if attachment.kind === MessageAttachmentKind.STL}
<STLViewer url={attachment.location} name={attachment.name} filesize={attachment.size} />
{:else if attachment.kind === MessageAttachmentKind.Audio}
<AudioEmbed location={attachment.location} name={attachment.name} size={attachment.size} />
{:else if attachment.kind === MessageAttachmentKind.Video}
<VideoEmbed location={attachment.location} name={attachment.name} size={attachment.size} />
{/if}
{/each}
Loading