Skip to content

Commit 8a7503c

Browse files
committed
perf(content_management): optimize topic list handling
- Replace unnecessary list copying with direct assignment - Use list spread operator for efficient element removal - Improve code readability and performance in DraftTopicsBloc
1 parent b515a80 commit 8a7503c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/content_management/bloc/draft_topics/draft_topics_bloc.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,13 @@ class DraftTopicsBloc extends Bloc<DraftTopicsEvent, DraftTopicsState> {
113113
PublishDraftTopicRequested event,
114114
Emitter<DraftTopicsState> emit,
115115
) async {
116-
final originalTopics = List<Topic>.from(state.topics);
116+
final originalTopics = state.topics;
117117
final topicIndex = originalTopics.indexWhere((t) => t.id == event.id);
118118
if (topicIndex == -1) return;
119-
120119
final topicToPublish = originalTopics[topicIndex];
121-
final updatedTopics = originalTopics..removeAt(topicIndex);
122-
120+
final updatedTopics = List<Topic>.from(originalTopics)
121+
..removeAt(topicIndex);
122+
123123
// Optimistically remove the topic from the UI.
124124
emit(
125125
state.copyWith(

0 commit comments

Comments
 (0)