package com.anytypeio.anytype.domain.history

import com.anytypeio.anytype.core_models.Command
import com.anytypeio.anytype.core_models.Id
import com.anytypeio.anytype.domain.base.AppCoroutineDispatchers
import com.anytypeio.anytype.domain.base.ResultInteractor
import com.anytypeio.anytype.domain.block.repo.BlockRepository
import javax.inject.Inject

class SetVersion @Inject constructor(
    dispatchers: AppCoroutineDispatchers,
    private val repo: BlockRepository
) : ResultInteractor<SetVersion.Params, Unit>(dispatchers.io) {

    override suspend fun doWork(params: Params) {
        val command = Command.VersionHistory.SetVersion(
            objectId = params.objectId,
            versionId = params.versionId
        )
        repo.setVersion(command)
    }

    data class Params(
        val objectId: Id,
        val versionId: Id
    )
}