loadCollection method

Future<void> loadCollection(
  1. String modelId
)

? This method will be called when we first open a collection through the interface, or switch to a new collection from some other collection

Implementation

Future<void> loadCollection(String modelId) async {
  if (state.model.id == modelId) {
    return;
  }
  globalSearchSilenced = true;
  final Model? model = modelCollectionBloc.tryToFindModelById(modelId);
  if (model == null) {
    globalSearchSilenced = false;
    notFoundModelError(modelId);
  }
  globalSearchController.clear();
  emit(state.copyWith(
    isLoading: true,
    notFoundAnything: false,
    model: model,
    totalPages: 1,
    currentPage: 1,
    dataRows: [],
  ));
  emit(state.copyWithNull(
    query: true,
    globalSearchQuery: true,
    sort: true,
  ));
  await restoreFiltersBackup();
  await _loadData(modelId: modelId, page: state.currentPage);
  globalSearchSilenced = false;
}