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