Merge branch 'main' into new-theme-handler
This commit is contained in:
commit
6fd970320b
14 files changed
+148
-75
No files matched your search
+27
-5
@@ -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<Profile> = derived(
|
||||
profileData,
|
||||
(pd, set, update) => {
|
||||
function profileStore(
|
||||
data: Writable<ProfileData>,
|
||||
fn: (
|
||||
values: ProfileData,
|
||||
set: (value: Profile) => void,
|
||||
update: (fn: Updater<Profile>) => void
|
||||
) => any
|
||||
) {
|
||||
const derive: Readable<Profile> = 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<Profile> & { 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<Profile> = derived(
|
||||
fetchUser.loading = false
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
export let notifications = writable<Notifications>({
|
||||
applications: 0,
|
||||
|
||||
@@ -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 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<form on:submit|preventDefault={submit} class="flex flex-col gap-4 h-full">
|
||||
<form
|
||||
on:submit|preventDefault={submit}
|
||||
class="flex flex-col gap-4 h-full w-full"
|
||||
>
|
||||
<slot name="formtitle">
|
||||
<Header>{$t('routes.createCommunity')}</Header>
|
||||
</slot>
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -148,7 +148,7 @@
|
||||
<Button
|
||||
size="sm"
|
||||
href="/post/{getInstance()}/{post.post.id}"
|
||||
class="text-inherit h-full px-3"
|
||||
class="!text-inherit h-full px-3"
|
||||
color="ghost"
|
||||
rounding="pill"
|
||||
target={$userSettings.openLinksInNewTab ? '_blank' : ''}
|
||||
|
||||
@@ -19,7 +19,10 @@
|
||||
For embed-type posts. Displays embed card or a compact link.
|
||||
-->
|
||||
{#if embed_title && !compact}
|
||||
<Material color="distinct" class="flex flex-col-reverse sm:flex-row overflow-hidden gap-4">
|
||||
<Material
|
||||
color="distinct"
|
||||
class="flex flex-col-reverse sm:flex-row overflow-hidden gap-4"
|
||||
>
|
||||
<div class="flex flex-col gap-2">
|
||||
{#if richURL}
|
||||
<Link
|
||||
@@ -52,14 +55,28 @@
|
||||
target="_blank"
|
||||
class="-m-4 mb-auto sm:-mb-4 sm:ml-auto flex-shrink-0 sm:w-1/3 sm:max-w-60"
|
||||
>
|
||||
<img
|
||||
src={optimizeImageURL(thumbnail_url, 256)}
|
||||
class="w-full h-full object-cover bg-slate-200 dark:bg-zinc-800"
|
||||
width={600}
|
||||
height={400}
|
||||
alt={embed_title}
|
||||
class:blur-3xl={nsfw}
|
||||
/>
|
||||
<picture>
|
||||
<source
|
||||
srcset={optimizeImageURL(thumbnail_url, 256)}
|
||||
media="(max-width: 256px)"
|
||||
/>
|
||||
<source
|
||||
srcset={optimizeImageURL(thumbnail_url, 512)}
|
||||
media="(max-width: 512px)"
|
||||
/>
|
||||
<source
|
||||
srcset={optimizeImageURL(thumbnail_url, 1024)}
|
||||
media="(max-width: 1024px)"
|
||||
/>
|
||||
<img
|
||||
src={optimizeImageURL(thumbnail_url, -1)}
|
||||
class="object-cover w-full sm:max-w-96 h-48 sm:h-72 bg-slate-200 dark:bg-zinc-800"
|
||||
width={600}
|
||||
height={400}
|
||||
alt={embed_title}
|
||||
class:blur-3xl={nsfw}
|
||||
/>
|
||||
</picture>
|
||||
</a>
|
||||
{/if}
|
||||
</Material>
|
||||
@@ -92,7 +109,7 @@
|
||||
<a href={url} target="_blank">
|
||||
<img
|
||||
src={optimizeImageURL(thumbnail_url, 256)}
|
||||
class="rounded-md max-w-[300px] w-full h-auto aspect-video object-cover bg-slate-200 dark:bg-zinc-800"
|
||||
class="rounded-md max-w-72 w-full h-auto aspect-video object-cover bg-slate-200 dark:bg-zinc-800"
|
||||
width={600}
|
||||
height={400}
|
||||
alt={embed_title ?? 'Embed prevented alt text'}
|
||||
|
||||
@@ -15,18 +15,7 @@
|
||||
<script lang="ts">
|
||||
import FormattedNumber from '$lib/components/util/FormattedNumber.svelte'
|
||||
import type { Post } from 'lemmy-js-client'
|
||||
import {
|
||||
ArrowDown,
|
||||
ArrowDownCircle,
|
||||
ArrowUp,
|
||||
ArrowUpCircle,
|
||||
ChevronDown,
|
||||
ChevronUp,
|
||||
HandThumbDown,
|
||||
HandThumbUp,
|
||||
Icon,
|
||||
Key,
|
||||
} from 'svelte-hero-icons'
|
||||
import { ChevronDown, ChevronUp, Icon } from 'svelte-hero-icons'
|
||||
import { profile } from '$lib/auth.js'
|
||||
import { vote as voteItem } from '$lib/lemmy/contentview.js'
|
||||
import { Button, Popover, buttonColor, toast } from 'mono-svelte'
|
||||
@@ -63,12 +52,13 @@
|
||||
<div
|
||||
class="{buttonColor.ghost} rounded-full h-full font-medium flex items-center *:p-2
|
||||
hover:bg-white hover:dark:bg-zinc-900 overflow-hidden transition-colors flex-shrink-0
|
||||
{vote != 0 ? '' : '!text-inherit'} !text-inherit
|
||||
{loading ? 'animate-pulse opacity-75 pointer-events-none' : ''}"
|
||||
>
|
||||
<button
|
||||
on:click={() => castVote(vote == 1 ? 0 : 1)}
|
||||
class="flex items-center gap-1 {buttonColor.ghost} transition-colors border-0
|
||||
{vote == 1 ? shouldShowVoteColor(vote, 'upvotes') : ''}"
|
||||
class="flex items-center gap-0.5 {buttonColor.ghost} transition-colors border-0
|
||||
{vote == 1 ? shouldShowVoteColor(vote, 'upvotes') : '!text-inherit'}"
|
||||
>
|
||||
<Icon src={ChevronUp} size="20" micro />
|
||||
<span class="grid text-sm">
|
||||
@@ -89,8 +79,8 @@
|
||||
></div>
|
||||
<button
|
||||
on:click={() => castVote(vote == -1 ? 0 : -1)}
|
||||
class="flex items-center flex-row-reverse gap-1 {buttonColor.ghost} transition-colors border-0
|
||||
{vote == -1 ? shouldShowVoteColor(vote, 'downvotes') : ''}"
|
||||
class="flex items-center flex-row-reverse gap-0.5 {buttonColor.ghost} transition-colors border-0
|
||||
{vote == -1 ? shouldShowVoteColor(vote, 'downvotes') : '!text-inherit'}"
|
||||
>
|
||||
<Icon src={ChevronDown} size="20" micro />
|
||||
<span class="grid text-sm">
|
||||
|
||||
@@ -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": {
|
||||
|
||||
@@ -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<PostFeedID, PostFeed>, id: PostFeedID) {
|
||||
|
||||
+13
-10
@@ -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) =>
|
||||
|
||||
@@ -244,10 +244,12 @@
|
||||
{$t('common.debug')}
|
||||
</MenuButton>
|
||||
{/if}
|
||||
<MenuButton on:click={() => action(profile)} color="danger-subtle">
|
||||
<Icon slot="prefix" src={ArrowRightOnRectangle} size="16" mini />
|
||||
{$t('account.logout')}
|
||||
</MenuButton>
|
||||
{#if !LINKED_INSTANCE_URL || profile.user}
|
||||
<MenuButton on:click={() => action(profile)} color="danger-subtle">
|
||||
<Icon slot="prefix" src={ArrowRightOnRectangle} size="16" mini />
|
||||
{$t('account.logout')}
|
||||
</MenuButton>
|
||||
{/if}
|
||||
</Menu>
|
||||
</div>
|
||||
{/each}
|
||||
|
||||
@@ -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 @@
|
||||
</script>
|
||||
|
||||
<div class="flex flex-col gap-4 h-full">
|
||||
<MultiSelect
|
||||
headless
|
||||
options={[`${communityUrl}/settings`, `${communityUrl}/settings/team`]}
|
||||
optionNames={['Settings', 'Team']}
|
||||
selected={$page.url.pathname}
|
||||
on:select={(e) => {
|
||||
goto(e.detail)
|
||||
}}
|
||||
/>
|
||||
<div
|
||||
class="sticky mx-auto z-50 max-w-full min-w-0 flex items-center gap-2"
|
||||
style="top: max(1.5rem, {$contentPadding.top}px);"
|
||||
>
|
||||
<Tabs
|
||||
routes={[
|
||||
{
|
||||
href: `${communityUrl}/settings`,
|
||||
name: $t('routes.community.settings.settings'),
|
||||
},
|
||||
{
|
||||
href: `${communityUrl}/team`,
|
||||
name: $t('routes.community.settings.team'),
|
||||
},
|
||||
]}
|
||||
></Tabs>
|
||||
</div>
|
||||
<slot />
|
||||
</div>
|
||||
@@ -2,6 +2,4 @@
|
||||
import CommunityForm from '$lib/components/lemmy/community/CommunityForm.svelte'
|
||||
</script>
|
||||
|
||||
<div class=" max-w-2xl mx-auto">
|
||||
<CommunityForm />
|
||||
</div>
|
||||
<CommunityForm />
|
||||
@@ -143,10 +143,12 @@
|
||||
<Icon src={QuestionMarkCircle} mini size="16" />
|
||||
{$t('form.forgotpassword')}
|
||||
</Button>
|
||||
<Button color="tertiary" href="/login/guest">
|
||||
<Icon src={UserCircle} mini size="16" />
|
||||
{$t('account.guest')}
|
||||
</Button>
|
||||
{#if !LINKED_INSTANCE_URL}
|
||||
<Button color="tertiary" href="/login/guest">
|
||||
<Icon src={UserCircle} mini size="16" />
|
||||
{$t('account.guest')}
|
||||
</Button>
|
||||
{/if}
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
Reference in new issue
Block a user