init method

  1. @action
Future<bool> init({
  1. List<CalibreWeebi<ArticleRawAbstract>>? data,
  2. List<ArticlePhoto>? photosData,
})

Implementation

@action
Future<bool> init(
    {List<CalibreWeebi>? data, List<ArticlePhoto>? photosData}) async {
  // firstInit or demo case
  if (data != null && data.isNotEmpty) {
    calibresFull = ObservableList.of(data);
    _calibres = ObservableList.of(data);
    if (photosData != null && photosData.isNotEmpty) {
      photos = ObservableList.of(photosData);
    }
  } else {
    // normal
    final ccc = await _articlesService.getCategoriesRpc.request(null);
    if (ccc.isNotEmpty) {
      categories = ObservableList.of(ccc);
      _categories = ObservableList.of(ccc);
    }
    final calibresFromRpc =
        await _articlesService.getArticlesCalibresRpc.request(null);
    if (calibresFromRpc.isNotEmpty) {
      calibresFull = ObservableList.of(calibresFromRpc);
      _calibres = ObservableList.of(calibresFromRpc);
      final photosFromRpc = await _articlesService.getPhotosRpc.request(null);
      if (photosFromRpc.isNotEmpty) {
        photos = ObservableList.of(photosFromRpc);
      }
    }
  }
  initialLoading = false;
  //print('articles init ok');
  return initialLoading;
}