fix: subscribe error
This commit is contained in:
1 parent
289ea0d34e
commit
a14b5786ee
2 files changed
+5
-22
No files matched your search
@@ -96,10 +96,4 @@ export function addFavorite(item: Community, add: boolean = true) {
|
|||||||
}
|
}
|
||||||
p.favorites = favs
|
p.favorites = favs
|
||||||
profileData.update(() => pd)
|
profileData.update(() => pd)
|
||||||
profile.update((p) => ({
|
|
||||||
...p,
|
|
||||||
favorites: favs,
|
|
||||||
id: p!.id,
|
|
||||||
instance: p!.instance,
|
|
||||||
}))
|
|
||||||
}
|
}
|
||||||
+5
-16
@@ -1,4 +1,4 @@
|
|||||||
import { profile, type Profile } from '$lib/auth.js'
|
import { profile, profileData, type Profile } from '$lib/auth.js'
|
||||||
import { getClient } from '$lib/lemmy.js'
|
import { getClient } from '$lib/lemmy.js'
|
||||||
import { trycatch } from '$lib/util.js'
|
import { trycatch } from '$lib/util.js'
|
||||||
import type { Community, MyUserInfo, PersonView } from 'lemmy-js-client'
|
import type { Community, MyUserInfo, PersonView } from 'lemmy-js-client'
|
||||||
@@ -22,30 +22,19 @@ export const addSubscription = (
|
|||||||
community: Community,
|
community: Community,
|
||||||
subscribe: boolean = true
|
subscribe: boolean = true
|
||||||
) => {
|
) => {
|
||||||
const p = get(profile)
|
const pd = get(profileData)
|
||||||
|
const p = pd.profiles.find((p) => p.id == pd.profile)
|
||||||
|
|
||||||
if (!p?.user) return
|
if (!p?.user) return
|
||||||
|
|
||||||
if (subscribe) {
|
if (subscribe) {
|
||||||
profile.set({
|
profileData.set(pd)
|
||||||
...p,
|
|
||||||
user: {
|
|
||||||
...p.user,
|
|
||||||
follows: [
|
|
||||||
...p.user.follows,
|
|
||||||
{
|
|
||||||
community: community,
|
|
||||||
follower: p.user.local_user_view.person,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
})
|
|
||||||
} else {
|
} else {
|
||||||
p.user.follows.splice(
|
p.user.follows.splice(
|
||||||
p.user.follows.findIndex((i) => i.community.id == community.id),
|
p.user.follows.findIndex((i) => i.community.id == community.id),
|
||||||
1
|
1
|
||||||
)
|
)
|
||||||
profile.set(p)
|
profileData.set(pd)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user