Skip to content

Commit 4c21ecd

Browse files
Bugfix: don't remove jobs if name doesn't exist
1 parent a649eb0 commit 4c21ecd

File tree

1 file changed

+10
-6
lines changed
  • plugins/jobs-management/src/JobsListWidget

1 file changed

+10
-6
lines changed

plugins/jobs-management/src/JobsListWidget/model.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,11 @@ export function stateModelFactory(_pluginManager: PluginManager) {
6262
*/
6363
removeJob(jobName: string) {
6464
const indx = self.jobs.findIndex(job => job.name === jobName)
65-
const removed = self.jobs[indx]
66-
self.jobs.splice(indx, 1)
67-
return removed
65+
if (indx === -1) {
66+
return undefined
67+
}
68+
const removed = self.jobs.splice(indx, 1)
69+
return removed[0]
6870
},
6971
/**
7072
* #action
@@ -110,9 +112,11 @@ export function stateModelFactory(_pluginManager: PluginManager) {
110112
*/
111113
removeQueuedJob(jobName: string) {
112114
const indx = self.queued.findIndex(job => job.name === jobName)
113-
const removed = self.queued[indx]
114-
self.queued.splice(indx, 1)
115-
return removed
115+
if (indx === -1) {
116+
return undefined
117+
}
118+
const removed = self.queued.splice(indx, 1)
119+
return removed[0]
116120
},
117121
/**
118122
* #action

0 commit comments

Comments
 (0)