restoreFiltersBackup method

Future<void> restoreFiltersBackup()

Implementation

Future<void> restoreFiltersBackup() async {
  if (state.filtersBackup.containsKey(state.model.id)) {
    final ModelFiltersBackup modelFiltersBackup = state.modelFiltersBackup;
    emit(state.copyWith(
      query: modelFiltersBackup.query,
      sort: modelFiltersBackup.sort,
      currentPage: modelFiltersBackup.currentPage,
      totalPages: modelFiltersBackup.totalPages,
      globalSearchQuery: modelFiltersBackup.globalSearchQuery,
    ));
    emit(state.copyWithNull(
      sort: modelFiltersBackup.sort == null,
      globalSearchQuery: modelFiltersBackup.globalSearchQuery == null,
      query: modelFiltersBackup.query == null,
    ));
    filterStructureBloc.init(state.query);
    globalSearchSilenced = true;
    globalSearchController.text = modelFiltersBackup.globalSearchValue;
    unawaited(Future<void>.delayed(const Duration(milliseconds: 250)).then((value) => globalSearchSilenced = false));
  } else {
    filterStructureBloc.init(null);
  }
}