1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2025-12-11 07:52:50 -05:00

modules cleanup and qmlfmt everywhere

- throw in 24H clock fix and app drawer fix too
This commit is contained in:
bbedward
2025-09-03 23:26:07 -04:00
parent 178ccd3634
commit 21867c842f
55 changed files with 2720 additions and 3236 deletions

View File

@@ -17,43 +17,38 @@ Singleton {
if (applications.length === 0)
return []
const queryLower = query.toLowerCase()
const queryLower = query.toLowerCase().trim()
const scoredApps = []
for (const app of applications) {
const name = (app.name || "").toLowerCase()
const genericName = (app.genericName || "").toLowerCase()
const comment = (app.comment || "").toLowerCase()
const keywords = app.keywords ? app.keywords.map(k => k.toLowerCase()) : []
let score = 0
let matched = false
const nameWords = name.trim().split(/\s+/).filter(w => w.length > 0)
const containsAsWord = nameWords.includes(queryLower)
const startsWithAsWord = nameWords.some(word => word.startsWith(queryLower))
if (name === queryLower) {
score = 10000
matched = true
}
else if (containsAsWord) {
} else if (containsAsWord) {
score = 9500 + (100 - Math.min(name.length, 100))
matched = true
}
else if (name.startsWith(queryLower)) {
} else if (name.startsWith(queryLower)) {
score = 9000 + (100 - Math.min(name.length, 100))
matched = true
}
else if (startsWithAsWord) {
} else if (startsWithAsWord) {
score = 8500 + (100 - Math.min(name.length, 100))
matched = true
}
else if (name.includes(queryLower)) {
} else if (name.includes(queryLower)) {
score = 8000 + (100 - Math.min(name.length, 100))
matched = true
}
else if (keywords.length > 0) {
} else if (keywords.length > 0) {
for (const keyword of keywords) {
if (keyword === queryLower) {
score = 6000
@@ -73,29 +68,30 @@ Singleton {
if (!matched && genericName.includes(queryLower)) {
score = 4000
matched = true
}
else if (!matched && comment.includes(queryLower)) {
} else if (!matched && comment.includes(queryLower)) {
score = 3000
matched = true
}
else if (!matched) {
} else if (!matched) {
const nameFinder = new Fzf.Finder([app], {
"selector": a => a.name || "",
"casing": "case-insensitive",
"fuzzy": "v2"
})
"selector": a => a.name || "",
"casing": "case-insensitive",
"fuzzy": "v2"
})
const fuzzyResults = nameFinder.find(query)
if (fuzzyResults.length > 0 && fuzzyResults[0].score > 0) {
score = Math.min(fuzzyResults[0].score, 2000)
matched = true
}
}
if (matched) {
scoredApps.push({ app, score })
scoredApps.push({
"app": app,
"score": score
})
}
}
scoredApps.sort((a, b) => b.score - a.score)
return scoredApps.slice(0, 50).map(item => item.app)
}