Conversation
Reviewer's GuideThe PR adds a deduplication mechanism to skip rapid repeated openPlugin events and cleans up tabs_bloc.dart by removing excessive blank lines and redundant whitespace across methods and imports. Sequence diagram for deduplication in openPlugin eventsequenceDiagram
participant TabsBloc
participant Plugin
participant ViewPB
participant State
actor User
User->>TabsBloc: Triggers openPlugin(plugin, view)
TabsBloc->>TabsBloc: Check if plugin and view match last opened
TabsBloc->>TabsBloc: Check time since last open
alt Within deduplication window
TabsBloc-->>User: Ignore event (no action)
else Outside deduplication window
TabsBloc->>TabsBloc: Update _lastOpenedPluginId, _lastOpenedViewId, _lastOpenTime
TabsBloc->>State: Hide secondary plugin
TabsBloc->>State: Set secondary plugin to BlankPagePlugin
TabsBloc->>State: Emit openPlugin state
TabsBloc->>TabsBloc: If setLatest, update latest open view
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
|
There was a problem hiding this comment.
Hey there - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `frontend/appflowy_flutter/lib/workspace/application/tabs/tabs_bloc.dart:33-35` </location>
<code_context>
+
@override
Future<void> close() {
state.dispose();
+
+
</code_context>
<issue_to_address>
**suggestion (bug_risk):** Dispose is called before super.close(), which is correct but may need error handling.
Wrap state.dispose() in a try/catch to guarantee super.close() is always called, even if dispose fails.
```suggestion
@override
Future<void> close() {
try {
state.dispose();
} catch (e, stackTrace) {
// Optionally log the error, e.g. using a logger
// logger.error('Error disposing state', e, stackTrace);
}
```
</issue_to_address>
### Comment 2
<location> `frontend/appflowy_flutter/lib/workspace/application/tabs/tabs_bloc.dart:55` </location>
<code_context>
return super.close();
}
-
void _dispatch() {
on<TabsEvent>(
(event, emit) async {
</code_context>
<issue_to_address>
**issue (bug_risk):** The _dispatch method is not invoked in the constructor.
If event handlers should be registered during initialization, call _dispatch in the constructor to ensure proper setup.
</issue_to_address>
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| @@ -53,15 +71,13 @@ class TabsBloc extends Bloc<TabsEvent, TabsState> { | |||
| if (pm?.isPinned == true) { | |||
| return; | |||
| } | |||
There was a problem hiding this comment.
issue (bug_risk): The _dispatch method is not invoked in the constructor.
If event handlers should be registered during initialization, call _dispatch in the constructor to ensure proper setup.
|
|
||
| Expand Up | ||
|
|
||
| @@ -73,6 +78,22 @@ class TabsBloc extends Bloc<TabsEvent, TabsState> { |
There was a problem hiding this comment.
Please verify the code before submitting a PR.
Feature Preview
PR Checklist
Summary by Sourcery
Enhance tab opening in TabsBloc by debouncing rapid duplicate openPlugin events and clean up formatting in the file
Enhancements:
Chores: