feat: add community creation
This commit is contained in:
1 parent
98a5a2f6f2
commit
7e76b1684c
8 files changed
+210
-31
No files matched your search
+32
-1
@@ -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)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user