feat: switch to new account system

This commit is contained in:
Xyphyn committed 2023-08-01 13:00:06 -07:00
1 parent 54ab6fdc82
commit 2da415b670
38 files changed
+222 -362

No files matched your search

+5 -4
View File
@@ -2,19 +2,20 @@
import InboxItem from './InboxItem.svelte'
import Button from '$lib/components/input/Button.svelte'
import { Check, EnvelopeOpen, Icon } from 'svelte-hero-icons'
import { authData, getClient, user } from '$lib/lemmy.js'
import { getClient } from '$lib/lemmy.js'
import { goto } from '$app/navigation'
import { page } from '$app/stores'
import { isRead } from '$lib/lemmy/inbox.js'
import Pageination from '$lib/components/ui/Pageination.svelte'
import MultiSelect from '$lib/components/input/MultiSelect.svelte'
import { profile } from '$lib/auth.js'
export let data
let markingAsRead = false
async function markAllAsRead() {
if (!$user) {
if (!$profile?.user) {
goto('/login')
return
}
@@ -22,10 +23,10 @@
markingAsRead = true
const response = await getClient().markAllAsRead({
auth: $authData!.token,
auth: $profile.jwt!,
})
$user!.unreads = 0
$profile.user.unreads = 0
goto($page.url, {
invalidateAll: true,
+5 -4
View File
@@ -1,12 +1,13 @@
import { authData, getClient } from '$lib/lemmy.js'
import { profile } from '$lib/auth.js'
import { getClient } from '$lib/lemmy.js'
import { getInboxItemPublished } from '$lib/lemmy/inbox.js'
import { get } from 'svelte/store'
type InboxFeedType = 'replies' | 'mentions' | 'messages' | 'all'
export async function load({ url }) {
const auth = get(authData)
if (!auth) return
const auth = get(profile)
if (!auth?.jwt) return
const type: InboxFeedType =
(url.searchParams.get('type') as InboxFeedType) || 'all'
@@ -18,7 +19,7 @@ export async function load({ url }) {
const params = {
limit: 50,
page: page,
auth: auth.token,
auth: auth.jwt,
unread_only: unreadOnly,
}
+7 -8
View File
@@ -1,15 +1,14 @@
<script lang="ts">
import { goto } from '$app/navigation'
import Button from '$lib/components/input/Button.svelte'
import Link from '$lib/components/input/Link.svelte'
import TextArea from '$lib/components/input/TextArea.svelte'
import Comment from '$lib/components/lemmy/comment/Comment.svelte'
import Markdown from '$lib/components/markdown/Markdown.svelte'
import Card from '$lib/components/ui/Card.svelte'
import { ToastType, addToast } from '$lib/components/ui/toasts/toasts.js'
import UserLink from '$lib/components/lemmy/user/UserLink.svelte'
import { authData, getClient, user } from '$lib/lemmy.js'
import { Color } from '$lib/ui/colors.js'
import { getClient } from '$lib/lemmy.js'
import { profile } from '$lib/auth.js'
import type {
CommentReplyView,
PersonMentionView,
@@ -34,13 +33,13 @@
async function replyToMessage(
message: PrivateMessageView | CommentReplyView | PersonMentionView
) {
if (!$authData) return
if (!$profile?.jwt) return
loading = true
try {
await getClient().createPrivateMessage({
auth: $authData.token,
auth: $profile.jwt,
content: reply,
recipient_id: message.creator.id,
})
@@ -105,7 +104,7 @@
overflow-hidden flex flex-row items-center gap-1 {read ? 'opacity-80' : ''}"
>
<span class="font-bold flex items-center">
{#if item.creator.id == $user?.local_user_view.person.id}
{#if item.creator.id == $profile?.user?.local_user_view.person.id}
You
{:else}
<UserLink avatar user={item.creator} />
@@ -113,7 +112,7 @@
</span>
<span>messaged</span>
<span class="font-bold flex items-center">
{#if item.recipient.id == $user?.local_user_view.person.id}
{#if item.recipient.id == $profile?.user?.local_user_view.person.id}
You
{:else}
<UserLink avatar user={item.recipient} />
@@ -124,7 +123,7 @@
<p class="text-sm py-2">
<Markdown source={item.private_message.content} />
</p>
{#if item.recipient.id == $user?.local_user_view.person.id}
{#if item.recipient.id == $profile?.user?.local_user_view.person.id}
<div class="flex flex-row gap-2">
<Button color="ghost" on:click={() => (replying = !replying)}>
<Icon mini src={ChatBubbleOvalLeft} width={16} />