feat: add community resumables
This commit is contained in:
1 parent
98a597c0d3
commit
47b8b21ede
4 files changed
+33
-14
No files matched your search
@@ -303,7 +303,7 @@
|
||||
<CommandItem
|
||||
{action}
|
||||
class="{globalIndex == selectedIndex
|
||||
? 'bg-slate-200 dark:bg-zinc-800 text-inherit'
|
||||
? '!bg-slate-100 dark:!bg-zinc-800 text-inherit'
|
||||
: 'text-slate-600 dark:text-zinc-400'} block"
|
||||
/>
|
||||
</li>
|
||||
|
||||
+18
-2
@@ -72,7 +72,7 @@ export const isPrivateMessageReport = (
|
||||
|
||||
export interface ResumableItem {
|
||||
url: string
|
||||
id: number
|
||||
id?: number
|
||||
name: string
|
||||
avatar?: string
|
||||
type: 'community' | 'post'
|
||||
@@ -82,7 +82,23 @@ export interface ResumableItem {
|
||||
}
|
||||
}
|
||||
|
||||
export let resumables = writable<ResumableItem[]>([])
|
||||
function resumableStore(limit: number = 10) {
|
||||
const { subscribe, set, update } = writable<ResumableItem[]>([])
|
||||
|
||||
return {
|
||||
subscribe, set, update,
|
||||
add: (item: ResumableItem) => {
|
||||
update(resumables => {
|
||||
if (resumables.find(i => JSON.stringify(i) == JSON.stringify(item))) return resumables
|
||||
resumables.unshift(item)
|
||||
if (resumables.length > limit) resumables.pop()
|
||||
return resumables
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export let resumables = resumableStore()
|
||||
|
||||
export function addFavorite(item: Community, add: boolean = true) {
|
||||
const pd = get(profileData)
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
import EntityHeader from '$lib/components/ui/EntityHeader.svelte'
|
||||
import CommunityLink from '$lib/components/lemmy/community/CommunityLink.svelte'
|
||||
import Subscribe from '../../communities/Subscribe.svelte'
|
||||
import { resumables } from '$lib/lemmy/item'
|
||||
|
||||
export let data
|
||||
|
||||
@@ -45,6 +46,13 @@
|
||||
'lastSeenCommunity',
|
||||
data.community.community_view.community,
|
||||
)
|
||||
|
||||
resumables.add({
|
||||
name: community.community.title,
|
||||
type: 'community',
|
||||
url: $page.url.toString(),
|
||||
avatar: community.community.icon,
|
||||
})
|
||||
})
|
||||
|
||||
onDestroy(() => {
|
||||
|
||||
@@ -64,17 +64,12 @@
|
||||
})
|
||||
}
|
||||
|
||||
if (!$resumables.find((r) => r.url == $page.url.toString()))
|
||||
$resumables = [
|
||||
{
|
||||
id: Math.floor(Math.random() * 1000000),
|
||||
name: post.post_view.post.name,
|
||||
type: 'post',
|
||||
url: $page.url.toString(),
|
||||
avatar: post.post_view.post.thumbnail_url,
|
||||
},
|
||||
...$resumables,
|
||||
]
|
||||
resumables.add({
|
||||
name: post.post_view.post.name,
|
||||
type: 'post',
|
||||
url: $page.url.toString(),
|
||||
avatar: post.post_view.post.thumbnail_url,
|
||||
})
|
||||
})
|
||||
|
||||
afterNavigate(async () => {
|
||||
|
||||
Reference in new issue
Block a user