Skip to content

Commit a28b15c

Browse files
committed
Up
1 parent 6782a7f commit a28b15c

File tree

1 file changed

+31
-4
lines changed

1 file changed

+31
-4
lines changed

druid/editor_scripts/core/asset_store_internal.lua

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,19 @@ function M.download_json(json_url)
2020
end
2121

2222

23+
local function is_unlisted_visible(item, lower_query)
24+
if not item.unlisted then
25+
return true
26+
end
27+
28+
if not lower_query or lower_query == "" or not item.id then
29+
return false
30+
end
31+
32+
return string.lower(item.id) == lower_query
33+
end
34+
35+
2336
---Filter items based on search query
2437
---Filter items based on search query
2538
---@param items table - List of widget items
@@ -36,7 +49,9 @@ function M.filter_items(items, query)
3649
for _, item in ipairs(items) do
3750
-- Search in title, author, description
3851
local matches = false
39-
if item.title and string.find(string.lower(item.title), lower_query, 1, true) then
52+
if item.id and string.find(string.lower(item.id), lower_query, 1, true) then
53+
matches = true
54+
elseif item.title and string.find(string.lower(item.title), lower_query, 1, true) then
4055
matches = true
4156
elseif item.author and string.find(string.lower(item.author), lower_query, 1, true) then
4257
matches = true
@@ -81,7 +96,7 @@ function M.extract_authors(items)
8196
local author_set = {}
8297

8398
for _, item in ipairs(items) do
84-
if item.author and not author_set[item.author] then
99+
if not item.unlisted and item.author and not author_set[item.author] then
85100
author_set[item.author] = true
86101
table.insert(authors, item.author)
87102
end
@@ -100,7 +115,7 @@ function M.extract_tags(items)
100115
local tag_set = {}
101116

102117
for _, item in ipairs(items) do
103-
if item.tags then
118+
if not item.unlisted and item.tags then
104119
for _, tag in ipairs(item.tags) do
105120
if not tag_set[tag] then
106121
tag_set[tag] = true
@@ -124,7 +139,19 @@ end
124139
---@param install_folder string - Installation folder to check installed status
125140
---@return table - Filtered items
126141
function M.filter_items_by_filters(items, search_query, filter_type, filter_author, filter_tag, install_folder)
127-
local filtered = items
142+
local lower_query = nil
143+
if search_query and search_query ~= "" then
144+
lower_query = string.lower(search_query)
145+
end
146+
147+
local visible_items = {}
148+
for _, item in ipairs(items) do
149+
if is_unlisted_visible(item, lower_query) then
150+
table.insert(visible_items, item)
151+
end
152+
end
153+
154+
local filtered = visible_items
128155

129156
-- Filter by search query
130157
if search_query and search_query ~= "" then

0 commit comments

Comments
 (0)