From 1dd1da9298795fd6785de1401108126fd91b1552 Mon Sep 17 00:00:00 2001 From: Xylight Date: Wed, 24 Jul 2024 21:38:38 -0700 Subject: [PATCH 1/6] fix: fixed width for thumbnails to prevent cls --- src/lib/components/lemmy/post/PostLink.svelte | 37 ++++++++++++++----- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/src/lib/components/lemmy/post/PostLink.svelte b/src/lib/components/lemmy/post/PostLink.svelte index ade3bfd9..2d99f095 100644 --- a/src/lib/components/lemmy/post/PostLink.svelte +++ b/src/lib/components/lemmy/post/PostLink.svelte @@ -19,7 +19,10 @@ For embed-type posts. Displays embed card or a compact link. --> {#if embed_title && !compact} - +
{#if richURL} - {embed_title} + + + + + {embed_title} + {/if} @@ -92,7 +109,7 @@ {embed_title Date: Wed, 24 Jul 2024 21:41:07 -0700 Subject: [PATCH 2/6] misc: improve color --- src/lib/components/lemmy/post/PostActions.svelte | 2 +- src/lib/components/lemmy/post/PostVote.svelte | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/lib/components/lemmy/post/PostActions.svelte b/src/lib/components/lemmy/post/PostActions.svelte index b4c6a5d4..c281c934 100644 --- a/src/lib/components/lemmy/post/PostActions.svelte +++ b/src/lib/components/lemmy/post/PostActions.svelte @@ -148,7 +148,7 @@
- + {#if !LINKED_INSTANCE_URL} + + {/if} From 3631cb46275d26b1430233e24c99febb63a84487 Mon Sep 17 00:00:00 2001 From: Xylight Date: Thu, 25 Jul 2024 10:08:30 -0700 Subject: [PATCH 5/6] fix: ssr issue, close #378 --- src/lib/components/lemmy/dropdowns/Sort.svelte | 4 ++-- src/lib/lemmy/postfeed.ts | 11 ++++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/lib/components/lemmy/dropdowns/Sort.svelte b/src/lib/components/lemmy/dropdowns/Sort.svelte index bf6c23f6..ecd10b1d 100644 --- a/src/lib/components/lemmy/dropdowns/Sort.svelte +++ b/src/lib/components/lemmy/dropdowns/Sort.svelte @@ -15,9 +15,9 @@ export let navigate: boolean = true export let changeDefault: boolean = false - let sort: string = selected.startsWith('Top') ? 'TopAll' : selected + let sort: string = selected?.startsWith('Top') ? 'TopAll' : selected $: if (selected) { - sort = selected.startsWith('Top') ? 'TopAll' : selected + sort = selected?.startsWith('Top') ? 'TopAll' : selected } const setSelected = () => (selected = sort) $: changeDefault diff --git a/src/lib/lemmy/postfeed.ts b/src/lib/lemmy/postfeed.ts index 516c5959..ead24319 100644 --- a/src/lib/lemmy/postfeed.ts +++ b/src/lib/lemmy/postfeed.ts @@ -51,7 +51,16 @@ export async function postFeed(args: { instance: get(instance), }) - return get(postFeeds)[args.id].data + return ( + get(postFeeds)[args.id]?.data ?? { + ...args.request, + posts: posts, + cursor: { + next: posts.next_page, + }, + type_: args.request.type_, + } + ) } export function getPostFeed(feeds: Map, id: PostFeedID) { From ababbb437100b824ab522d5be669a8b8de516ef9 Mon Sep 17 00:00:00 2001 From: Xylight Date: Thu, 25 Jul 2024 10:28:33 -0700 Subject: [PATCH 6/6] fix: store.set is not a function, close #375 --- src/lib/auth.ts | 32 +++++++++++++++--- .../lemmy/community/CommunityForm.svelte | 33 +++++++++++++------ src/lib/i18n/en.json | 6 ++++ src/lib/lemmy/user.ts | 23 +++++++------ src/routes/c/[name]/settings/+layout.svelte | 29 +++++++++++----- src/routes/create/community/+page.svelte | 4 +-- 6 files changed, 90 insertions(+), 37 deletions(-) diff --git a/src/lib/auth.ts b/src/lib/auth.ts index 1569ea4c..efa461d6 100644 --- a/src/lib/auth.ts +++ b/src/lib/auth.ts @@ -19,6 +19,7 @@ import { writable, type Readable, type Writable, + type Updater, } from 'svelte/store' import { MINIMUM_VERSION, versionIsSupported } from '$lib/version.js' import { browser } from '$app/environment' @@ -102,9 +103,31 @@ let fetchUser = { prevProfile: -1, } -export let profile: Readable = derived( - profileData, - (pd, set, update) => { +function profileStore( + data: Writable, + fn: ( + values: ProfileData, + set: (value: Profile) => void, + update: (fn: Updater) => void + ) => any +) { + const derive: Readable = derived(data, fn) + const { subscribe } = derive + + return { + subscribe, + set: (value: Profile) => { + data.update((data) => { + let index = data.profiles.findIndex((t) => t.id == value.id) + data.profiles[index] = value + return data + }) + }, + } +} + +export let profile: Readable & { set: (v: Profile) => void } = + profileStore(profileData, (pd, set, update) => { const profile = pd.profiles.find((p) => p.id == pd.profile) ?? getDefaultProfile() @@ -154,8 +177,7 @@ export let profile: Readable = derived( fetchUser.loading = false } } - } -) + }) export let notifications = writable({ applications: 0, diff --git a/src/lib/components/lemmy/community/CommunityForm.svelte b/src/lib/components/lemmy/community/CommunityForm.svelte index 9e17f6c9..f725d052 100644 --- a/src/lib/components/lemmy/community/CommunityForm.svelte +++ b/src/lib/components/lemmy/community/CommunityForm.svelte @@ -75,15 +75,25 @@ }) if ($profile.user) { - $profile.user = { - ...$profile.user, - moderates: [ - ...$profile.user.moderates, - { - community: res.community_view.community, - moderator: $profile.user.local_user_view.person, - }, - ], + const c = $profile.user.moderates + .map((m) => m.community.id) + .indexOf(res.community_view.community.id) + if (c != -1) { + $profile.user.moderates[c] = { + community: res.community_view.community, + moderator: $profile.user.local_user_view.person, + } + } else { + $profile.user = { + ...$profile.user, + moderates: [ + ...$profile.user.moderates, + { + community: res.community_view.community, + moderator: $profile.user.local_user_view.person, + }, + ], + } } addSubscription(res.community_view.community, true) @@ -106,7 +116,10 @@ } -
+
{$t('routes.createCommunity')}
diff --git a/src/lib/i18n/en.json b/src/lib/i18n/en.json index 19f775e1..1d273d80 100644 --- a/src/lib/i18n/en.json +++ b/src/lib/i18n/en.json @@ -360,6 +360,12 @@ "title": "Reset Theme", "description": "This will reset all of your colors to the default. It is recommended to export your theme before this." } + }, + "community": { + "settings": { + "team": "Team", + "settings": "Settings" + } } }, "cards": { diff --git a/src/lib/lemmy/user.ts b/src/lib/lemmy/user.ts index 3dab12e9..7ba41b06 100644 --- a/src/lib/lemmy/user.ts +++ b/src/lib/lemmy/user.ts @@ -22,20 +22,23 @@ export const addSubscription = ( community: Community, subscribe: boolean = true ) => { - const pd = get(profileData) - const p = pd.profiles.find((p) => p.id == pd.profile) + const p = get(profile) - if (!p?.user) return + if (!p.user) return - if (subscribe) { - profileData.set(pd) + const index = p.user.follows.map((f) => f.community.id).indexOf(community.id) + + if (subscribe && index == -1) { + p.user.follows.push({ + // @ts-ignore + follower: p.user.follows[0]?.follower, + community: community, + }) } else { - p.user.follows.splice( - p.user.follows.findIndex((i) => i.community.id == community.id), - 1 - ) - profileData.set(pd) + p.user.follows.splice(index, 1) } + + profile.set(p) } export const addAdmin = async (handle: string, added: boolean, jwt: string) => diff --git a/src/routes/c/[name]/settings/+layout.svelte b/src/routes/c/[name]/settings/+layout.svelte index c6722de6..5f2b4727 100644 --- a/src/routes/c/[name]/settings/+layout.svelte +++ b/src/routes/c/[name]/settings/+layout.svelte @@ -2,6 +2,9 @@ import { goto } from '$app/navigation' import { page } from '$app/stores' import MultiSelect from '$lib/components/input/Switch.svelte' + import Tabs from '$lib/components/ui/layout/pages/Tabs.svelte' + import { contentPadding } from '$lib/components/ui/layout/Shell.svelte' + import { t } from '$lib/translations.js' import { fullCommunityName } from '$lib/util.js' import type { PageData } from './$types.js' @@ -14,14 +17,22 @@
- { - goto(e.detail) - }} - /> +
+ +
diff --git a/src/routes/create/community/+page.svelte b/src/routes/create/community/+page.svelte index 12f93ff3..61bce637 100644 --- a/src/routes/create/community/+page.svelte +++ b/src/routes/create/community/+page.svelte @@ -2,6 +2,4 @@ import CommunityForm from '$lib/components/lemmy/community/CommunityForm.svelte' -
- -
+