package dev.photosync.core.upload;

import dev.photosync.core.provider.UploadReceipt;

/**
 * The transitions worth telling someone about.
 *
 * <p>Byte-level progress is deliberately not an event. It changes hundreds of
 * times per upload, and the only thing that wants it -- the queue screen -- is
 * redrawing every frame anyway and can just read {@link UploadQueue#snapshot()}.
 * Emitting it would mean thousands of cross-thread hops for no gain.
 */
public sealed interface UploadEvent {

    UploadJob job();

    record Enqueued(UploadJob job) implements UploadEvent {
    }

    record Started(UploadJob job) implements UploadEvent {
    }

    record Completed(UploadJob job, UploadReceipt receipt) implements UploadEvent {
    }

    /** A single attempt failed. {@code willRetry} says whether another one is coming. */
    record Failed(UploadJob job, String message, boolean willRetry) implements UploadEvent {
    }

    record Removed(UploadJob job) implements UploadEvent {
    }

    /** The last active job left the queue. The quit dialog waits for this. */
    record Drained(UploadJob job) implements UploadEvent {
    }
}
