Skip to content

Commit e123d78

Browse files
committed
fix(launcher): Resolve TypeScript errors
1 parent f17968e commit e123d78

File tree

2 files changed

+22
-16
lines changed

2 files changed

+22
-16
lines changed

src/dialog_launcher.ts

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ export class Launcher extends search.Search {
6969
plugin.config.icon,
7070
icon,
7171
this.icon_size(),
72-
{ plugin, id: selection.id }
72+
{ plugin, id: selection.id },
73+
null,
74+
null
7375
))
7476
}
7577
}
@@ -97,14 +99,16 @@ export class Launcher extends search.Search {
9799
const name = app.name()
98100
const keywords = app.keywords()
99101
const exec = app.exec()
100-
const app_items = keywords !== null ?
101-
name.split().concat(keywords).concat(exec) : name.split().concat(exec)
102-
102+
103+
let app_items = name.split(' ')
104+
if (keywords !== null) app_items = app_items.concat(keywords)
105+
if (exec !== null) app_items = app_items.concat(exec)
106+
103107
for (const item of app_items) {
104108
const item_match = item.toLowerCase()
105109
if ( item_match.startsWith(pattern)
106110
|| item_match.includes(pattern)
107-
|| levenshtein.compare(item_match, pattern) < 3 {
111+
|| levenshtein.compare(item_match, pattern) < 3) {
108112
const generic = app.generic_name();
109113
const button = new launch.SearchOption(
110114
name,
@@ -136,14 +140,14 @@ export class Launcher extends search.Search {
136140
// Sort by metadata (name, description, keywords)
137141
if (!a_name.startsWith(pattern)) {
138142
a_weight = 1
139-
if (!a_name.includes(pattern) {
143+
if (!a_name.includes(pattern)) {
140144
a_weight = levenshtein.compare(a_name, pattern)
141145
if (a.description) {
142146
a_weight = Math.min(a_weight, levenshtein.compare(pattern, a.description.toLowerCase()))
143147
}
144148
if (a.keywords) {
145149
for (const keyword of a.keywords) {
146-
if keyword.toLowerCase().startsWith(pattern) || keyword.toLowerCase().includes(pattern) {
150+
if (keyword.toLowerCase().startsWith(pattern) || keyword.toLowerCase().includes(pattern)) {
147151
a_weight = 1
148152
} else {
149153
a_weight = Math.min(a_weight, (levenshtein.compare(pattern, keyword.toLowerCase()) + 1))
@@ -154,13 +158,13 @@ export class Launcher extends search.Search {
154158
}
155159
// Sort by command (exec)
156160
if (a_exec.includes(pattern)) {
157-
if (a_exec.startsWith(pattern) {
161+
if (a_exec.startsWith(pattern)) {
158162
a_weight = Math.min(a_weight, 2)
159163
} else {
160164
a_weight = Math.min(a_weight, levenshtein.compare(pattern, a_exec))
161165
}
162166
}
163-
167+
164168

165169
// Sort by metadata (name, description, keywords)
166170
if (!b_name.startsWith(pattern)) {
@@ -172,7 +176,7 @@ export class Launcher extends search.Search {
172176
}
173177
if (b.keywords) {
174178
for (const keyword of b.keywords) {
175-
if keyword.toLowerCase().startsWith(pattern) || keyword.toLowerCase().includes(pattern) {
179+
if (keyword.toLowerCase().startsWith(pattern) || keyword.toLowerCase().includes(pattern)) {
176180
b_weight = 1
177181
} else {
178182
b_weight = Math.min(b_weight, (levenshtein.compare(pattern, keyword.toLowerCase()) + 1))
@@ -183,7 +187,7 @@ export class Launcher extends search.Search {
183187
}
184188
// Sort by command (exec)
185189
if (b_exec.includes(pattern)) {
186-
if (b_exec.startsWith(pattern) {
190+
if (b_exec.startsWith(pattern)) {
187191
b_weight = Math.min(b_weight, 2)
188192
} else {
189193
b_weight = Math.min(b_weight, levenshtein.compare(pattern, b_exec))
@@ -321,7 +325,7 @@ export class Launcher extends search.Search {
321325
load_desktop_files() {
322326
lib.bench("load_desktop_files", () => {
323327
this.desktop_apps.splice(0);
324-
for (const _path of DATA_DIRS_USER.split().concat(DATA_DIRS_SYSTEM)) {
328+
for (const _path of [DATA_DIRS_USER].concat(DATA_DIRS_SYSTEM)) {
325329
const path = _path.replace(/\/$/, '') + "/applications";
326330
for (const result of app_info.load_desktop_entries(path)) {
327331
if (result.kind == OK) {
@@ -397,6 +401,8 @@ function window_selection(ext: Ext, window: ShellWindow, icon_size: number): lau
397401
widget: window.icon(ext, icon_size)
398402
},
399403
icon_size,
400-
{ window }
404+
{ window },
405+
null,
406+
null
401407
)
402408
}

src/launcher_service.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,14 +179,14 @@ export class SearchOption {
179179
description: null | string
180180
id: Identity
181181
exec: null | string
182-
keywords: null | array
182+
keywords: null | Array<string>
183183

184184
widget: St.Button
185185

186186
shortcut: St.Widget = new St.Label({ text: "", y_align: Clutter.ActorAlign.CENTER, style: "padding-left: 6px;padding-right: 6px" })
187187

188-
constructor(title: string, description: null | string, category_icon: string, icon: null | IconSrc, icon_size: number, id: Identity,
189-
exec: null | string, keywords: null | array) {
188+
constructor(title: string, description: null | string, category_icon: string, icon: null | IconSrc, icon_size: number, id: Identity,
189+
exec: null | string, keywords: null | Array<string>) {
190190
this.title = title
191191
this.description = description
192192
this.id = id

0 commit comments

Comments
 (0)