Merge pull request #364 from Xyphyn/command-palette
feat: add a command palette
This commit is contained in:
14 files changed
+837
-6
No files matched your search
+20
-2
@@ -12,7 +12,7 @@ import type {
|
||||
PrivateMessageView,
|
||||
Community,
|
||||
} from 'lemmy-js-client'
|
||||
import { get } from 'svelte/store'
|
||||
import { get, writable } from 'svelte/store'
|
||||
|
||||
export type Result =
|
||||
| PostView
|
||||
@@ -72,7 +72,7 @@ export const isPrivateMessageReport = (
|
||||
|
||||
export interface ResumableItem {
|
||||
url: string
|
||||
id: number
|
||||
id?: number
|
||||
name: string
|
||||
avatar?: string
|
||||
type: 'community' | 'post'
|
||||
@@ -82,6 +82,24 @@ export interface 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)
|
||||
const p = pd.profiles.find((p) => p.id == get(profile)?.id)
|
||||
|
||||
Reference in new issue
Block a user