mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-08-25 07:52:27 +00:00
Refactor booking system: replace DebouncedBookingSystemService with DebouncedBookableSpacesService and streamline search handling
This commit is contained in:
@ -3,14 +3,14 @@ import 'package:syncrow_web/pages/access_management/booking_system/domain/load_b
|
||||
import 'package:syncrow_web/pages/access_management/booking_system/domain/models/paginated_bookable_spaces.dart';
|
||||
import 'package:syncrow_web/pages/access_management/booking_system/domain/services/bookable_system_service.dart';
|
||||
|
||||
class DebouncedBookingSystemService implements BookableSystemService {
|
||||
class DebouncedBookableSpacesService implements BookableSystemService {
|
||||
final BookableSystemService _inner;
|
||||
final Duration debounceDuration;
|
||||
|
||||
Timer? _debounceTimer;
|
||||
Completer<PaginatedBookableSpaces>? _lastCompleter;
|
||||
|
||||
DebouncedBookingSystemService(
|
||||
DebouncedBookableSpacesService(
|
||||
this._inner, {
|
||||
this.debounceDuration = const Duration(milliseconds: 500),
|
||||
});
|
@ -1,4 +1,3 @@
|
||||
import 'dart:async';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
@ -46,7 +45,6 @@ class _SidebarContent extends StatefulWidget {
|
||||
class __SidebarContentState extends State<_SidebarContent> {
|
||||
final TextEditingController searchController = TextEditingController();
|
||||
final ScrollController _scrollController = ScrollController();
|
||||
Timer? _searchDebounce;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@ -57,7 +55,6 @@ class __SidebarContentState extends State<_SidebarContent> {
|
||||
@override
|
||||
void dispose() {
|
||||
_scrollController.dispose();
|
||||
_searchDebounce?.cancel();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@ -69,10 +66,7 @@ class __SidebarContentState extends State<_SidebarContent> {
|
||||
}
|
||||
|
||||
void _handleSearch(String value) {
|
||||
_searchDebounce?.cancel();
|
||||
_searchDebounce = Timer(const Duration(milliseconds: 300), () {
|
||||
context.read<SidebarBloc>().add(SearchRoomsEvent(value));
|
||||
});
|
||||
context.read<SidebarBloc>().add(SearchRoomsEvent(value));
|
||||
}
|
||||
|
||||
@override
|
||||
|
Reference in New Issue
Block a user