/*
 * Book's Story — free and open-source Material You eBook reader.
 * Copyright (C) 2024-2026 Acclorite
 * SPDX-License-Identifier: GPL-3.0-only
 */

package org.dueattendant149.bookshelf.domain.use_case.color_preset

import org.dueattendant149.bookshelf.core.log.logE
import org.dueattendant149.bookshelf.core.log.logI
import org.dueattendant149.bookshelf.domain.model.reader.ColorPreset
import org.dueattendant149.bookshelf.domain.repository.ColorPresetRepository
import javax.inject.Inject

private const val TAG = "DeleteColorPreset"

class DeleteColorPresetUseCase @Inject constructor(
    private val colorPresetRepository: ColorPresetRepository
) {

    suspend operator fun invoke(colorPreset: ColorPreset) {
        logI(TAG, "Deleting [${colorPreset.id}] color preset.")

        colorPresetRepository.deleteColorPreset(colorPreset).fold(
            onSuccess = {
                logI(TAG, "Successfully deleted [${colorPreset.id}] color preset.")
            },
            onFailure = {
                logE(
                    TAG,
                    "Could not delete [${colorPreset.id}] color preset with error: ${it.message}"
                )
            }
        )
    }
}