flatten hierarchies correctly
This commit is contained in:
@@ -223,11 +223,13 @@ selectedContainerTabStatesWithContainer(Ref ref) {
|
||||
|
||||
final tabStates = ref.watch(tabStatesProvider);
|
||||
|
||||
final pinnedTabIds = ref.watch(
|
||||
watchPinnedTabIdsProvider.select((value) => value.value),
|
||||
);
|
||||
final groupedItems = ref
|
||||
.watch(groupedTabListItemsProvider(containerId: filter.containerId))
|
||||
.value;
|
||||
|
||||
final orderKeys = {for (final tab in sortedTabs) tab.tabId: tab.orderKey};
|
||||
final groupedOrder = {
|
||||
for (var i = 0; i < groupedItems.length; i++) groupedItems[i].tabId: i,
|
||||
};
|
||||
|
||||
final items = [
|
||||
for (final tabEntity in sortedTabs)
|
||||
@@ -240,24 +242,10 @@ selectedContainerTabStatesWithContainer(Ref ref) {
|
||||
),
|
||||
];
|
||||
|
||||
final tabBarDirection = ref.watch(
|
||||
generalSettingsWithDefaultsProvider.select((s) => s.tabBarDirection),
|
||||
);
|
||||
|
||||
items.sort((a, b) {
|
||||
final aPinned = pinnedTabIds?.contains(a.$1.id) ?? false;
|
||||
final bPinned = pinnedTabIds?.contains(b.$1.id) ?? false;
|
||||
|
||||
if (aPinned != bPinned) {
|
||||
return aPinned ? -1 : 1;
|
||||
}
|
||||
|
||||
final aOrderKey = orderKeys[a.$1.id] ?? '';
|
||||
final bOrderKey = orderKeys[b.$1.id] ?? '';
|
||||
// Root tabs always append (trailing key), so ascending = oldest first.
|
||||
return tabBarDirection == TabBarDirection.newestFirst
|
||||
? bOrderKey.compareTo(aOrderKey)
|
||||
: aOrderKey.compareTo(bOrderKey);
|
||||
final aIndex = groupedOrder[a.$1.id] ?? groupedItems.length;
|
||||
final bIndex = groupedOrder[b.$1.id] ?? groupedItems.length;
|
||||
return aIndex.compareTo(bIndex);
|
||||
});
|
||||
|
||||
return EquatableValue(items);
|
||||
|
||||
+14
-18
@@ -45,8 +45,6 @@ import 'package:weblibre/features/geckoview/features/browser/presentation/widget
|
||||
import 'package:weblibre/features/geckoview/features/browser/presentation/widgets/tab_view/tab_view_header.dart';
|
||||
import 'package:weblibre/features/geckoview/features/browser/presentation/widgets/tab_view/tab_view_item.dart';
|
||||
import 'package:weblibre/features/geckoview/features/browser/utils/grid_calculations.dart';
|
||||
import 'package:weblibre/features/geckoview/features/tabs/data/database/definitions.drift.dart'
|
||||
show TabsWithRootAndDepthResult;
|
||||
import 'package:weblibre/features/geckoview/features/tabs/data/entities/container_filter.dart';
|
||||
import 'package:weblibre/features/geckoview/features/tabs/data/entities/tab_entity.dart';
|
||||
import 'package:weblibre/features/geckoview/features/tabs/domain/providers.dart';
|
||||
@@ -190,13 +188,11 @@ class _TabGridView extends HookConsumerWidget {
|
||||
),
|
||||
);
|
||||
final collapsedGroups = ref.watch(collapsedGroupsProvider);
|
||||
final List<TabsWithRootAndDepthResult> treeRows = showHierarchicalTabs
|
||||
? ref.watch(
|
||||
watchTabsWithRootAndDepthProvider(
|
||||
containerId,
|
||||
).select((value) => value.value ?? const []),
|
||||
)
|
||||
: const <TabsWithRootAndDepthResult>[];
|
||||
final treeRows = ref.watch(
|
||||
watchTabsWithRootAndDepthProvider(
|
||||
containerId,
|
||||
).select((value) => value.value ?? const []),
|
||||
);
|
||||
|
||||
final hasActiveSearch = ref.watch(
|
||||
tabSearchRepositoryProvider(
|
||||
@@ -205,7 +201,7 @@ class _TabGridView extends HookConsumerWidget {
|
||||
);
|
||||
|
||||
final List<TabViewItem> primaryRows;
|
||||
if (hasActiveSearch || !showHierarchicalTabs) {
|
||||
if (hasActiveSearch) {
|
||||
final flat = ref.watch(
|
||||
seamlessFilteredTabEntitiesProvider(
|
||||
searchPartition: TabSearchPartition.preview,
|
||||
@@ -236,14 +232,14 @@ class _TabGridView extends HookConsumerWidget {
|
||||
TabListStandaloneItem(:final tabId) => TabViewItem.standalone(
|
||||
tabId: tabId,
|
||||
),
|
||||
final TabListParentGroup g => TabViewItem.parent(
|
||||
tabId: g.tabId,
|
||||
parentGroup: g,
|
||||
),
|
||||
final TabListChildItem c => TabViewItem.child(
|
||||
tabId: c.tabId,
|
||||
childItem: c,
|
||||
),
|
||||
final TabListParentGroup g =>
|
||||
showHierarchicalTabs
|
||||
? TabViewItem.parent(tabId: g.tabId, parentGroup: g)
|
||||
: TabViewItem.standalone(tabId: g.tabId),
|
||||
final TabListChildItem c =>
|
||||
showHierarchicalTabs
|
||||
? TabViewItem.child(tabId: c.tabId, childItem: c)
|
||||
: TabViewItem.standalone(tabId: c.tabId),
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
+14
-18
@@ -43,8 +43,6 @@ import 'package:weblibre/features/geckoview/features/browser/presentation/widget
|
||||
import 'package:weblibre/features/geckoview/features/browser/presentation/widgets/tab_view/tab_preview.dart';
|
||||
import 'package:weblibre/features/geckoview/features/browser/presentation/widgets/tab_view/tab_view_header.dart';
|
||||
import 'package:weblibre/features/geckoview/features/browser/presentation/widgets/tab_view/tab_view_item.dart';
|
||||
import 'package:weblibre/features/geckoview/features/tabs/data/database/definitions.drift.dart'
|
||||
show TabsWithRootAndDepthResult;
|
||||
import 'package:weblibre/features/geckoview/features/tabs/data/entities/container_filter.dart';
|
||||
import 'package:weblibre/features/geckoview/features/tabs/data/entities/tab_entity.dart';
|
||||
import 'package:weblibre/features/geckoview/features/tabs/domain/providers.dart';
|
||||
@@ -251,13 +249,11 @@ class _TabListView extends HookConsumerWidget {
|
||||
generalSettingsWithDefaultsProvider.select((s) => s.tabListDirection),
|
||||
);
|
||||
final collapsedGroups = ref.watch(collapsedGroupsProvider);
|
||||
final List<TabsWithRootAndDepthResult> treeRows = showHierarchicalTabs
|
||||
? ref.watch(
|
||||
watchTabsWithRootAndDepthProvider(
|
||||
containerId,
|
||||
).select((value) => value.value ?? const []),
|
||||
)
|
||||
: const <TabsWithRootAndDepthResult>[];
|
||||
final treeRows = ref.watch(
|
||||
watchTabsWithRootAndDepthProvider(
|
||||
containerId,
|
||||
).select((value) => value.value ?? const []),
|
||||
);
|
||||
|
||||
final hasActiveSearch = ref.watch(
|
||||
tabSearchRepositoryProvider(
|
||||
@@ -266,7 +262,7 @@ class _TabListView extends HookConsumerWidget {
|
||||
);
|
||||
|
||||
final List<TabViewItem> primaryRows;
|
||||
if (hasActiveSearch || !showHierarchicalTabs) {
|
||||
if (hasActiveSearch) {
|
||||
final flat = ref.watch(
|
||||
seamlessFilteredTabEntitiesProvider(
|
||||
searchPartition: TabSearchPartition.preview,
|
||||
@@ -297,14 +293,14 @@ class _TabListView extends HookConsumerWidget {
|
||||
TabListStandaloneItem(:final tabId) => TabViewItem.standalone(
|
||||
tabId: tabId,
|
||||
),
|
||||
final TabListParentGroup g => TabViewItem.parent(
|
||||
tabId: g.tabId,
|
||||
parentGroup: g,
|
||||
),
|
||||
final TabListChildItem c => TabViewItem.child(
|
||||
tabId: c.tabId,
|
||||
childItem: c,
|
||||
),
|
||||
final TabListParentGroup g =>
|
||||
showHierarchicalTabs
|
||||
? TabViewItem.parent(tabId: g.tabId, parentGroup: g)
|
||||
: TabViewItem.standalone(tabId: g.tabId),
|
||||
final TabListChildItem c =>
|
||||
showHierarchicalTabs
|
||||
? TabViewItem.child(tabId: c.tabId, childItem: c)
|
||||
: TabViewItem.standalone(tabId: c.tabId),
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user