1
0
mirror of https://github.com/woodpecker-ci/woodpecker.git synced 2025-01-17 17:45:03 +02:00

41 lines
852 B
TypeScript
Raw Normal View History

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);
});
};