djangoflow / flutter-odoo-timesheets

Timesheet tracking app for Odoo
0 stars 3 forks source link

Display amount of Timers #55

Open ajil-apx opened 10 months ago

ajil-apx commented 10 months ago

I need help with this issue.

Context

On top of the List of active timers, we need to show the number of active timers. Refer to attached screenshot.

Description

Usual solution would be to use the headerBuilder and use state.data?.length. But in case of ContinuousListViewBlocBuilder, it would not work as the cubit would only load partial/paginated data.

I do not have a good solution to fix this issue at the moment. And the only solution that comes to mind is to create a separate cubit that talks to the repository and fetches the count of all active timesheets. I also have to make checks to make sure that this cubit is reloaded every time the TimesheetListCubit changes. This does not feel like a good solution.

Another probable solution would be to update ListCubit such that it uses a new ListData<T> instead of Data<List<T>>. This would give us more freedom to make changes to data.

For eg

@freezed  
class ListData<T, F> with _$ListData<T,F> {

  const factory Data({List<T>? data, F? filter, int? totalCount}) = Data;

}

Would love to hear if there is a better solution.

Screenshot 2023-11-07 at 16 25 00