@@ -4,17 +4,19 @@ import Fuse from 'fuse.js'
4
4
import { computed , ref } from ' vue'
5
5
// @ts-expect-error missing types
6
6
import { RecycleScroller } from ' vue-virtual-scroller'
7
- import { useModulesList } from ' ~/composables/state-modules'
7
+ import { useInstalledModules , useModulesList } from ' ~/composables/state-modules'
8
8
9
9
type SortingFunction <T > = (a : T , b : T ) => number
10
10
11
11
const emit = defineEmits ([' close' ])
12
12
13
13
const collection = useModulesList ()
14
+ const installedModules = useInstalledModules ()
14
15
15
16
const sortingOptions = [' downloads' , ' stars' , ' updated' , ' created' ] as const
16
17
const ascendingOrder = ref (false )
17
18
const selectedSortingOption = ref <typeof sortingOptions [number ]>(sortingOptions [0 ])
19
+ const excludeInstalled = ref (true )
18
20
19
21
const sortingFactors: Record <typeof sortingOptions [number ], SortingFunction <ModuleStaticInfo >> = {
20
22
downloads : (a , b ) => a .stats .downloads - b .stats .downloads ,
@@ -45,9 +47,13 @@ const fuse = computed(() => new Fuse(collection.value || [], {
45
47
}))
46
48
47
49
const items = computed (() => {
50
+ let filteredItems = sortedItems .value
51
+ if (excludeInstalled .value ) {
52
+ filteredItems = (filteredItems || []).filter (item => ! installedModules .value .some (installed => installed .name === item .name ))
53
+ }
48
54
if (! search .value )
49
- return sortedItems . value
50
- return fuse .value .search (search .value ).map (r => r .item )
55
+ return filteredItems
56
+ return fuse .value .search (search .value ).map (r => r .item ). filter ( item => filteredItems ?. includes ( item ))
51
57
})
52
58
</script >
53
59
@@ -59,7 +65,7 @@ const items = computed(() => {
59
65
icon =" i-carbon-intent-request-create"
60
66
text =" Install Module"
61
67
/>
62
- <NNavbar v-model:search =" search" no-padding px-6 pb-5 pt-2 >
68
+ <NNavbar v-model:search =" search" no-padding px-6 pb-3 pt-2 >
63
69
<template #actions >
64
70
<NDropdown direction =" end" n =" sm primary" >
65
71
<template #trigger =" { click } " >
@@ -96,6 +102,15 @@ const items = computed(() => {
96
102
</div >
97
103
</NDropdown >
98
104
</template >
105
+ <div flex =" ~ items-center gap-2" >
106
+ <NCheckbox v-model =" excludeInstalled" n =" primary md" >
107
+ <span op75 >Exclude installed modules</span >
108
+ </NCheckbox >
109
+ <div flex =" ~ gap1" text-sm op50 >
110
+ <span v-if =" search || excludeInstalled" >{{ items?.length }} matched · </span >
111
+ <span >{{ collection?.length }} modules in total</span >
112
+ </div >
113
+ </div >
99
114
</NNavbar >
100
115
101
116
<div flex-auto of-auto flex =" ~ col gap-2" pl6 pr4 >
0 commit comments