//
//  TSGenerateHistoryVM.swift
//  AIRingtone
//
//  Created by 100Years on 2025/3/18.
//

import ObjectMapper

class TSGenerateHistoryVM {
    
    lazy var modelList: [TSAIRintoneHistoryModel] = {
        getModelList()
    }()
    
    private func getModelList()->[TSAIRintoneHistoryModel]{
        var list = [TSAIRintoneHistoryModel]()
        
        if aiRintoneHistoryModel.list.count > 0 {
            list.append(aiRintoneHistoryModel)
        }
        return list
    }
    
    //生成的历史
    lazy var aiRintoneHistoryModel: TSAIRintoneHistoryModel = {
        let model = TSAIRintoneHistoryModel(title: "Generate History", list:TSAIRintoneHistory.listModelArray)
        return model
    }()

}


extension TSGenerateHistoryVM {
    
    func updateRecentData() {
        aiRintoneHistoryModel.list = Array(TSAIRintoneHistory.listModelArray.prefix(2))
        modelList = getModelList()
    }
    
    func removeModel(model:TSActionInfoModel){
        TSAIRintoneHistory.removeModel(model: model)
        updateRecentData()
    }
    
}
