Skip to content

Commit 66bbd4c

Browse files
committed
fix(launcher): Prevent two updates from being scheduled at the same time
1 parent 890cc89 commit 66bbd4c

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/launcher.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export class Launcher extends search.Search {
2828
options_array: Array<SearchOption> = new Array()
2929
windows: arena.Arena<ShellWindow> = new arena.Arena()
3030
service: null | service.LauncherService = null
31+
append_id: null | number = null
3132

3233
constructor(ext: Ext) {
3334
super()
@@ -103,7 +104,12 @@ export class Launcher extends search.Search {
103104
this.close()
104105
} else if ("Update" in response) {
105106
this.clear()
106-
GLib.idle_add(GLib.PRIORITY_DEFAULT, () => {
107+
if (this.append_id !== null) {
108+
GLib.source_remove(this.append_id)
109+
this.append_id = null
110+
}
111+
112+
this.append_id = GLib.idle_add(GLib.PRIORITY_DEFAULT, () => {
107113
const item = response.Update.shift()
108114
if (item) {
109115
try {
@@ -131,7 +137,12 @@ export class Launcher extends search.Search {
131137
}
132138
}
133139

134-
return response.Update.length !== 0
140+
if (response.Update.length === 0) {
141+
this.append_id = null
142+
return false
143+
}
144+
145+
return true
135146
})
136147
} else if ("Fill" in response) {
137148
this.set_text(response.Fill)

0 commit comments

Comments
 (0)