tab trees
This commit is contained in:
@@ -16,6 +16,8 @@ class TabState extends WebPageInfo {
|
||||
@CopyWithField(immutable: true)
|
||||
final String id;
|
||||
|
||||
final String? parentId;
|
||||
|
||||
final String? contextId;
|
||||
|
||||
@override
|
||||
@@ -47,6 +49,7 @@ class TabState extends WebPageInfo {
|
||||
|
||||
TabState({
|
||||
required this.id,
|
||||
required this.parentId,
|
||||
required this.contextId,
|
||||
required super.url,
|
||||
required String title,
|
||||
@@ -64,6 +67,7 @@ class TabState extends WebPageInfo {
|
||||
|
||||
factory TabState.$default(String tabId) => TabState(
|
||||
id: tabId,
|
||||
parentId: null,
|
||||
contextId: null,
|
||||
url: Uri.parse('about:blank'),
|
||||
title: "",
|
||||
@@ -83,6 +87,7 @@ class TabState extends WebPageInfo {
|
||||
List<Object?> get hashParameters => [
|
||||
...super.hashParameters,
|
||||
id,
|
||||
parentId,
|
||||
contextId,
|
||||
icon,
|
||||
thumbnail,
|
||||
|
||||
@@ -7,6 +7,8 @@ part of 'tab.dart';
|
||||
// **************************************************************************
|
||||
|
||||
abstract class _$TabStateCWProxy {
|
||||
TabState parentId(String? parentId);
|
||||
|
||||
TabState contextId(String? contextId);
|
||||
|
||||
TabState url(Uri url);
|
||||
@@ -40,6 +42,7 @@ abstract class _$TabStateCWProxy {
|
||||
/// TabState(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
TabState call({
|
||||
String? parentId,
|
||||
String? contextId,
|
||||
Uri url,
|
||||
String title,
|
||||
@@ -62,6 +65,9 @@ class _$TabStateCWProxyImpl implements _$TabStateCWProxy {
|
||||
|
||||
final TabState _value;
|
||||
|
||||
@override
|
||||
TabState parentId(String? parentId) => this(parentId: parentId);
|
||||
|
||||
@override
|
||||
TabState contextId(String? contextId) => this(contextId: contextId);
|
||||
|
||||
@@ -113,6 +119,7 @@ class _$TabStateCWProxyImpl implements _$TabStateCWProxy {
|
||||
/// TabState(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
TabState call({
|
||||
Object? parentId = const $CopyWithPlaceholder(),
|
||||
Object? contextId = const $CopyWithPlaceholder(),
|
||||
Object? url = const $CopyWithPlaceholder(),
|
||||
Object? title = const $CopyWithPlaceholder(),
|
||||
@@ -129,6 +136,10 @@ class _$TabStateCWProxyImpl implements _$TabStateCWProxy {
|
||||
}) {
|
||||
return TabState(
|
||||
id: _value.id,
|
||||
parentId: parentId == const $CopyWithPlaceholder()
|
||||
? _value.parentId
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: parentId as String?,
|
||||
contextId: contextId == const $CopyWithPlaceholder()
|
||||
? _value.contextId
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
|
||||
@@ -24,6 +24,7 @@ class TabStates extends _$TabStates {
|
||||
state[contentState.id] ?? TabState.$default(contentState.id);
|
||||
state = {...state}
|
||||
..[contentState.id] = current.copyWith(
|
||||
parentId: contentState.parentId,
|
||||
contextId: contentState.contextId,
|
||||
url: Uri.parse(contentState.url),
|
||||
title: (contentState.title.isNotEmpty)
|
||||
|
||||
@@ -53,23 +53,27 @@ class TabRepository extends _$TabRepository {
|
||||
.read(selectedContainerProvider.notifier)
|
||||
.fetchData();
|
||||
|
||||
return ref.read(tabDatabaseProvider).tabDao.upsertContainerTabTransactional(
|
||||
() {
|
||||
return _tabsService.addTab(
|
||||
url: url,
|
||||
selectTab: selectTab,
|
||||
startLoading: startLoading,
|
||||
parentId: parentId,
|
||||
flags: flags,
|
||||
contextId: selectedContainer?.metadata.contextualIdentity,
|
||||
source: source,
|
||||
private: private,
|
||||
historyMetadata: historyMetadata,
|
||||
additionalHeaders: additionalHeaders,
|
||||
return ref
|
||||
.read(tabDatabaseProvider)
|
||||
.tabDao
|
||||
.upsertContainerTabTransactional(
|
||||
() {
|
||||
return _tabsService.addTab(
|
||||
url: url,
|
||||
selectTab: selectTab,
|
||||
startLoading: startLoading,
|
||||
parentId: parentId,
|
||||
flags: flags,
|
||||
contextId: selectedContainer?.metadata.contextualIdentity,
|
||||
source: source,
|
||||
private: private,
|
||||
historyMetadata: historyMetadata,
|
||||
additionalHeaders: additionalHeaders,
|
||||
);
|
||||
},
|
||||
parentId: Value(parentId),
|
||||
containerId: Value(selectedContainer?.id),
|
||||
);
|
||||
},
|
||||
containerId: Value(selectedContainer?.id),
|
||||
);
|
||||
}
|
||||
|
||||
Future<String> duplicateTab({
|
||||
@@ -83,16 +87,20 @@ class TabRepository extends _$TabRepository {
|
||||
.getContainerData(containerId),
|
||||
);
|
||||
|
||||
return ref.read(tabDatabaseProvider).tabDao.upsertContainerTabTransactional(
|
||||
() {
|
||||
return _tabsService.duplicateTab(
|
||||
selectTabId: selectTabId,
|
||||
newContextId: containerData?.metadata.contextualIdentity,
|
||||
selectNewTab: selectTab,
|
||||
return ref
|
||||
.read(tabDatabaseProvider)
|
||||
.tabDao
|
||||
.upsertContainerTabTransactional(
|
||||
() {
|
||||
return _tabsService.duplicateTab(
|
||||
selectTabId: selectTabId,
|
||||
newContextId: containerData?.metadata.contextualIdentity,
|
||||
selectNewTab: selectTab,
|
||||
);
|
||||
},
|
||||
parentId: const Value.absent(),
|
||||
containerId: Value(containerData?.id),
|
||||
);
|
||||
},
|
||||
containerId: Value(containerData?.id),
|
||||
);
|
||||
}
|
||||
|
||||
Future<bool> selectPreviousTab() async {
|
||||
@@ -227,6 +235,7 @@ class TabRepository extends _$TabRepository {
|
||||
final containerId = ref.read(selectedContainerProvider);
|
||||
await db.tabDao.upsertUnassignedTab(
|
||||
tabId,
|
||||
parentId: const Value.absent(),
|
||||
containerId: Value(containerId),
|
||||
);
|
||||
});
|
||||
|
||||
@@ -6,7 +6,7 @@ part of 'tab.dart';
|
||||
// RiverpodGenerator
|
||||
// **************************************************************************
|
||||
|
||||
String _$tabRepositoryHash() => r'9b7ef03bec41f149b3cb456b73d7ee0e1b2804df';
|
||||
String _$tabRepositoryHash() => r'db220096fef5d125a698063e9a88272db92e75c5';
|
||||
|
||||
/// See also [TabRepository].
|
||||
@ProviderFor(TabRepository)
|
||||
|
||||
Reference in New Issue
Block a user