Skip to content

Commit 952bc6e

Browse files
committed
fix(community_management): handle null pending update id
- Update state more granularly when receiving remote changes - Ensure lastPendingUpdateId and snackbarMessage are reset in all cases - Improve code readability with more specific state updates
1 parent f87e940 commit 952bc6e

File tree

1 file changed

+26
-8
lines changed

1 file changed

+26
-8
lines changed

lib/community_management/bloc/community_management_bloc.dart

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -421,22 +421,40 @@ class CommunityManagementBloc
421421
if (index != -1) {
422422
final updatedEngagements = List<Engagement>.from(state.engagements)
423423
..[index] = item;
424-
emit(state.copyWith(engagements: updatedEngagements));
424+
emit(
425+
state.copyWith(
426+
engagements: updatedEngagements,
427+
lastPendingUpdateId: null,
428+
snackbarMessage: null,
429+
),
430+
);
431+
} else {
432+
emit(
433+
state.copyWith(lastPendingUpdateId: null, snackbarMessage: null),
434+
);
425435
}
426436
} else if (item is Report) {
427437
final index = state.reports.indexWhere((r) => r.id == item.id);
428438
if (index != -1) {
429439
final updatedReports = List<Report>.from(state.reports)
430440
..[index] = item;
431-
emit(state.copyWith(reports: updatedReports));
441+
emit(
442+
state.copyWith(
443+
reports: updatedReports,
444+
lastPendingUpdateId: null,
445+
snackbarMessage: null,
446+
),
447+
);
448+
} else {
449+
emit(
450+
state.copyWith(lastPendingUpdateId: null, snackbarMessage: null),
451+
);
432452
}
453+
} else {
454+
emit(
455+
state.copyWith(lastPendingUpdateId: null, snackbarMessage: null),
456+
);
433457
}
434-
emit(
435-
state.copyWith(
436-
lastPendingUpdateId: null,
437-
snackbarMessage: null,
438-
),
439-
);
440458
}
441459
}
442460
}

0 commit comments

Comments
 (0)