diff --git a/package.json b/package.json
index 2ed184ad..d15a8bd4 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "photon-lemmy",
- "version": "0.7.8",
+ "version": "0.8.0",
"private": true,
"scripts": {
"dev": "vite dev",
diff --git a/src/lib/components/input/FileInput.svelte b/src/lib/components/input/FileInput.svelte
index 613c25e3..3bc9fcdf 100644
--- a/src/lib/components/input/FileInput.svelte
+++ b/src/lib/components/input/FileInput.svelte
@@ -5,6 +5,7 @@
export let multiple = false
export let files: FileList | null | undefined = null
export let image = false
+ export let label: string | undefined = undefined
let previewURL = ''
let dragover = false
@@ -14,34 +15,39 @@
}
-{label}
+ {/if}
+ (files = event.dataTransfer?.files)}
- on:dragover|preventDefault={(event) => {
- if (event.dataTransfer) {
- event.dataTransfer.dropEffect = 'copy'
- dragover = true
- }
- }}
- on:dragleave|preventDefault={() => (dragover = false)}
->
- {#if image && files}
-
- {
- if (previewURL) URL.revokeObjectURL(previewURL)
- }}
- class="w-full max-w-sm h-full rounded-lg"
- />
- {:else}
-
- Attach a file
- {/if}
-
-
+ on:drop|preventDefault={(event) => (files = event.dataTransfer?.files)}
+ on:dragover|preventDefault={(event) => {
+ if (event.dataTransfer) {
+ event.dataTransfer.dropEffect = 'copy'
+ dragover = true
+ }
+ }}
+ on:dragleave|preventDefault={() => (dragover = false)}
+ >
+ {#if image && files}
+
+ {
+ if (previewURL) URL.revokeObjectURL(previewURL)
+ }}
+ class="w-full max-w-sm h-full rounded-lg"
+ />
+ {:else}
+
+ Attach a file
+ {/if}
+
+
+
diff --git a/src/lib/components/lemmy/community/CommunityCard.svelte b/src/lib/components/lemmy/community/CommunityCard.svelte
index d5cb1477..c26f4221 100644
--- a/src/lib/components/lemmy/community/CommunityCard.svelte
+++ b/src/lib/components/lemmy/community/CommunityCard.svelte
@@ -1,6 +1,7 @@
+
+
diff --git a/src/lib/components/lemmy/community/CommunityTitle.svelte b/src/lib/components/lemmy/community/CommunityTitle.svelte
new file mode 100644
index 00000000..2410c20f
--- /dev/null
+++ b/src/lib/components/lemmy/community/CommunityTitle.svelte
@@ -0,0 +1,16 @@
+
+
+
+
+
+
{community.title}
+
+ !{community.name}@{new URL(community.actor_id).hostname}
+
+
+
diff --git a/src/lib/components/markdown/MarkdownEditor.svelte b/src/lib/components/markdown/MarkdownEditor.svelte
index 8702c327..ebe21b22 100644
--- a/src/lib/components/markdown/MarkdownEditor.svelte
+++ b/src/lib/components/markdown/MarkdownEditor.svelte
@@ -116,7 +116,7 @@
{label}
{/if}
{#if previewing}
diff --git a/src/lib/components/ui/Navbar.svelte b/src/lib/components/ui/Navbar.svelte
index ab21efcd..f22db2d5 100644
--- a/src/lib/components/ui/Navbar.svelte
+++ b/src/lib/components/ui/Navbar.svelte
@@ -28,6 +28,7 @@
InformationCircle,
MagnifyingGlass,
Moon,
+ Newspaper,
PencilSquare,
Plus,
Sun,
@@ -153,6 +154,14 @@
Post
+
+
+ Community
+
{#if !$profile?.jwt}
Log in to create content.
diff --git a/src/lib/lemmy/user.ts b/src/lib/lemmy/user.ts
index e1350cf5..fea26b47 100644
--- a/src/lib/lemmy/user.ts
+++ b/src/lib/lemmy/user.ts
@@ -1,6 +1,6 @@
import { profile } from '$lib/auth.js'
import { getClient } from '$lib/lemmy.js'
-import type { MyUserInfo, PersonView } from 'lemmy-js-client'
+import type { Community, MyUserInfo, PersonView } from 'lemmy-js-client'
import { get } from 'svelte/store'
export const blockUser = async (block: boolean, id: number) => {
@@ -17,3 +17,34 @@ export const blockUser = async (block: boolean, id: number) => {
export const isBlocked = (me: MyUserInfo, user: number) =>
me.person_blocks.map((b) => b.target.id).includes(user)
+
+export const addSubscription = (
+ community: Community,
+ subscribe: boolean = true
+) => {
+ const p = get(profile)
+
+ if (!p?.user) return
+
+ if (subscribe) {
+ profile.set({
+ ...p,
+ user: {
+ ...p.user,
+ follows: [
+ ...p.user.follows,
+ {
+ community: community,
+ follower: p.user.local_user_view.person,
+ },
+ ],
+ },
+ })
+ } else {
+ p.user.follows.splice(
+ p.user.follows.findIndex((i) => i.community.id == community.id),
+ 1
+ )
+ profile.set(p)
+ }
+}
diff --git a/src/routes/c/[name]/+layout.svelte b/src/routes/c/[name]/+layout.svelte
new file mode 100644
index 00000000..2b51e0da
--- /dev/null
+++ b/src/routes/c/[name]/+layout.svelte
@@ -0,0 +1,9 @@
+
+
+
+ {data.community.community_view.community.title}
+
+
+
diff --git a/src/routes/c/[name]/+page.ts b/src/routes/c/[name]/+layout.ts
similarity index 80%
rename from src/routes/c/[name]/+page.ts
rename to src/routes/c/[name]/+layout.ts
index 1aca1dc8..657eb25b 100644
--- a/src/routes/c/[name]/+page.ts
+++ b/src/routes/c/[name]/+layout.ts
@@ -21,11 +21,9 @@ export async function load(req: any) {
sort: sort,
auth: get(profile)?.jwt,
}),
- community: (
- await getClient(undefined, req.fetch).getCommunity({
- name: req.params.name,
- auth: get(profile)?.jwt,
- })
- ).community_view,
+ community: await getClient(undefined, req.fetch).getCommunity({
+ name: req.params.name,
+ auth: get(profile)?.jwt,
+ }),
}
}
diff --git a/src/routes/c/[name]/+page.svelte b/src/routes/c/[name]/+page.svelte
index 4eaaebeb..3957727a 100644
--- a/src/routes/c/[name]/+page.svelte
+++ b/src/routes/c/[name]/+page.svelte
@@ -25,10 +25,10 @@
onMount(() => {
setSessionStorage('lastSeenCommunity', {
- id: data.community.community.id,
+ id: data.community.community_view.community.id,
name: fullCommunityName(
- data.community.community.name,
- data.community.community.actor_id
+ data.community.community_view.community.name,
+ data.community.community_view.community.actor_id
),
})
})
@@ -36,11 +36,14 @@
{data.posts.posts[0]?.community.name}
-
- {#if data.community.community.description}
+
+ {#if data.community.community_view.community.description}
{/if}
@@ -49,7 +52,7 @@
About
-
+
@@ -58,14 +61,16 @@
-
{data.community.community.title}
+
+ {data.community.community_view.community.title}
+
- !{data.community.community.name}@{new URL(
- data.community.community.actor_id
+ !{data.community.community_view.community.name}@{new URL(
+ data.community.community_view.community.actor_id
).hostname}
@@ -85,6 +90,6 @@
/>
-
+
diff --git a/src/routes/c/[name]/settings/+layout.svelte b/src/routes/c/[name]/settings/+layout.svelte
new file mode 100644
index 00000000..1686dc7d
--- /dev/null
+++ b/src/routes/c/[name]/settings/+layout.svelte
@@ -0,0 +1,27 @@
+
+
+
+ {
+ goto(e.detail)
+ }}
+ />
+
+
diff --git a/src/routes/c/[name]/settings/+page.svelte b/src/routes/c/[name]/settings/+page.svelte
new file mode 100644
index 00000000..8b62049b
--- /dev/null
+++ b/src/routes/c/[name]/settings/+page.svelte
@@ -0,0 +1,27 @@
+
+
+
+
+
Settings
+
+ {''}
+
+
diff --git a/src/routes/c/[name]/settings/team/+page.svelte b/src/routes/c/[name]/settings/team/+page.svelte
new file mode 100644
index 00000000..dd383b6d
--- /dev/null
+++ b/src/routes/c/[name]/settings/team/+page.svelte
@@ -0,0 +1,141 @@
+
+
+Moderators
+ {
+ toast({
+ content: `Are you sure you want to remove ${e.detail.name} as a moderator?`,
+ action: () => removeMod(e.detail.id),
+ })
+ }}
+>
+ {#each data.community.moderators as moderator (moderator.moderator.id)}
+
+
+
+
+
+
+ {new URL(moderator.moderator.actor_id).hostname}
+
+
+
+ {#if moderator.moderator.id != $profile?.user?.local_user_view.person.id}
+
action(moderator.moderator)}>
+
+
+ {/if}
+
+ {/each}
+
+
+
+
+ Add moderator
+
+
diff --git a/src/routes/communities/+page.svelte b/src/routes/communities/+page.svelte
index b8fca01f..966885e8 100644
--- a/src/routes/communities/+page.svelte
+++ b/src/routes/communities/+page.svelte
@@ -15,6 +15,7 @@
import Button from '$lib/components/input/Button.svelte'
import Pageination from '$lib/components/ui/Pageination.svelte'
import { searchParam } from '$lib/util.js'
+ import { addSubscription } from '$lib/lemmy/user.js'
export let data
@@ -96,6 +97,11 @@
res.community_view.subscribed != 'NotSubscribed'
? 'Subscribed'
: 'NotSubscribed'
+
+ addSubscription(
+ community.community,
+ res.community_view.subscribed == 'Subscribed'
+ )
}
}}
color={community.subscribed == 'Subscribed'
diff --git a/src/routes/create/community/+page.svelte b/src/routes/create/community/+page.svelte
new file mode 100644
index 00000000..12f93ff3
--- /dev/null
+++ b/src/routes/create/community/+page.svelte
@@ -0,0 +1,7 @@
+
+
+
+
+