fix: Label list not updated

This commit is contained in:
Anton Stubenbord
2023-05-29 18:12:22 +02:00
parent 5e9843f27f
commit 217de49fd4

View File

@@ -108,14 +108,16 @@ class _LabelsPageState extends State<LabelsPage> with SingleTickerProviderStateM
),
),
],
body: NotificationListener<ScrollNotification>(
body: BlocBuilder<LabelCubit, LabelState>(
builder: (context, state) {
return NotificationListener<ScrollNotification>(
onNotification: (notification) {
final metrics = notification.metrics;
if (metrics.maxScrollExtent == 0) {
return true;
}
final desiredTab =
((metrics.pixels / metrics.maxScrollExtent) * (_tabController.length - 1))
final desiredTab = ((metrics.pixels / metrics.maxScrollExtent) *
(_tabController.length - 1))
.round();
if (metrics.axis == Axis.horizontal && _currentIndex != desiredTab) {
@@ -143,16 +145,18 @@ class _LabelsPageState extends State<LabelsPage> with SingleTickerProviderStateM
SliverOverlapInjector(handle: searchBarHandle),
SliverOverlapInjector(handle: tabBarHandle),
LabelTabView<Correspondent>(
labels: context.watch<LabelCubit>().state.correspondents,
labels: state.correspondents,
filterBuilder: (label) => DocumentFilter(
correspondent: IdQueryParameter.fromId(label.id!),
),
canEdit: LocalUserAccount.current.paperlessUser.hasPermission(
PermissionAction.change, PermissionTarget.correspondent),
canAddNew: LocalUserAccount.current.paperlessUser.hasPermission(
canAddNew: LocalUserAccount.current.paperlessUser
.hasPermission(
PermissionAction.add, PermissionTarget.correspondent),
onEdit: _openEditCorrespondentPage,
emptyStateActionButtonLabel: S.of(context)!.addNewCorrespondent,
emptyStateActionButtonLabel:
S.of(context)!.addNewCorrespondent,
emptyStateDescription: S.of(context)!.noCorrespondentsSetUp,
onAddNew: _openAddCorrespondentPage,
),
@@ -167,16 +171,18 @@ class _LabelsPageState extends State<LabelsPage> with SingleTickerProviderStateM
SliverOverlapInjector(handle: searchBarHandle),
SliverOverlapInjector(handle: tabBarHandle),
LabelTabView<DocumentType>(
labels: context.watch<LabelCubit>().state.documentTypes,
labels: state.documentTypes,
filterBuilder: (label) => DocumentFilter(
documentType: IdQueryParameter.fromId(label.id!),
),
canEdit: LocalUserAccount.current.paperlessUser.hasPermission(
PermissionAction.change, PermissionTarget.documentType),
canAddNew: LocalUserAccount.current.paperlessUser.hasPermission(
canAddNew: LocalUserAccount.current.paperlessUser
.hasPermission(
PermissionAction.add, PermissionTarget.documentType),
onEdit: _openEditDocumentTypePage,
emptyStateActionButtonLabel: S.of(context)!.addNewDocumentType,
emptyStateActionButtonLabel:
S.of(context)!.addNewDocumentType,
emptyStateDescription: S.of(context)!.noDocumentTypesSetUp,
onAddNew: _openAddDocumentTypePage,
),
@@ -191,14 +197,15 @@ class _LabelsPageState extends State<LabelsPage> with SingleTickerProviderStateM
SliverOverlapInjector(handle: searchBarHandle),
SliverOverlapInjector(handle: tabBarHandle),
LabelTabView<Tag>(
labels: context.watch<LabelCubit>().state.tags,
labels: state.tags,
filterBuilder: (label) => DocumentFilter(
tags: TagsQuery.ids(include: [label.id!]),
),
canEdit: LocalUserAccount.current.paperlessUser
.hasPermission(PermissionAction.change, PermissionTarget.tag),
canEdit: LocalUserAccount.current.paperlessUser.hasPermission(
PermissionAction.change, PermissionTarget.tag),
canAddNew: LocalUserAccount.current.paperlessUser
.hasPermission(PermissionAction.add, PermissionTarget.tag),
.hasPermission(
PermissionAction.add, PermissionTarget.tag),
onEdit: _openEditTagPage,
leadingBuilder: (t) => CircleAvatar(
backgroundColor: t.color,
@@ -224,14 +231,15 @@ class _LabelsPageState extends State<LabelsPage> with SingleTickerProviderStateM
SliverOverlapInjector(handle: searchBarHandle),
SliverOverlapInjector(handle: tabBarHandle),
LabelTabView<StoragePath>(
labels: context.watch<LabelCubit>().state.storagePaths,
labels: state.storagePaths,
onEdit: _openEditStoragePathPage,
filterBuilder: (label) => DocumentFilter(
storagePath: IdQueryParameter.fromId(label.id!),
),
canEdit: LocalUserAccount.current.paperlessUser.hasPermission(
PermissionAction.change, PermissionTarget.storagePath),
canAddNew: LocalUserAccount.current.paperlessUser.hasPermission(
canAddNew: LocalUserAccount.current.paperlessUser
.hasPermission(
PermissionAction.add, PermissionTarget.storagePath),
contentBuilder: (path) => Text(path.path),
emptyStateActionButtonLabel: S.of(context)!.addNewStoragePath,
@@ -245,6 +253,8 @@ class _LabelsPageState extends State<LabelsPage> with SingleTickerProviderStateM
],
),
),
);
},
),
),
),