woodpecker/web/src/compositions/useEvents.ts
Harikesh00 36e42914fa
Renamed procs/jobs to steps in code (#1331)
Renamed `procs` to `steps` in code for the issue #1288

Co-authored-by: Harikesh Prajapati <harikesh.prajapati@druva.com>
Co-authored-by: qwerty287 <ndev@web.de>
Co-authored-by: qwerty287 <80460567+qwerty287@users.noreply.github.com>
Co-authored-by: 6543 <6543@obermui.de>
2022-10-28 17:38:53 +02:00

43 lines
1,019 B
TypeScript

import PipelineStore from '~/store/pipelines';
import RepoStore from '~/store/repos';
import { repoSlug } from '~/utils/helpers';
import useApiClient from './useApiClient';
const apiClient = useApiClient();
let initialized = false;
export default () => {
if (initialized) {
return;
}
const repoStore = RepoStore();
const pipelineStore = PipelineStore();
initialized = true;
apiClient.on((data) => {
// contains repo update
if (!data.repo) {
return;
}
const { repo } = data;
repoStore.setRepo(repo);
// contains pipeline update
if (!data.pipeline) {
return;
}
const { pipeline } = data;
pipelineStore.setPipeline(repo.owner, repo.name, pipeline);
pipelineStore.setPipelineFeedItem({ ...pipeline, name: repo.name, owner: repo.owner, full_name: repoSlug(repo) });
// contains step update
if (!data.step) {
return;
}
const { step } = data;
pipelineStore.setStep(repo.owner, repo.name, pipeline.number, step);
});
};