/*
 * 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 = "GetColorPresets"

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

    suspend operator fun invoke(): List<ColorPreset> {
        logI(TAG, "Getting color presets.")

        return colorPresetRepository.getColorPresets().fold(
            onSuccess = {
                logI(TAG, "Successfully got [${it.size}] color presets.")
                it
            },
            onFailure = {
                logE(TAG, "Could not get color presets with error: ${it.message}")
                emptyList()
            }
        )
    }
}