export type ProjectProgressTaskKind = "backup" | "copy";

type ProjectProgressTask = {
	isActive: () => boolean;
	restore: () => void;
};

const projectProgressTasks = new Map<
	ProjectProgressTaskKind,
	ProjectProgressTask
>();

export function registerProjectProgressTask(
	kind: ProjectProgressTaskKind,
	task: ProjectProgressTask,
) {
	projectProgressTasks.set(kind, task);
}

export function getActiveProjectProgressTask() {
	for (const [kind, task] of projectProgressTasks) {
		if (task.isActive()) return kind;
	}
	return null;
}

export function restoreProjectProgressTask(kind: ProjectProgressTaskKind) {
	projectProgressTasks.get(kind)?.restore();
}
