improve tab insertion process

This commit is contained in:
Fabian Freund
2026-01-01 17:45:18 +01:00
parent 8848bd5d09
commit 61267c899d
28 changed files with 2109 additions and 91 deletions
@@ -50,6 +50,7 @@ class OpenSharedContent extends HookConsumerWidget {
private: isPrivate,
container: Value(selectedContainer.value),
launchedFromIntent: true,
selectTab: true,
);
if (context.mounted) {
@@ -501,7 +501,7 @@ class QuickTabSwitcher extends HookConsumerWidget {
if (item.isHistory) {
await ref
.read(tabRepositoryProvider.notifier)
.addTab(url: item.url, private: false);
.addTab(url: item.url, private: false, selectTab: true);
} else {
await ref.read(tabRepositoryProvider.notifier).selectTab(item.id);
}
@@ -755,6 +755,7 @@ class NavigationMenuButton extends HookConsumerWidget {
url: Uri.parse('https://addons.mozilla.org'),
private: isPrivate,
container: const Value(null),
selectTab: true,
);
},
leadingIcon: const Icon(MdiIcons.puzzlePlus),
@@ -188,6 +188,7 @@ class _BrowserViewState extends ConsumerState<BrowserView>
settings.tabIntentOpenSetting ==
TabIntentOpenSetting.private,
launchedFromIntent: true,
selectTab: true,
);
case SharedText():
final bang =
@@ -202,6 +203,7 @@ class _BrowserViewState extends ConsumerState<BrowserView>
settings.tabIntentOpenSetting ==
TabIntentOpenSetting.private,
launchedFromIntent: true,
selectTab: true,
);
}
case TabIntentOpenSetting.ask:
@@ -1,5 +1,6 @@
import 'dart:convert';
import 'package:collection/collection.dart';
import 'package:drift/drift.dart' show Value;
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
@@ -297,7 +298,7 @@ class TabViewHeader extends HookConsumerWidget {
ref
.read(tabRepositoryProvider.notifier)
.undoClose,
count: count,
count: count.length,
);
}
}
@@ -329,7 +330,7 @@ class TabViewHeader extends HookConsumerWidget {
ref
.read(tabRepositoryProvider.notifier)
.undoClose,
count: count,
count: count.length,
);
}
}
@@ -379,7 +380,7 @@ class TabViewHeader extends HookConsumerWidget {
if (result == true) {
try {
await ref
final closedTabIds = await ref
.read(
tabDataRepositoryProvider
.notifier,
@@ -402,25 +403,35 @@ class TabViewHeader extends HookConsumerWidget {
tabRepositoryProvider.notifier,
)
.addMultipleTabs(
tabs: tabs
.map(
(tab) => AddTabParams(
url: tab.url.toString(),
startLoading: true,
parentId: tab.parentId,
private:
tab.isPrivate ??
false,
flags: LoadUrlFlags.NONE
.toValue(),
source: Internal.newTab
.toValue(),
contextId: selectedContainer
.metadata
.contextualIdentity,
),
)
.toList(),
tabs: tabs.map((tab) {
var parentId = tab.parentId;
while (parentId != null &&
closedTabIds.contains(
parentId,
)) {
parentId = tabs
.firstWhereOrNull(
(old) =>
old.id == parentId,
)
?.parentId;
}
return AddTabParams(
url: tab.url.toString(),
startLoading: true,
parentId: parentId,
private:
tab.isPrivate ?? false,
flags: LoadUrlFlags.NONE
.toValue(),
source: Internal.newTab
.toValue(),
contextId: selectedContainer
.metadata
.contextualIdentity,
);
}).toList(),
container: Value(
selectedContainer,
),