(filterState, isInitial = false)
| 175 | } |
| 176 | |
| 177 | async function loadFilteredPlugins(filterState, isInitial = false) { |
| 178 | if (isFilterLoading || !filterHasMore || !filterState) return; |
| 179 | |
| 180 | try { |
| 181 | isFilterLoading = true; |
| 182 | |
| 183 | const { items, hasMore } = await getFilteredPlugins(filterState); |
| 184 | |
| 185 | if (currentFilter !== filterState) { |
| 186 | return; |
| 187 | } |
| 188 | |
| 189 | installedPlugins = await listInstalledPlugins(); |
| 190 | const pluginElements = items.map(ListItem); |
| 191 | if (pluginElements.length) { |
| 192 | $searchResult.append(...pluginElements); |
| 193 | } else if (isInitial) { |
| 194 | $searchResult.append( |
| 195 | <span className="error empty"> |
| 196 | {strings["no plugins found"] || strings.empty || "No plugins found"} |
| 197 | </span>, |
| 198 | ); |
| 199 | } |
| 200 | |
| 201 | filterHasMore = hasMore; |
| 202 | if (!filterHasMore) { |
| 203 | $searchResult.onscroll = null; |
| 204 | } |
| 205 | |
| 206 | updateHeight($searchResult); |
| 207 | } catch (error) { |
| 208 | window.log("error", "Error loading filtered plugins:"); |
| 209 | window.log("error", error); |
| 210 | } finally { |
| 211 | isFilterLoading = false; |
| 212 | } |
| 213 | } |
| 214 | |
| 215 | async function searchPlugin() { |
| 216 | clearTimeout(searchTimeout); |
no test coverage detected