-
Notifications
You must be signed in to change notification settings - Fork 43
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
13 changed files
with
467 additions
and
428 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<script lang="ts"> | ||
import { profile } from '$lib/auth.js' | ||
import UserLink from '$lib/components/lemmy/user/UserLink.svelte' | ||
import Markdown from '$lib/components/markdown/Markdown.svelte' | ||
import type { PrivateMessageView } from 'lemmy-js-client' | ||
import { Icon, PaperAirplane } from 'svelte-hero-icons' | ||
export let message: PrivateMessageView | ||
</script> | ||
|
||
<div class="flex flex-col gap-2"> | ||
<div class="flex flex-row gap-2 items-center flex-wrap"> | ||
<span class="font-medium text-xs">From</span> | ||
<UserLink | ||
showInstance={false} | ||
user={message.creator} | ||
avatar | ||
avatarSize={20} | ||
shownBadges={{ | ||
admin: true, | ||
banned: true, | ||
bot: true, | ||
you: $profile?.user?.local_user_view.person.id == message.creator.id, | ||
}} | ||
/> | ||
{#if $profile?.user?.local_user_view.person.id != message.recipient.id} | ||
to | ||
<UserLink | ||
showInstance={false} | ||
user={message.recipient} | ||
avatar | ||
avatarSize={20} | ||
shownBadges={{ | ||
admin: true, | ||
banned: true, | ||
bot: true, | ||
you: | ||
$profile?.user?.local_user_view.person.id == message.recipient.id, | ||
}} | ||
/> | ||
{/if} | ||
</div> | ||
<Markdown source={message.private_message.content} /> | ||
</div> |
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,61 @@ | ||
<script lang="ts"> | ||
import { profile } from '$lib/auth.js' | ||
import UserLink from '$lib/components/lemmy/user/UserLink.svelte' | ||
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte' | ||
import { getClient } from '$lib/lemmy.js' | ||
import type { Person } from 'lemmy-js-client' | ||
import { Button, Modal, toast } from 'mono-svelte' | ||
export let open: boolean = false | ||
export let user: Person | ||
let message = '' | ||
let loading = false | ||
async function sendMessage() { | ||
if (!$profile?.jwt || message == '') return | ||
loading = true | ||
try { | ||
await getClient().createPrivateMessage({ | ||
auth: $profile.jwt, | ||
content: message, | ||
recipient_id: user.id, | ||
}) | ||
toast({ | ||
content: 'Successfully sent that person a message.', | ||
type: 'success', | ||
}) | ||
open = false | ||
} catch (err) { | ||
toast({ | ||
content: err as any, | ||
type: 'error', | ||
}) | ||
} | ||
loading = false | ||
} | ||
</script> | ||
|
||
<Modal bind:open> | ||
<h1 class="text-2xl font-bold" slot="title">Message</h1> | ||
<form on:submit|preventDefault={sendMessage} class="flex flex-col gap-4"> | ||
<p class="inline-flex flex-row gap-2 items-center"> | ||
Sending <UserLink avatar {user} /> a message | ||
</p> | ||
<MarkdownEditor | ||
bind:value={message} | ||
label="Message" | ||
placeholder="your hair looks nice today" | ||
rows={4} | ||
/> | ||
<Button color="primary" size="lg" submit {loading} disabled={loading}> | ||
Send | ||
</Button> | ||
</form> | ||
</Modal> |
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.