upsert container when cloning
This commit is contained in:
@@ -127,8 +127,10 @@ class TabRepository extends _$TabRepository {
|
|||||||
.toSet();
|
.toSet();
|
||||||
|
|
||||||
// Batch validate parent IDs that aren't in the current creation batch
|
// Batch validate parent IDs that aren't in the current creation batch
|
||||||
final existingParentIds =
|
final existingParentIds = await tabDao
|
||||||
await tabDao.getExistingTabIds(parentIdsToValidate).get().then((ids) => ids.toSet());
|
.getExistingTabIds(parentIdsToValidate)
|
||||||
|
.get()
|
||||||
|
.then((ids) => ids.toSet());
|
||||||
|
|
||||||
// Upsert all tabs in the database
|
// Upsert all tabs in the database
|
||||||
for (var i = 0; i < createdTabIds.length; i++) {
|
for (var i = 0; i < createdTabIds.length; i++) {
|
||||||
@@ -160,17 +162,11 @@ class TabRepository extends _$TabRepository {
|
|||||||
|
|
||||||
Future<String> duplicateTab({
|
Future<String> duplicateTab({
|
||||||
required String selectTabId,
|
required String selectTabId,
|
||||||
required String? containerId,
|
required ContainerData? containerData,
|
||||||
required bool selectTab,
|
required bool selectTab,
|
||||||
}) async {
|
}) async {
|
||||||
final tabDao = ref.read(tabDatabaseProvider).tabDao;
|
final tabDao = ref.read(tabDatabaseProvider).tabDao;
|
||||||
|
|
||||||
final containerData = await containerId.mapNotNull(
|
|
||||||
(containerId) => ref
|
|
||||||
.read(containerRepositoryProvider.notifier)
|
|
||||||
.getContainerData(containerId),
|
|
||||||
);
|
|
||||||
|
|
||||||
return await tabDao.upsertTabTransactional(
|
return await tabDao.upsertTabTransactional(
|
||||||
() {
|
() {
|
||||||
return _tabsService.duplicateTab(
|
return _tabsService.duplicateTab(
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ final class TabRepositoryProvider
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String _$tabRepositoryHash() => r'6a66c2f1f8d00767d19e6125d4eafc6d93381c8a';
|
String _$tabRepositoryHash() => r'ab4ba2bf11ccbd99497819b9068cbbd733a93d81';
|
||||||
|
|
||||||
abstract class _$TabRepository extends $Notifier<void> {
|
abstract class _$TabRepository extends $Notifier<void> {
|
||||||
void build();
|
void build();
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
*/
|
*/
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'package:drift/drift.dart';
|
||||||
import 'package:file_picker/file_picker.dart';
|
import 'package:file_picker/file_picker.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
@@ -195,6 +196,9 @@ class TabMenu extends HookConsumerWidget {
|
|||||||
child: const Text('Regular'),
|
child: const Text('Regular'),
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
final tabState = ref.read(tabStateProvider(selectedTabId))!;
|
final tabState = ref.read(tabStateProvider(selectedTabId))!;
|
||||||
|
final containerData = await ref
|
||||||
|
.read(tabDataRepositoryProvider.notifier)
|
||||||
|
.getTabContainerData(selectedTabId);
|
||||||
|
|
||||||
final tabId = (tabState.isPrivate)
|
final tabId = (tabState.isPrivate)
|
||||||
? await ref
|
? await ref
|
||||||
@@ -202,13 +206,14 @@ class TabMenu extends HookConsumerWidget {
|
|||||||
.addTab(
|
.addTab(
|
||||||
url: tabState.url,
|
url: tabState.url,
|
||||||
private: false,
|
private: false,
|
||||||
|
container: Value(containerData),
|
||||||
selectTab: false,
|
selectTab: false,
|
||||||
)
|
)
|
||||||
: await ref
|
: await ref
|
||||||
.read(tabRepositoryProvider.notifier)
|
.read(tabRepositoryProvider.notifier)
|
||||||
.duplicateTab(
|
.duplicateTab(
|
||||||
selectTabId: selectedTabId,
|
selectTabId: selectedTabId,
|
||||||
containerId: tabState.contextId,
|
containerData: containerData,
|
||||||
selectTab: false,
|
selectTab: false,
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -230,6 +235,9 @@ class TabMenu extends HookConsumerWidget {
|
|||||||
child: const Text('Private'),
|
child: const Text('Private'),
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
final tabState = ref.read(tabStateProvider(selectedTabId))!;
|
final tabState = ref.read(tabStateProvider(selectedTabId))!;
|
||||||
|
final containerData = await ref
|
||||||
|
.read(tabDataRepositoryProvider.notifier)
|
||||||
|
.getTabContainerData(selectedTabId);
|
||||||
|
|
||||||
final tabId = (!tabState.isPrivate)
|
final tabId = (!tabState.isPrivate)
|
||||||
? await ref
|
? await ref
|
||||||
@@ -237,13 +245,14 @@ class TabMenu extends HookConsumerWidget {
|
|||||||
.addTab(
|
.addTab(
|
||||||
url: tabState.url,
|
url: tabState.url,
|
||||||
private: true,
|
private: true,
|
||||||
|
container: Value(containerData),
|
||||||
selectTab: false,
|
selectTab: false,
|
||||||
)
|
)
|
||||||
: await ref
|
: await ref
|
||||||
.read(tabRepositoryProvider.notifier)
|
.read(tabRepositoryProvider.notifier)
|
||||||
.duplicateTab(
|
.duplicateTab(
|
||||||
selectTabId: selectedTabId,
|
selectTabId: selectedTabId,
|
||||||
containerId: tabState.contextId,
|
containerData: containerData,
|
||||||
selectTab: false,
|
selectTab: false,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -193,6 +193,14 @@ class TabDataRepository extends _$TabDataRepository {
|
|||||||
.getSingleOrNull();
|
.getSingleOrNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<ContainerData?> getTabContainerData(String tabId) {
|
||||||
|
return ref
|
||||||
|
.read(tabDatabaseProvider)
|
||||||
|
.tabDao
|
||||||
|
.getTabContainerData(tabId)
|
||||||
|
.getSingleOrNull();
|
||||||
|
}
|
||||||
|
|
||||||
Future<Map<String, String?>> getTabsContainerId(Iterable<String> tabIds) {
|
Future<Map<String, String?>> getTabsContainerId(Iterable<String> tabIds) {
|
||||||
return ref
|
return ref
|
||||||
.read(tabDatabaseProvider)
|
.read(tabDatabaseProvider)
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ final class TabDataRepositoryProvider
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String _$tabDataRepositoryHash() => r'e6d8f328368e7525bdd970d8cb3fdea6f0f03a85';
|
String _$tabDataRepositoryHash() => r'0ab598656accfc90a15a9bfef3899cd3bb577b66';
|
||||||
|
|
||||||
abstract class _$TabDataRepository extends $Notifier<void> {
|
abstract class _$TabDataRepository extends $Notifier<void> {
|
||||||
void build();
|
void build();
|
||||||
|
|||||||
Reference in New Issue
Block a user