diff --git a/src/store/server/jobQueue/actions.ts b/src/store/server/jobQueue/actions.ts index 7f6f594ae..9c8630b39 100644 --- a/src/store/server/jobQueue/actions.ts +++ b/src/store/server/jobQueue/actions.ts @@ -3,6 +3,17 @@ import { ActionTree } from 'vuex' import { RootState } from '@/store/types' import { ServerJobQueueState, ServerJobQueueStateJob } from '@/store/server/jobQueue/types' +const convertJobToFilenames = (job: ServerJobQueueStateJob) => { + const filenames: string[] = [] + + const count = (job.combinedIds?.length ?? 0) + 1 + for (let i = 0; i < count; i++) { + filenames.push(job.filename) + } + + return filenames +} + export const actions: ActionTree = { reset({ commit }) { commit('reset') @@ -41,10 +52,7 @@ export const actions: ActionTree = { return } - const count = (job.combinedIds?.length ?? 0) + 1 - for (let i = 0; i < count; i++) { - filenames.push(job.filename) - } + filenames.push(...convertJobToFilenames(job)) }) Vue.$socket.emit('server.job_queue.post_job', { @@ -69,10 +77,7 @@ export const actions: ActionTree = { jobs.splice(payload.positionIndex, 0, jobToMove) jobs.forEach((job) => { - const count = (job.combinedIds?.length ?? 0) + 1 - for (let i = 0; i < count; i++) { - filenames.push(job.filename) - } + filenames.push(...convertJobToFilenames(job)) }) Vue.$socket.emit('server.job_queue.post_job', {