package ctbrec.ui.sites.showup;

import java.io.IOException;
import java.util.List;

import ctbrec.Model;
import ctbrec.sites.showup.Showup;
import ctbrec.sites.showup.ShowupHttpClient;
import ctbrec.ui.tabs.PaginatedScheduledService;
import javafx.concurrent.Task;

public class ShowupUpdateService extends PaginatedScheduledService {

    private Showup showup;
    private String category;

    public ShowupUpdateService(Showup showup, String category) {
        this.showup = showup;
        this.category = category;
    }

    @Override
    protected Task<List<Model>> createTask() {
        return new Task<List<Model>>() {
            @Override
            public List<Model> call() throws IOException {
                ShowupHttpClient httpClient = (ShowupHttpClient) showup.getHttpClient();
                httpClient.setCookie("category", category);
                return showup.getModelList();
            }
        };
    }

}
