Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ class TabsBloc extends Bloc<TabsEvent, TabsState> {

late final MenuSharedState menuSharedState;

String? _lastOpenedPluginId;
DateTime? _lastOpenTime;
static const _deduplicationWindow = Duration(milliseconds: 500);

@override
Future<void> close() {
state.dispose();
Expand Down Expand Up @@ -73,6 +77,19 @@ class TabsBloc extends Bloc<TabsEvent, TabsState> {
_setLatestOpenView(view);
},
openPlugin: (Plugin plugin, ViewPB? view, bool setLatest) {
final now = DateTime.now();

// deduplicate. skip if same plugin was just opened
if (_lastOpenedPluginId == plugin.id && _lastOpenTime != null) {
final timeSinceLastOpen = now.difference(_lastOpenTime!);
if (timeSinceLastOpen < _deduplicationWindow) {
return;
}
}

_lastOpenedPluginId = plugin.id;
_lastOpenTime = now;

state.currentPageManager
..hideSecondaryPlugin()
..setSecondaryPlugin(BlankPagePlugin());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,23 @@ class _SingleInnerViewItemState extends State<SingleInnerViewItem> {

bool isIconPickerOpened = false;

DateTime? _lastClickTime;
static const _clickThrottleDuration = Duration(milliseconds: 200);

void _handleViewTap() {
final now = DateTime.now();

if (_lastClickTime != null) {
final timeSinceLastClick = now.difference(_lastClickTime!);
if (timeSinceLastClick < _clickThrottleDuration) {
return;
}
}

_lastClickTime = now;
widget.onSelected(context, widget.view);
}

@override
Widget build(BuildContext context) {
bool isSelected = widget.isSelected;
Expand Down Expand Up @@ -586,7 +603,7 @@ class _SingleInnerViewItemState extends State<SingleInnerViewItem> {

final child = GestureDetector(
behavior: HitTestBehavior.translucent,
onTap: () => widget.onSelected(context, widget.view),
onTap: _handleViewTap,
onTertiaryTapDown: (_) =>
widget.onTertiarySelected?.call(context, widget.view),
child: SizedBox(
Expand Down