cleanup: switch to $state for themes

This commit is contained in:
James Xylight committed 2025-02-10 17:34:40 -08:00
1 parent a5ba6d66f6
commit 80df5c5409
19 files changed
+169 -349

No files matched your search

-3
View File
@@ -1,6 +1,3 @@
import { publishedToDate } from '$lib/components/util/date.js'
import { getClient } from '$lib/lemmy.svelte.js'
import type { Result } from '$lib/lemmy/item.js'
import type {
Comment,
CommentReplyView,
+2 -7
View File
@@ -104,17 +104,12 @@ function resumableStore(limit: number = 10) {
export let resumables = resumableStore()
export function addFavorite(item: Community, add: boolean = true) {
const pd = get(profileData)
const p = pd.profiles.find((p) => p.id == profile.data?.id)
if (!p) return
let favs = p.favorites ?? []
let favs = profile.data.favorites ?? []
if (favs.map((fav) => fav.id).includes(item.id)) if (add) return
if (!add) {
favs.splice(favs.map((c) => c.id).indexOf(item.id), 1)
} else {
favs.unshift(item)
}
p.favorites = favs
profileData.update(() => pd)
profile.data.favorites = favs
}
+6 -10
View File
@@ -22,23 +22,19 @@ export const addSubscription = (
community: Community,
subscribe: boolean = true,
) => {
const p = profile
if (!p.user) return
const index = p.user.follows.map((f) => f.community.id).indexOf(community.id)
const index = profile.data.user?.follows
.map((f) => f.community.id)
.indexOf(community.id)
if (subscribe && index == -1) {
p.user.follows.push({
profile.data.user?.follows.push({
// @ts-ignore
follower: p.user.follows[0]?.follower,
community: community,
})
} else {
p.user.follows.splice(index, 1)
profile.data.user?.follows.splice(index ?? 0, 1)
}
profile.data.set(p)
}
export const addAdmin = async (handle: string, added: boolean, jwt: string) =>
@@ -56,4 +52,4 @@ export const addAdmin = async (handle: string, added: boolean, jwt: string) =>
})
export const hasFavorite = (profile: Profile, id: number): boolean =>
profile.data?.favorites?.map((i) => i.id).includes(id) ?? false
profile.favorites?.map((i) => i.id).includes(id) ?? false