import { ModuleRoot } from "queenjs/framework";
import { PageListController } from "queenjs/framework/utils";
import actions from "./actions";
import ListHttp from "./http";
import ItemObject from "./objects/item";
import state from "./state";
import { Uploader } from "./objects/uploader";

export default class ListModule extends ModuleRoot {
  state = new state().reactive();
  actions = this.createAction(actions);
  http = new ListHttp(this);
  list: ItemObject[] = [];
  backendList = new PageListController(this);
  exportList = new PageListController(this);
  uploader = new Uploader(this);

  onInit() {
    super.onInit();
    this.backendList.setCrudPrefix("/antique", this.http as any);
    // this.exportList.setCrudPrefix("/antique", this.http as any);
    // this.exportList.hasLimit = true;
    // let speed = 1;
    // setInterval(() => {
    //   this.state.scrollOffsetX += speed;
    //   if (this.state.scrollOffsetX <= 0) {
    //     speed = 1;
    //   }
    //   if (this.state.scrollOffsetX >= this.state.repeatWidth) {
    //     speed = -1;
    //   }
    //   this.actions.updateItem();
    // }, 1000 / 20);
  }
}
