[client] Fix removeListener call

This commit is contained in:
Abhishek Shroff
2024-12-11 23:08:11 +05:30
parent 86d2904bf3
commit 36a2455f77
3 changed files with 11 additions and 5 deletions
@@ -25,8 +25,11 @@ class ActionQueueStatusNotifier extends ChangeNotifier {
// Ignore progress updates
if (_statusMap[action].runtimeType != status.runtimeType) {
if (status is ActionStatusDone) {
_listeners.remove(action)?.call();
final l = _listeners.remove(action);
_statusMap.remove(action);
if (l != null) {
Future.microtask(() => l());
}
} else {
_statusMap[action] = status;
}
+3 -3
View File
@@ -47,7 +47,7 @@ class ActionView extends StatelessWidget {
final account = context.read<PhylumAccount>();
String description = error.description;
if (error is PhylumApiErrorResponse) {
if (error.code == "name_conflict") {
if (error.code == "resource_name_conflict") {
description = 'Error: Another resource with this name already exists on the server.';
}
}
@@ -57,8 +57,8 @@ class ActionView extends StatelessWidget {
trailing: Row(
mainAxisSize: MainAxisSize.min,
children: [
IconButton(icon: const Icon(Icons.refresh), onPressed: () => context.read<PhylumActionQueue>().retryAction(action.id)),
IconButton(icon: const Icon(Icons.delete), onPressed: () => context.read<PhylumActionQueue>().deleteAction(action.id)),
IconButton(icon: const Icon(Icons.refresh), tooltip: 'Retry', onPressed: () => context.read<PhylumActionQueue>().retryAction(action.id)),
IconButton(icon: const Icon(Icons.block), tooltip: 'Delete', onPressed: () => context.read<PhylumActionQueue>().deleteAction(action.id)),
],
),
);
+4 -1
View File
@@ -44,8 +44,11 @@ class _ActionsSliverState extends State<ActionsSliver> {
// Ignore progress updates
if (_statusMap[action].runtimeType != status.runtimeType) {
if (status is ActionStatusDone) {
_listeners.remove(action)?.call();
final l = _listeners.remove(action);
_statusMap.remove(action);
if (l != null) {
Future.microtask(() => l());
}
} else {
_statusMap[action] = status;
}