Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

791 B
Raw Blame
import { isTaskInFinalState } from "../github/services/task-service";
import { isStateSyncPaused } from "./state-sync-paused";

// Archiving keeps the issue's current state: a completed task's issue stays
// closed, and shelving unfinished work does not close it. Unarchiving into an
// open column reopens the issue in case the task was completed before.
export async function resolveIssueStateChange(
  projectId: string,
  oldStatus: string,
  status: string,
): Promise<"close" | "reopen" | undefined> {
  if (isStateSyncPaused(status)) return;
  if (await isTaskInFinalState({ projectId, status, columnId: null }))
    return "close";
  if (
    isStateSyncPaused(oldStatus) ||
    (await isTaskInFinalState({ projectId, status: oldStatus, columnId: null }))
  )
    return "reopen";
}