From fd09c33ca1e8703051b13f0210fd062ce88c0130 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Dzieko=C5=84ski?= Date: Sat, 16 Dec 2023 19:42:05 +0100 Subject: [PATCH] feat: Add reusable convertJobToFilenames() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michał Dziekoński --- src/store/server/jobQueue/actions.ts | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) 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', {