1
0
mirror of https://github.com/woodpecker-ci/woodpecker.git synced 2024-12-12 08:23:48 +02:00
woodpecker/web/src/compositions/useEvents.ts
qwerty287 3033abc3b4
Add own workflow model (#1784)
Closes #1287

---------

Co-authored-by: 6543 <6543@obermui.de>
2023-06-27 18:01:18 +02:00

41 lines
852 B
TypeScript

import { usePipelineStore } from '~/store/pipelines';
import { useRepoStore } from '~/store/repos';
import useApiClient from './useApiClient';
const apiClient = useApiClient();
let initialized = false;
export default () => {
if (initialized) {
return;
}
const repoStore = useRepoStore();
const pipelineStore = usePipelineStore();
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.id, pipeline);
// contains step update
if (!data.step) {
return;
}
const { step } = data;
pipelineStore.setWorkflow(repo.id, pipeline.number, step);
});
};